Recent

Author Topic: Can't display a PNG image  (Read 7799 times)

Neuromancer

  • New Member
  • *
  • Posts: 44
    • My personal website
Can't display a PNG image
« on: June 04, 2010, 11:59:08 am »
Hi,

I'm trying to display PNG images using a TImage component (tiles for a pseudo-3D isometric map). Only one image (ocean.png) is displayed. I don't understand why.

Code: [Select]
Ocean := TPNGImage.Create;
Ocean.LoadFromFile(CurrentDir + '/images/ocean.png');
Grass := TPNGImage.Create;
Grass.LoadFromFile(CurrentDir + '/images/grass.png');
Mountains := TPNGImage.Create;
Mountains.LoadFromFile(CurrentDir + '/images/mountains.png');
Desert := TPNGImage.Create;
Desert.LoadFromFile(CurrentDir + '/images/desert.png');
 
imgMap.Canvas.Draw(i, j, Ocean);
imgMap.Canvas.Draw(i, j, Grass); // Ne s'affiche pas
imgMap.Canvas.Draw(i, j, Mountains); // Ne s'affiche pas

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: Can't display a PNG image
« Reply #1 on: June 04, 2010, 01:12:42 pm »
The images have different formats.
ocean is 32bit Alpha RGB
mountains etc are 8bit Palette.

Either convert them all to 32bit Alpha RGB or upgrade
to an fpc version later than 2.4.0 (and probably upgraded Lazarus too) or use OpBitmap to load them.


 

TinyPortal © 2005-2018