Assume a monochrome (1 bit per pixel) IEImage with two palette entries that are not black and white.
Saving such an image in PNG format generates a PNG file with black and white color, not respecting the two palette colors.
// Create IEBitmap
Bmp := TIEBitmap.Create;
// Load monochrome bitmap with green and blue color and keep palette (don't convert to 24 bit)
Bmp.ParamsEnabled := true;
if Bmp.Params.Read('Bear_green_blue.bmp') then begin
if (Bmp.Params.BitsPerSample * Bmp.Params.SamplesPerPixel <= 8) then begin
Bmp.Params.NativePixelFormat := true;
end;
end;
if Bmp.Read('Bear_green_blue.bmp') then ...
// Save bitmap as PNG
Bmp.ParamsEnabled := true;
Bmp.Params.NativePixelFormat := true;
if Bmp.Write('Bear_green_blue.bmp', ioPNG) then ... // the saved file uses black and white instead of green and blue
// Free IEBitmap
Bmp.Free;
