Link to home
Start Free TrialLog in
Avatar of Dippen
Dippen

asked on

Problem with TJPEGImage!

Hi!

Why doesn't the code below work? It displays test1.jpg just fine (Image1 is an TImage that is put at the form at design-time), but it refuses to display test2.jpg. Do I have to reset (in some way) or even DESTROY the TJPEGImage between these operations?

procedure TForm1.FormShow(Sender: TObject);
var
  JPEG : TJPEGImage;

begin
  JPEG := TJPEGImage.Create;
  JPEG.LoadFromFile('\Temp\Test1.jpg');
  Image1.Picture.Bitmap.Assign(JPEG);
  //**************
  JPEG.LoadFromFile('\Temp\Test2.jpg');
  Image1.Picture.Bitmap.Assign(JPEG);
  Image1.Repaint;
end;

All help appreciated!
ASKER CERTIFIED SOLUTION
Avatar of JimBob091197
JimBob091197

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of acerola
acerola

try
Image1.Picture.Assign(JPEG);
instead of
Image1.Picture.Bitmap.Assign(JPEG);