views:

122

answers:

1
procedure TmainForm.FormCreate(Sender: TObject);
  var img : TImage;
      pic:TPicture;

begin
  pic := TPicture.create();
  pic.LoadFromFile('my_picture.jpg');
  img :=  Timage.create(Self);
  img.Picture := pic;
end;

...

"Project MyProect.exe raised exception class EInvalidGraphic 
with message 'Unknown picture extension (.jpg)'" 

and, sure enough, right there in function TPicturePropertyEditor.Execute() it only handles .ICO and .BMP files!

The weird thing is that if I place a TImage on a form at design time & click its Picture property then the file load dialog shows me .JPG files (and crashes if I load one) - *NOTE* this is the "free for personal use" version of D7 that was given away with a computer mag many years ago.

What to do? Code my own VCL component? Or maybe someone already invented that (FOSS) wheel?

+3  A: 

Create a new project, and write (for example)

procedure TForm1.FormCreate(Sender: TObject);
var
  img: TPicture;
begin
  img := TPicture.Create;
  img.LoadFromFile('C:\Users\Andreas Rejbrand\...\tiles55.jpg');
end;

This will generate the "Unknown picture file extension (.jpg)" error. However, if you add "Jpeg" to the uses clause, then it will work.

Andreas Rejbrand
Mawg
No,not bad Borland (for a change). <g> The IDE was compiled with JPEG support (uses JPEG), so the JPEG stuff works in the IDE. You need to do the same so that JPEGs work in your app by also using JPEG.
Ken White