I\'m loading an image from disk and want to copy (part of) it to a second TImage:
Image1.Picture.LoadFromFile(S);
with Image1.Picture.Bitmap do
Image2.Ca
TCanvas.CopyRect
copies the rectangle by using StretchBlt
. StretchBlt requires a bitmap. If you're loading any other graphic type to your image then its Picture.Bitmap
is empty. In fact the bitmap gets created just when you refer to it: with Image1.Picture.Bitmap do
.
You can use a temporary bitmap for the cause:
var
Bmp: TBitmap;
begin
Image1.Picture.LoadFromFile(S);
Bmp := TBitmap.Create;
try
Bmp.Assign(Image1.Picture.Graphic);
with Bmp do
Image2.Canvas.CopyRect(Image2.Canvas.ClipRect, Canvas, Canvas.ClipRect);
finally
Bmp.Free;
..