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 have a specific transparent color, you can set MinColor and MaxColor to the same value. You can also use the second overload, to specify a transparent color and the Tolerance (0 to 255, where 0 requires an exact color match, whereas 255 would match every color) to auto-calculate the color range.
Note: ◼If the image PixelFormat is not one of ie24RGB, ie32RGB, ie1g, it will be converted ◼An AlphaChannel will be added to the image, if it does not exist ◼A UI for this is available to your users in the Image Processing dialog
// Specify all colors from gray (128, 128, 128) to white (255, 255, 255) as transparent ImageEnView1.Proc.SetTransparentColors(CreateRGB(128, 128, 128), CreateRGB(255, 255, 255), 0);
// Make all colors close to white transparent ImageEnView1.Proc.SetTransparentColors( TColor2TRGB( clWhite ), 20, 0 );
// Convert a bitmap to PNG where the bottom-left pixel represents the transparent color bmp := TIEBitmap.Create(); bmp.LoadFromFile( 'D:\Glyph_Source.bmp'); // Get transparent color (transColor is type TRGB) transColor := bmp.Pixels[ 0, bmp.Height - 1 ]; bmp.SetTransparentColors( transColor, transColor, 0 ); bmp.SaveToFile( 'D:\Glyph_Output.png'); bmp.Free;
Glyph_Source.bmp:
Glyph_Output.png:
// Example of drawing text with soft shadow over a background image ImageEnView1.IO.LoadFromfile('background.jpg'); // load background image ImageEnView1.LayersAdd(); // add a new layer ImageEnView1.IEBitmap.Canvas.Font.Name := 'Tahoma'; ImageEnView1.IEBitmap.Canvas.Font.Height := 45; ImageEnView1.IEBitmap.Canvas.Font.Color := clYellow; ImageEnView1.IEBitmap.Canvas.TextOut(0, 250, 'Hello World!'); // draw text on second layer ImageEnView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0); // remove the white, making it as transparent ImageEnView1.Proc.AddSoftShadow(2, 3, 3); // add the shadow
// Load test image ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );
// Make colors similar to white transparent ImageEnView1.Proc.SetTransparentColors( CreateRGB(255, 255, 255), 50, 0 );