LoadPicture error invalid picture

Iban Arriola picture Iban Arriola · Sep 6, 2013 · Viewed 19.7k times · Source

I am trying to take an image from a folder to check its width after that. To do it I am using the following peace of code:

         Dim pic As IPictureDisp
         Dim var As Variant
         var = "C:\Myfolder\Animage" & animationNum + 1 & ".png"
         pic = LoadPicture(var)

It is giving me "invalid picture" error. I tried also just using the following line:

        width = LoadPicture("C:\Myfolder\Animage" & animationNum + 1 & ".png").width

But it also gave me the same error. How can I load the picture?

EDIT

I try with a jpg image and it works... Does this function some issues with png files?

Answer

Aaron Thomas picture Aaron Thomas · Sep 10, 2013

From msdn.microsoft.com:

Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files.

.png is not supported.