ImageEn, unit iexBitmaps

TIEBitmap.CopyToTBitmap

TIEBitmap.CopyToTBitmap


Declaration

procedure CopyToTBitmap(Dest: TBitmap; AlphaToRGBA: Boolean = False);


Description

Copies the image to the Dest TBitmap object. These PixelFormat conversions are applied:
ie1g -> pf1bit
ie8p -> pf8bit
ie8g -> pf8bit (create gray scale palette)
ie16g -> pf8bit (copy only high 8 bit)
ie24RGB* -> pf24bit
ie32RGB -> pf32bit

If AlphaToRGBA is enabled and the image has an alpha channel, it will be output as a 32bit (RGBA) bitmap image by calling SynchronizeRGBA( False, True ).

Note: If scaling is required, use AssignTo


Examples

// Copy the displayed image to a TBitmap
ImageEnView1.IEBitmap.CopyToTBitmap( MyBmp );

// Copy the displayed image to a TImage
ImageEnView1.IEBitmap.CopyToTBitmap( Image1.Picture.Bitmap );

// Load a RAW image into a TImage
myBmp := TIEBitmap.create;
myBmp.Read( 'C:\camera.dng' );
myBmp.CopyToTBitmap( Image1.Picture.Bitmap );
myBmp.Free;

// Output content of TImageEnView as a 32bit Bitmap with alpha channel
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create();
  ImageEnView1.IEBitmap.SynchronizeRGBA( False, True ); // Convert 24bit Image + Alpha channel to 32bit RGBA
  ImageEnView1.IEBitmap.CopyToTBitmap( bmp );
  ... bmp is now 32bit
  bmp.Free();
end;

// Copy TIEBitmap with Alpha to 32bit BMP
iebmp := TIEBitmap.Create();
bmp   := TBitmap.create;
iebmp.Read( 'D:\OriginalAlpha.png' );
iebmp.SynchronizeRGBA( False, True ); // Convert 24bit Image + Alpha channel to 32bit RGBA
iebmp.CopyToTBitmap( bmp );
... Do something with bitmap, e.g. bmp.SaveToFile( 'D:\BMP32.bmp' );
bmp.Free;
iebmp.Free;


See Also

 SynchronizeRGBA
 BMP_HandleTransparency
 CopyFromTBitmap


TIEBitmap Assignment and Drawing Methods

TIEBitmap Methods
Method Mode Purpose
Assign From TIEBitmap/TBitmap/TGraphic/TIcon Copy whole image
AssignImage From TIEBitmap Like assign, but does not copy the alpha channel
AssignRect From TIEBitmap/TBitmap Copy a specified rect
CopyAndConvertFormat From TIEBitmap Copy whole image
CopyRectTo To TIEBitmap Copy rect to another image (without scaling)
CopyWithMask1 To TIEBitmap Copy image using a mask to specify what is copied from the source
CopyWithMask2 To TIEBitmap Copy image using a mask to specify what is replaced in the destintation
DrawToTIEBitmap To TIEBitmap Copies all or part of the image to a specified position and/or size
JoinBitmaps From two TIEBitmaps Draws two bitmaps to a single bitmaps
MergeAlphaRectTo With TIEBitmap Merges the alpha channels of two TIEBitmaps using merge rules
MergeWithAlpha With TIEBitmap Merges all or part of two TIEBitmaps with alpha channels to a specified position
RenderToTIEBitmapEx To TIEBitmap Extended drawing of content to a TIEBitmap
StretchRectTo To TIEBitmap Copy rect to dest rect in another image (with scaling)
SwitchTo To TIEBitmap Move content from one TIEBitmap to another

TBitmap Methods
Method Mode Purpose
Assign From TIEBitmap/TBitmap/TGraphic/TIcon Copy whole image
AssignTo To TIEBitmap/TBitmap Copy whole image with optional scaling
AssignRect From TIEBitmap/TBitmap Copy a specified rect
CopyFromTBitmap From TBitmap Copy whole image
CopyToTBitmap To TBitmap Copy whole image
RenderToTBitmapEx To TBitmap Extended drawing of content to a TBitmap

TCanvas Methods
Method Mode Purpose
DrawToCanvas To TCanvas Copies whole image to canvas at specified position (ignoring the alpha channel)
DrawToCanvasWithAlpha To TCanvas Copies whole image to canvas at specified position (honoring the alpha channel)
RenderToCanvas To TCanvas Extended drawing of content to a TCanvas (ignoring the alpha channel)
RenderToCanvasWithAlpha To TCanvas Extended drawing of content to a TCanvas (honoring the alpha channel)