Why hazel? When you use LockBits, you can use PixelFormat24bppRGB as a parameter for three LockBits, since the system copies data anyway (you never had direct access to image data in GDI +).
Here are some of the errors I found (for now):
int paletteSize =b->GetPaletteSize(); ColorPalette colorPalette; b->GetPalette(&colorPalette,paletteSize/4);
Why division by four? GetPaletteSize returns the size in bytes, and GetPalette expects the size in bytes. ColorPalette is a placeholder definition, one of the darkest that Microsoft developers have done with us. It only defines the first color entry!
use a byte pointer, for example:
void *palette=new char[paletteSize]; b->GetPalette((ColorPalette *)palette,paletteSize);
Using
((ColorPalette *)palette)->Entries[i]
When you need to access the color.
Sorry, this is really as ugly as it seems when you use palettes directly. Remember to free the palette and ... ... good luck.
source share