How to display all picture formats in TImage using Delphi
Add JPEG
to the uses clause in the interface section.
This automatically registers .jpg
as valid image file extension and couples it to the TJPEGImage
class which TPicture
will instantiate.
Japster
Im still new to programming, at universtity at the moment studying towards a degree in CS
Updated on June 11, 2022Comments
-
Japster almost 2 years
I have written an application that stores photos, keeping the path to the photos in an database. I have encountered a problem. When I click my button to select the picture I want to display in an TImage object for the user to view before saving, I receive the following exception notification: raised exception class: EInvalidGraphic with message "Unknown picture extension (.jpg)'
I'm using an TopenPicture component to go and fetch the image. the openPicture.filter property is set to accept most of the image formats, (jpg, jpeg, png, gif, bmp), but I cannot load any of these formats into the TImage component.
Here is the code I'm using to load the image:
openPicture.Execute(); filename := openPicture.FileName; if not(fileName = '') then begin imgFoto.Picture.LoadFromFile(filename); imgFoto.Visible := true; end;
-
David Heffernan about 12 yearsLikewise add pngimage and gifimage or whatever they are called
-
Slappy almost 9 yearsFor .png I have this problem: [Fatal Error] UWizard.pas(15): File not found: 'PngImage.dcu'
-
NGLN almost 9 years@Slap Like David says: "or whatever they are called"; your Delphi version uses another filename!
-
Slappy almost 9 yearsNo, I have to download .png sources (.pas files) and add them to my project and build it (Delphi 7)
-
NGLN almost 9 years@Slap Delphi 7 has no build-in PNG support; you must add it yourself. That's why David mentions that the sourcename could differ. Search for or buy a PNG component suite.