Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image changeing picture during runtime

Status
Not open for further replies.

HelpMEDude

Programmer
Feb 27, 2005
21
SE
Hi and thank you for answering on my previous question and now im up for my second question which may look easy but i never found any answer.

The problem is what the topic says: When I load a picture to image1.picture the (TJPEGImage) text appears, thats no destination, if it was i could during runtime say something like Image1.picture:= example.jpg, is there anyway that make you able to edit the picture during runtime? and if it is not anyway to do that can you at least tell me if there is any component thats only ability for it is to show pictures inserted in a imagelist?
 
Hi, a useful tip!
Search the Delphi sourcecode, it may give you some help...

Example:
Code:
uses
  Jpeg;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Image1.Picture.Graphic := TJPEGImage.Create;
  Image1.Picture.Graphic.LoadFromFile('C:\1.JPG');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Image1.Picture.Graphic := TJPEGImage.Create;
  Image1.Picture.Graphic.LoadFromFile('C:\2.JPG');
end;

KungTure-RX.jpg

//Nordlund
 
...or even easier:
Load the example: C:\Program files\Borland\Delphi7\Help\Examples\Jpeg

KungTure-RX.jpg

//Nordlund
 
...and a version without memoryleaks (I guess)
Code:
uses
  Jpeg;
var
  J: TJpegImage;

procedure TForm1.FormCreate(Sender: TObject);
begin
  J := TJPEGImage.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  J.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  J.LoadFromFile('C:\Temp\Pict0037.jpg');
  Image1.Picture.Graphic := J;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
  J.LoadFromFile('C:\Temp\Pict0038.jpg');
  Image1.Picture.Graphic := J;
end;

KungTure-RX.jpg

//Nordlund
 
Thank you. i didnt get much about the edample in the folder you showed me but the first post helped me much, thank you!
 
Here i am again!

My next problem is about the same issue, since i noticed another less urgent problem.

The problem is that the area image1 is on turns white for a
fraction of a second (i mean a very very short second if you didnt understand) and that makes an irritation in the program.

Also take note that im using JPG pics (could that be a reason?) and 15 pictures are changeing pic per second and at once.
 
You could try using LockWindowUpdate to prevent your screen from updating whilst loading the pictures.
Do LockWindowUpdate(Form1.Handle) to stop Form1 from updating, and then do LockWindowUpdate(0) to allow Form1 to update again. I'd advise you to put this bit in a finally block to ensire that it is always executed. e.g.

Code:
try
  LockWindowUpdate(Form1.Handle);
  Image1.Picture.Graphic.LoadFromFile('C:\1.JPG');
finally
  LockWindowUpdate(0);
end;

I'm not sure that this will be an improvement, but give it a try.

Steve
 
Sorry didnt work, can it have anything to do that i must uncode *.jpg* files or something?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top