Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TImage does not seem to support Jpeg in D7 (free edition)?

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?

like image 519
Mawg says reinstate Monica Avatar asked Oct 27 '25 16:10

Mawg says reinstate Monica


1 Answers

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.

like image 122
Andreas Rejbrand Avatar answered Oct 30 '25 07:10

Andreas Rejbrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!