TIECanvas.SetCompositingMode
TIECanvas.SetCompositingMode
Declaration
procedure TIECanvas.SetCompositingMode(Mode: TIECanvasCompositingMode; Quality: TIECanvasCompositingQuality);
Description
Specify how alpha compositing is performed.
Suppose you create an object that has an alpha of 192, which is about 75% of 255.
If your compositing mode is CompositingModeSourceOver, then areas filled with the object are a blend that is 75% brush color and 25% background color.
If your compositing mode is CompositingModeSourceCopy, then the background color is not blended with the brush color. However, the color rendered by the brush has an intensity that is 75% of what it would be if the alpha component were 255.
GDI+ Methods: GdipSetCompositingMode, GdipSetCompositingQuality
// Draw a semi-transparent ellipse
var
bmp: TIEBitmap;
begin
bmp := TIEBitmap.Create( 500, 500, ie32RGB ); // <= RGBA required!
bmp.Fill( 0 );
bmp.AlphaChannel.Fill( 0 );
bmp.IECanvas.SetCompositingMode( ieCompositingModeSourceOver, ieCompositingQualityDefault );
bmp.IECanvas.Pen.Width := 4;
bmp.IECanvas.Pen.Color := clRed;
bmp.IECanvas.Brush.Color := clBlue;
bmp.IECanvas.Pen.Transparency := 90;
bmp.IECanvas.Brush.Transparency := 90;
bmp.IECanvas.Ellipse(10, 10, 400, 400);
bmp.SynchronizeRGBA( True ); // <= gdi+ draws alpha on RGBA. This copies 'A' to TIEBitmap alpha channel
ImageEnView1.IEBitmap.Assign( bmp );
ImageEnView1.Update;
bmp.Free();
end;
// Draw a custom shape onto a bitmap
bmp := TIEBitmap.Create( w, h, ie32RGB );
bmp.Fill( clWhite ); // Note: Used as the blend color for the anti-aliasing of GDI+ objects
bmp.AlphaChannel.Fill(0);
bmp.IECanvas.SetCompositingMode(ieCompositingModeSourceOver, ieCompositingQualityDefault);
bmp.IECanvas.DrawShape( 0, 0, bmp.Width, bmp.Height, ... );
bmp.SynchronizeRGBA( True, True );