DelphiGuy
DelphiGuy

Reputation: 231

Delphi Not Loading Jpg Image - Thinks it's a Bitmap?

I have an issue where I'm trying to load a Jpg image in Delphi.

My calling line of code is:

AImage.Picture.LoadFromFile( AImageFilePathStr );

I've followed it though to the Vcl.Graphics TFileFormatsList.FindExt method.

There I've added a watch (some variables like 'I' were inaccessible due to optimization), but FindExt matches when I=8. 4th item matches and 'I' counts down from 11 to 0.

A watch on TFileFormatType(Items[8]) expands to GraphicClass is TBitmap and Extension is 'jpg'. So the extension matches, but the GraphicClass is TBitmap.

An exception is later thrown "Bitmap image is not valid".

Why does Delphi seem to think this Jpg image is a bitmap?

Thanks.

Upvotes: 0

Views: 2006

Answers (1)

DelphiGuy
DelphiGuy

Reputation: 231

Adding Vcl.Imaging.Jpeg to the uses clause in my main unit was the answer.

I don't understand the why yet, but that fixed it. :-)

Upvotes: 1

Related Questions