Solved

Problem with TJPEGImage!

Posted on 1998-04-29
2
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 112
Run video youtube webbrowse 10 86
TEMBEDDEDWB how can i change its user agent ? 8 106
Delphi android app hide keyboard 3 84
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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