DelphiFAQ Home Search:

TPicture and non-standard image file name extensions

 

comments1 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

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.
You don't like the formatting? Check out SourceCoder then!

Comments:

2006-05-25, 19:03:18
anonymous from United States  
rating
Crushdaddy

Keywords:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.