1

How can I load a PNG image from a resource to a TImage at runtime ?

The TImage.Picture has no LoadFromResourceName method. But it can load a PNG at design time !

I tried [TImage].Picture.Bitmap.LoadFromResourceName(HInstance, 'BALANCE_OFF');... but it says "Resurce BALANCE_OFF not found.". But it's there !

.rc file looks like this:

BKG_TEXTURE  BITMAP  "BKG_TEXTURE.BMP"
BKG_FOTO     RCDATA  "BKG_FOTO.PNG"
BALANCE_ON   RCDATA  "BALANCE_ON.PNG"
BALANCE_OFF  RCDATA  "BALANCE_OFF.PNG"
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55
  • 1
    That won't work because it's not a bitmap. Create a TPngImage, the use its LoadFromResourceName method then assign it to the Picture. – hikari Sep 05 '19 at 08:22

0 Answers0