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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My Delphi Program wont show JPegs!

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
I need help

I want to display the file Titleimage.jpeg in the Image location, but it says Delphi doesn't recognise it!

Any ideas?


PROGRAMS USES
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMan, StdCtrls, ExtCtrls, Buttons, ComCtrls, Grids, DBGrids;


CODE INVOLVING THE IMAGE
Image.Picture.LoadFromFile('Images/titleimage.jpg');
 
Code:
uses Jpeg,...


procedure LoadJpeg(filename: string);
var jpeg : TJepImage;
begin
 jpeg:=TJepImage.Create;
 try
  Jpeg.loadFromFile(filename);
  Image.Picture.Assign(Jpeg);
 finally
  FreeAndNil(Jpeg);
 end;
end;

--------------------------------------
What You See Is What You Get
 
But you might have a problem with 'TJepImage' (typo whosrdaddy?)

jpeg:=TJpegImage.Create;
Works for me
but D3 dosnt want anything to do with 'FreeandNil'.
You can do Jpeg.free but jpeg.assign(nil) dosent work, there may be some other way to clear the momory before freeing it?



Steve
Two things are infinite
The Universe and Human stupidity: Einstein.
(He wasn't too sure about the Universe)
 
procedure FreeAndNil(var Obj);
var
Temp: TObject;
begin
Temp := TObject(Obj);
Pointer(Obj) := nil;
Temp.Free;
end;

copy/paste from D7

--------------------------------------
What You See Is What You Get
 
I don't know if you've gathered it from these responses, but all you really have to do is add JPEG to the uses clause of the form or forms that use them. Just that will allow your existing code to work just fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top