LoadImage Not working (BMax 1.37)

Archives Forums/BlitzMax Bug Reports/LoadImage Not working (BMax 1.37)

Spencer(Posted 2010) [#1]
I am sure this is a simple thing to fix, but 'LoadImage' is not working on my machine. I keep getting an unhandled Exception Error: "UnHandled Exception:Attempt to access field or method of Null object" I am using BlitzMax v1.37 with WindowsXP SP3, Nvidia 6150 LE Integrated Graphics, DirectX 9.0c. The simple code below throws the error. (I get a similar error when trying to display the same image in BlitzPlus v1.47) Has anyone experienced an issue like this before?

BlitzMax Code...
Graphics 800, 600
Global image:TImage = LoadImage("c:\test.bmp")
While Not KeyHit(KEY_ESCAPE)
    Cls
    DrawImage image, 10 , 10
    Flip
EndWhile



Spencer(Posted 2010) [#2]
Doh! never mind, lt appears as though .bmp is not supported,. When I change the extension to jpg it works fine.


therevills(Posted 2010) [#3]
Works fine here.

Are you sure that test.bmp exists at c:\?

Try the following:
SuperStrict
Graphics 800, 600

Global image:TImage = LoadImage("c:\test.bmp")
If image = Null Then RuntimeError("IMAGE NOT FOUND!") 

While Not KeyHit(KEY_ESCAPE)
    Cls
    DrawImage image, 10 , 10
    Flip
EndWhile


See if you get "Unhandled Exception:IMAGE NOT FOUND!"


therevills(Posted 2010) [#4]
How did you create your bmp?

Ive created one via Paint and one via Paint.net and they both work fine...


xlsior(Posted 2010) [#5]
Ive created one via Paint and one via Paint.net and they both work fine...


8 bit or 24 bit? :-?


therevills(Posted 2010) [#6]
Just tried both (via Paint.net) and both work fine.


Spencer(Posted 2010) [#7]
Thanks for the replies!

I am not sure what the problem was, everything is working now. I did not alter the code or the image. I restarted my PC. I was then prompted to install an XP update which disabled an AutoRun Feature. Text from Microsoft website:
"Update for Windows XP (KB967715)
Install this update to resolve an issue with AutoRun features were not correctly disabled. After you install this item, you may have to restart your computer. "

After this everything seemed to be normal. Do you suppose these are directly connected?


Spencer(Posted 2010) [#8]
PS: I created the Image with MS Paint and saved it as a 24-bit BMP. I checked the code, and the file location several times. I am sure it was something weird with my PC because the same attempt in BlitzPlus failed as well. I was just wondering what might have caused it... Thanks again for the help.


GfK(Posted 2010) [#9]
Wouldn't think so.