ImageEn, unit iexBitmaps

TIEBitmap.MergeWithAlpha

TIEBitmap.MergeWithAlpha


Declaration


procedure MergeWithAlpha(Bitmap: TIEBitmap; DstX: integer=0; DstY: integer=0; DstWidth: integer=-1; DstHeight: integer=-1; Transparency: integer=255; ResampleFilter: TResampleFilter = rfNone; Operation: TIERenderOperation = ielNormal; Resample: boolean = false; ; SrcX: integer = 0; SrcY: integer = 0; Opacity: double = 1.0);


Description


Merges pixels and alpha channel of Bitmap with the background.

Parameter Description
Bitmap Source image with alpha channel to merge with the background.
DstX Horizontal destination position.
DstY Vertical destination position.
DstWidth Destination width (Bitmap will be resampled/cropped to this value). -1 = the same width of source bitmap.
DstHeight Destination height (Bitmap will be resampled/cropped to this value). -1 = the same height of source bitmap.
Transparency Transparency of source bitmap. 0 = fully transparent, 255 = fully opaque.
ResampleFilter Interpolation filter used when source bitmap needs to be resampled.
Operation Blender operation to perform.
Resample If true Bitmap is resampled, otherwise it is cropped.
SrcX Source bitmap left position.
SrcY Source bitmap top position.



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


// merges uplayer.png over background.png
ImageEnView1.IO.LoadFromFile('background.png');
ImageEnView2.IO.LoadFromFile('uplayer.png');
ImageEnView1.IEBitmap.MergeWithAlpha(ImageEnView2.IEBitmap);
ImageEnView1.Update;
ImageEnView1.IO.SaveToFile('output.png');