I want to do the following using the ATL CImage class. (This is a
stripped down version of what I really need)... Create a 4 bits per
pixel bitamp which is 2 pixels by 2 pixels Set a color table
(palette). Set the pixels (via palette index). I just can't get it
to work. Either I am missing the point or this stuff is bugged.
Here's my example code
#include <atlimage.h>
......
CImage image;
image.Create(2, 2, 4, 0);
RGBQUAD colors[16];
ZeroMemory(&colors, sizeof(colors));
colors[0].rgbBlue = 0xAA;
colors[0].rgbGreen = 0xBB;
colors[0].rgbRed = 0xCC;
colors[0].rgbReserved = 0;
colors[1].rgbBlue = 0xDD;
colors[1].rgbGreen = 0xEE;
colors[1].rgbRed = 0xFF;
colors[1].rgbReserved = 0;
colors[2].rgbBlue = 0xAB;
colors[2].rgbGreen = 0xCD;
colors[2].rgbRed = 0xEF;
colors[2].rgbReserved = 0;
colors[3].rgbBlue = 0xBC;
colors[3].rgbGreen = 0xBA;
colors[3].rgbRed = 0xBD;
colors[3].rgbReserved = 0;
colors[4].rgbBlue = 0x12;
colors[4].rgbGreen = 0x12;
colors[4].rgbRed = 0x12;
colors[4].rgbReserved = 0;
colors[5].rgbBlue = 0x22;
colors[5].rgbGreen = 0x22;
colors[5].rgbRed = 0x22;
colors[5].rgbReserved = 0;
colors[6].rgbBlue = 0x33;
colors[6].rgbGreen = 0x33;
colors[6].rgbRed = 0x33;
colors[6].rgbReserved = 0;
....
image.SetColorTable(0, 16, colors);
image.SetPixelIndexed(0,0,0);
image.SetPixelIndexed(0,1,1);
image.SetPixelIndexed(1,0,2);
image.SetPixelIndexed(1,1,3);
COLORREF c00 = image.GetPixel(0,0); //returns 0x00000000 (expecting
AABBCC...)
COLORREF c01 = image.GetPixel(0,1); //returns 0x33333333 (expecting
DDEEFF...)
COLORREF c10 = image.GetPixel(1,0); //returns 0x33333333
COLORREF c11 = image.GetPixel(1,1); //returns 0x33333333
Can anyone help? I am at my wits end with this :-(
SetPixel(0, 0, DIBINDEX(0));
SetPixel(0, 1, DIBINDEX(1));
SetPixel(1, 0, DIBINDEX(2));
SetPixel(1, 1, DIBINDEX(3));
The world of bitmaps, palettes, DIBs, DDBs, etc. can be very complicated and confusing. This is
partly because of a need to support a long legacy of ancient formats and techniques, as well as to
provide numerous ways to provide efficient abstractions so that color schemes can be swapped out
easily. I'm sure there are other reasons why it has become a "mess". I suggest that if you need to
get into this world, you do some more intense reading of the myriad of articles "out there" on these
topics.
<renegade_m...@yahoo.co.uk> wrote in message
news:d36908a6-93ff-44fa...@s31g2000vbp.googlegroups.com...
Simon
On 24 May, 08:50, "Scot T Brennecke" <Sc...@MVPs.spamhater.org> wrote:
> The trap you've fallen into is assuming that the color table in the DIB section is the same as the
> palette selected into the DC. When you call SetPixelIndexed, you are telling it to use the index of
> a palette entry, which is not the same as an index into the color table. To get the results you are
> expecting, you will need to do this:
>
> SetPixel(0, 0, DIBINDEX(0));
> SetPixel(0, 1, DIBINDEX(1));
> SetPixel(1, 0, DIBINDEX(2));
> SetPixel(1, 1, DIBINDEX(3));
>
> The world of bitmaps, palettes, DIBs, DDBs, etc. can be very complicated and confusing. This is
> partly because of a need to support a long legacy of ancient formats and techniques, as well as to
> provide numerous ways to provide efficient abstractions so that color schemes can be swapped out
> easily. I'm sure there are other reasons why it has become a "mess". I suggest that if you need to
> get into this world, you do some more intense reading of the myriad of articles "out there" on these
> topics.
>
> <renegade_master_12...@yahoo.co.uk> wrote in message