How I can load a Png image from file which have another extension?
Asked Answered
M

1

5

I'm using a TImage component to load some png images, but some of them have the .imp extension. I add the Vcl.Imaging.pngimage unit to my code and I'm using this code to load the images

 if OpenDialog1.Execute then
  Image1.Picture.LoadFromFile(OpenDialog1.FileName);

But when the LoadFromFile procedure is executed a exception is raised

Unknown picture file extension (.imp)

these images (.imp) are png files generated by an extenal app and are located in a read-only folder, so rename these files is not a option, the question is How I can load a Png image in a TImage component from a file which have another extension?

Maladminister answered 4/4, 2012 at 21:37 Comment(1)
load it to a stream and then load the image from thatGuidry
F
14

you must register the file format first using the TPicture.RegisterFileFormat method

Try this

TPicture.RegisterFileFormat('imp','imp (png) image file',TPngImage);
Fala answered 4/4, 2012 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.