ImageEn, unit iexBitmaps

TIEBitmap.SetTransparentColors

TIEBitmap.SetTransparentColors


Declaration

procedure SetTransparentColors(MinColor, MaxColor: TRGB; Alpha: Integer); overload;
procedure SetTransparentColors(MinColor, MaxColor: TColor; Alpha: Integer); overload;


Description

Sets all pixels within the MinColor and MaxColor range as transparent. The level of transparency is specified by Alpha (0=fully transparent, 255=fully visible).
If you are sure of the transparent color, you can set MinColor and MaxColor to the same value.




Examples

// Specify all colors from gray (128, 128, 128) to white (255, 255, 255) as transparent
MyBMP.SetTransparentColors( CreateRGB(128, 128, 128), CreateRGB(255, 255, 255), 0 );

// Set all white pixels as transparent
MyBMP.SetTransparentColors( clWhite, clWhite, 0 );

// Convert a bitmap to PNG where the bottom-left pixel represents the transparent color
bmp := TIEBitmap.Create;
bmp.Read( 'D:\Glyph_Source.bmp');
// Get transparent color (transColor is type TRGB)
transColor := bmp.Pixels[ 0, bmp.Height - 1 ];
bmp.SetTransparentColors( transColor, transColor, 0 );
bmp.Write( 'D:\Glyph_Output.png');
bmp.Free;

Glyph_Source.bmp:  
Glyph_Output.png:  


See Also

 CreateRGB
 TRGB2TColor
 TColor2TRGB