Solved

Problem with TJPEGImage!

Posted on 1998-04-29
2
329 Views
Last Modified: 2012-05-04
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!
0
Comment
Question by:Dippen
2 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 70 total points
ID: 1339476
Hi

Yes, you MUST free & recreate the jpeg image each time.

E.g.
var
  Jp: TJPegImage;
begin
  Jp := TJPegImage.Create;
  Jp.LoadFromFile('Test1.jpg');
  imgTest.Picture.Bitmap.Assign(Jp);
  Jp.Free;

  // Do stuff...

  Jp := TJPegImage.Create;
  Jp.LoadFromFile('Test2.jpg');
  imgTest.Picture.Bitmap.Assign(Jp);
  Jp.Free;

Cheers,
JB
0
 
LVL 1

Expert Comment

by:acerola
ID: 1339477
try
Image1.Picture.Assign(JPEG);
instead of
Image1.Picture.Bitmap.Assign(JPEG);
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question