Mega Code Archive

 
Categories / Delphi / Examples
 

Tpicture and non-standard image file name extensions

Question: Can we use TPicture.LoadFromFile() for loading images while their file extension isn't recognized by TPicture? For example if BMP files have been renamed to *.img. Answer: If you know the format and it is indeed a bitmap then you can force it to work - see the first piece of code below. You can even register your own extension with the second piece of code. begin // force it to be treated as a bitmap: Image1.Picture.Bitmap.LoadFromFile('APicture.img'); // register your IMG extension application-wide to be treated as a bitmap: Image1.Picture.RegisterFileFormat('img','Bitmap file',TBitmap); Image1.Picture.LoadFromFile('APicture.img'); end.