TIEBitmap.RemoveAlphaChannel
TIEBitmap.RemoveAlphaChannel
Declaration
procedure RemoveAlphaChannel(Merge: boolean = false; BackgroundColor: TColor = clWhite);
Description
Removes the
alpha channel of the image (the channel that specifies the transparency of an image).
When Merge is true, the specified
BackgroundColor is merged with the semi-transparent areas of the image (like a shadow).
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
// Load a transparent PNG, remove the alpha channel (merging with a white background). Then save as a JPEG
aBmp := TIEBitmap.Create();
aBmp.LoadFromFile('D:\TransparentImage.png');
aBmp.RemoveAlphaChannel( True, clWhite );
aBmp.SaveToFile('D:\Out.jpeg');
aBmp.Free();
// Convert a 32bit PNG file to an 8bit PNG (without transparency)
ImageEnView1.IO.LoadFromFile( 'D:\Alpha.png');
// Remove alpha channel and make background white
ImageEnView1.IEBitmap.RemoveAlphaChannel( True, clWhite );
// Set PixelFormat to 8bit
ImageEnView1.IEBitmap.PixelFormat := ie8p;
// Use PixelFormat as authoritative source of bit-depth
IEGlobalSettings().AutoSetBitDepth := True;
ImageEnView1.IO.SaveToFile('D:\No-Alpha.png');