2007. október 30., kedd

TPicture and non-standard image file name extensions


Problem/Question/Abstract:

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.

Nincsenek megjegyzések:

Megjegyzés küldése