ImageEn, unit iexBitmaps

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).

Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr

Examples

Also see: Automated Samples
// Load a transparent PNG, remove the alpha channel (merging with a white background). Then save as a JPEG
bmp := TIEBitmap.Create();
bmp.LoadFromFile('D:\TransparentImage.png');
bmp.RemoveAlphaChannel( True, clWhite );
bmp.SaveToFile('D:\Out.jpeg');
bmp.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');

See Also

AlphaChannel