ImageEn, unit iexBitmaps

TIEBitmap.DrawToTIEBitmap

TIEBitmap.DrawToTIEBitmap


Declaration


procedure DrawToTIEBitmap(Dest: TIEBitmap; XDest, YDest : Integer); overload; // Draw whole image
procedure DrawToTIEBitmap(Dest: TIEBitmap; XDest, YDest : Integer; SrcRect : TIERectangle); overload; // Draw part of image
procedure DrawToTIEBitmap(Dest: TIEBitmap; DestRect : TIERectangle; SrcRect : TIERectangle; Filter: TResampleFilter = rfLanczos3); overload; // Stretch draw image


Description


Draws content of the current IEBitmap onto another IEBitmap.
Overload 1 will draw the whole of the current image at coordinates XDest, YDest.
Overload 2 allows you to specify a portion of the current image to draw at coordinates XDest, YDest.
Overload 3 allows you to stretch draw (enlarge or reduce) the image.

Dest PixelFormat must be ie24RGB.

Note: Use IERectangle to convert a standard TRect to a TIERectangle


Examples


// Stretch Draw an image centered within a TIEBitmap
aRect := GetImageRectWithinArea( SrcBMP.Width, SrcBMP.Height, DestBMP.Width, DestBMP.Height);
SrcBMP.DrawToTIEBitmap( DestBMP, IERectangle( aRect ), IERectangle( 0, 0, SrcBMP.Width, SrcBMP.Height ) );


// DRAW TWO IMAGES BESIDE EACH OTHER (USING OVERLOAD 1)

// Load input files
IEBitmap1.Read('D:\MyPic1.png');
IEBitmap2.Read('D:\MyPic2.jpg');

// Get Left position for IEBitmap2
iBitmap1Width := IEBitmap1.Width;

// Resize IEBitmap1
IEBitmap1.Resize(IEBitmap1.Width + IEBitmap2.Width, iMax(IEBitmap1.Height, IEBitmap2.Height), clWhite, 255, iehLeft, ievCenter);

// Draw IEBitmap2
IEBitmap2.DrawToTIEBitmap(IEBitmap1, iBitmap1Width, 0);

// Save output file
IEBitmap2.Write('D:\Output.png');



// DRAW TWO IMAGES BESIDE EACH OTHER, BUT ONLY OUTPUT CENTRAL PORTION OF SECOND IMAGE (USING OVERLOAD 2)

// Load input files
IEBitmap1.Read('D:\MyPic1.png');
IEBitmap2.Read('D:\MyPic2.jpg');

// Get Left position for IEBitmap2
iBitmap1Width := IEBitmap1.Width;

// Resize IEBitmap1
IEBitmap1.Resize(IEBitmap1.Width + IEBitmap2.Width div 2, iMax(IEBitmap1.Height, IEBitmap2.Height div 2), clWhite, 255, iehLeft, ievCenter);

// Draw IEBitmap2
IEBitmap2.DrawToTIEBitmap(IEBitmap1, iBitmap1Width, 0, IERectangle(IEBitmap2.Width div 4, IEBitmap2.Height div 4, IEBitmap2.Width div 2, IEBitmap2.Height div 2));

// Save output file
IEBitmap2.Write('D:\Output.png');



// DRAW TWO IMAGES BESIDE EACH OTHER, BUT ONLY OUTPUT CENTRAL PORTION OF SECOND IMAGE AT DOUBLE SIZE (USING OVERLOAD 3)

// Load input files
IEBitmap1.Read('D:\MyPic1.png');
IEBitmap2.Read('D:\MyPic2.jpg');

// Get Left position for IEBitmap2
iBitmap1Width := IEBitmap1.Width;

// Resize IEBitmap1
IEBitmap1.Resize(IEBitmap1.Width + IEBitmap2.Width, iMax(IEBitmap1.Height, IEBitmap2.Height), clWhite, 255, iehLeft, ievCenter);

// Draw IEBitmap2
IEBitmap2.DrawToTIEBitmap(IEBitmap1,
                          IERectangle(iBitmap1Width, 0, IEBitmap2.Width, IEBitmap2.Height),
                          IERectangle(IEBitmap2.Width div 4, IEBitmap2.Height div 4, IEBitmap2.Width div 2, IEBitmap2.Height div 2));

// Save output file
IEBitmap2.Write('D:\Output.png');



// DRAW TWO IMAGES BESIDE EACH OTHER, BUT OUTPUT SECOND IMAGE AT HALF SIZE (USING OVERLOAD 3)

// Load input files
IEBitmap1.Read('D:\MyPic1.png');
IEBitmap2.Read('D:\MyPic2.jpg');

// Get Left position for IEBitmap2
iBitmap1Width := IEBitmap1.Width;

// Resize IEBitmap1
IEBitmap1.Resize(IEBitmap1.Width + IEBitmap2.Width div 2, iMax(IEBitmap1.Height, IEBitmap2.Height div 2), clWhite, 255, iehLeft, ievCenter);

// Draw IEBitmap2
IEBitmap2.DrawToTIEBitmap(IEBitmap1,
                          IERectangle(iBitmap1Width, 0, IEBitmap2.Width div 2, IEBitmap2.Height div 2),
                          IERectangle(0, 0, IEBitmap2.Width, IEBitmap2.Height));

// Save output file
IEBitmap2.Write('D:\Output.png');


See Also


- RenderToTIEBitmap
- RenderToTIEBitmapEx