Solved

Problem with TJPEGImage!

Posted on 1998-04-29
2
328 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now