From: Peter Olcott on
I carefully constructed a 24-bit bitmap to have exactly 256
unique colors.
I converted this bitmap to use an optimized 8-bit palette
retaining the exact same 256 colors using an image editor.
I compared all of these images to the original using the
BeyondCompare diff tool, they all has identical pixels.

CImage image;
image.Load("256colors.bmp"); // 24-bit
image.Save("test.gif");

The colors now have been changed by several shades.

To fix this I have to create my own color index table
precisely defining the colors that I want to use, and then
copy the original file to the bitmap with the new color
index table.

I have been unable to find the precise syntax for doing
this.


From: John H. on
On Mar 3, 4:06 pm, "Peter Olcott" <NoS...(a)OCR4Screen.com> wrote:
> I have to create my own color index table
> I have been unable to find the precise syntax for doing
> this.

For the 8bit image you will want to construct a CImage, and Create the
image to be the same size as the original image, with 8 bits per
pixel.
Next you will want to use SetColorTable, pass in a color table 256
entries long, with each entry holding one of the colors you used in
the 32bit image.
Next you can use GetPixel on the 32bit image and SetPixelIndexed on
the 8bit image to copy the image pixels from the 32bit image to the
8bit image. You will "get" 32 bit colors, and "set" the index of that
color from the color table.
Does this provide the level of detail you need?
From: Peter Olcott on

"John H." <oldman_fromthec(a)yahoo.com> wrote in message
news:5f608377-5c65-4b50-8f44-a6df18c50a45(a)g10g2000yqh.googlegroups.com...
On Mar 3, 4:06 pm, "Peter Olcott" <NoS...(a)OCR4Screen.com>
wrote:
> I have to create my own color index table
> I have been unable to find the precise syntax for doing
> this.

For the 8bit image you will want to construct a CImage, and
Create the
image to be the same size as the original image, with 8 bits
per
pixel.
Next you will want to use SetColorTable, pass in a color
table 256
entries long, with each entry holding one of the colors you
used in
the 32bit image.
Next you can use GetPixel on the 32bit image and
SetPixelIndexed on
the 8bit image to copy the image pixels from the 32bit image
to the
8bit image. You will "get" 32 bit colors, and "set" the
index of that
color from the color table.
Does this provide the level of detail you need?

Yes that was the exact level of detail that I was hoping
for.
Is there any way to make the process that you defined
optimal for speed?


From: John H. on
On Mar 4, 11:54 am, "Peter Olcott" <NoS...(a)OCR4Screen.com> wrote:
> Is there any way to make the process that you defined
> optimal for speed?

I am not sure a fast way to build up the color table, but once you
have that, CImage::BitBlt might be the fastest way copy the pixels.
From: Peter Olcott on

"John H." <oldman_fromthec(a)yahoo.com> wrote in message
news:8a392a65-e14e-41c9-aeab-ff91acbc0868(a)33g2000yqj.googlegroups.com...
On Mar 4, 11:54 am, "Peter Olcott" <NoS...(a)OCR4Screen.com>
wrote:
> Is there any way to make the process that you defined
> optimal for speed?

I am not sure a fast way to build up the color table, but
once you
have that, CImage::BitBlt might be the fastest way copy the
pixels.

Do you think that it could copy from 32-bit to 8-bit
indexed?