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

人盡茶涼 提交于 2019-12-10 20:20:11

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3536481/timage-does-not-seem-to-support-jpeg-in-d7-free-edition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!