ImageEn, unit iexBitmaps

TIEBitmap.RenderToCanvasWithAlpha

TIEBitmap.RenderToCanvasWithAlpha


Declaration


procedure RenderToCanvasWithAlpha(Dest: TCanvas; xDst, yDst, dxDst, dyDst: integer; xSrc, ySrc, dxSrc, dySrc: integer; Transparency: integer = 255; Filter: TResampleFilter = rfNone; RenderOperation: TIERenderOperation = ielNormal; Opacity: double = 1.0);


Description


Draws the rectangle, xSrc, ySrc, dxSrc, dySrc, within the destination rectangle, xDst, yDst, dxDst, dyDst, of Dest TCanvas object.
Transparency specifies the transparency value (0=Fully Transparent to 255=Fully Opaque).
Filter the resampling filter.
RenderOperation the rendering operation.
Opacity specifies the opacity (0=Fully Transparent to 1.0=Fully Opaque).

This functions reads the destination canvas pixels and merges them with image using the alpha channel mask.


Opacity vs Transparency


Both the Opacity and Transparency parameters provide the same functionality. Transparency is the traditional ImageEn value, whereas Opacity provides easier PSD compatibility.
While they can be used in combination, generally only one will be used, i.e. leave Opacity=1 and make use of transparency, or alternatively, leave Transparency=255 and make use of Opacity. For example, for 50% opacity: Transparency = 255 and Opacity = 0.5, or Transparency = 128 and Opacity = 1.0




Example


// Draw aIEBitmap within aRect while maintaining the aspect ratio of the image
aRect := GetImageRectWithinArea( aIEBitmap.Width, aIEBitmap.Height, aRect );
aIEBitmap.RenderToCanvasWithAlpha( aCanvas, aRect.Left, aRect.Top, aRect.Right - aRect.Left, aRect.Bottom - aRect.Top, 0, 0, aIEBitmap.Width, aIEBitmap.Height, 255, rfFastLinear );


See Also


- DrawToCanvasWithAlpha
- RenderToCanvas