ImageEn, unit iexBitmaps

TIEBitmap.RemoveAlphaChannel

TIEBitmap.RemoveAlphaChannel


Declaration

procedure RemoveAlphaChannel(Merge: boolean = false; BackgroundColor: TColor = clWhite);


Description

Removes the associated alpha channel.
When Merge is true, the specified BackgroundColor is merged with the semitransparent areas of the image (like a shadow).


Examples

// Load a transparent PNG, remove the alpha channel (merging with a white background). Then save as a JPEG
aBmp := TIEBitmap.Create;
aBmp.Read('D:\TransparentImage.png');
aBmp.RemoveAlphaChannel( True, clWhite );
aBmp.Write('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');