Mirror

How to assign a TImage to a TBitmap at runtime (Views: 16)


Problem/Question/Abstract:

Is it possible to assign a TImage.picture (a JPEG image) to a different TBitmap (created at runtime)? I want to copy the content of a TImage to another bitmap, but it seems to only works for .bmp files.

Answer:

I've done this without any problems. One thing to make sure is that the JPEG unit is in the uses clause. If I understand you correctly you want to do something like:

{ ... }
b := TBitmap.Create;
try
  b.Assign(Image1.Picture.Graphic);
  Image2.Picture.Graphic := b;
finally
  b.Free;
end;

Where the Image1 graphic is a TJPEGImage. This code works for me as long as the JPEG is in
the uses clause.

<< Back to main page