Need help with images!
BlitzMax Forums/BlitzMax Programming/Need help with images!
| ||
Every time I load an image and draw it, I get a runtime error saying,"Unhandled exception:attempt to access field of null object" what does it mean, and how do I fix it? Also, I need help finding an image editor that can draw images or animated images. twinprogrammer |
| ||
Sounds like there is a problem loading the images -- did you verify that the loading was successful before attempting to draw? Also, keep in mind that you need to create a graphics context *before* attempting to load the images. |
| ||
Are you reading the debugger's output? on the right side of the IDE it shows all the related objects, fields and variables. It's a great guide to find out what went wrong. Also, I need help finding an image editor that can draw images or animated images. Hope this is of use: http://www.gamedev.net/community/forums/topic.asp?topic_id=202348 |
| ||
'use as a replacement for LoadImage (use default parameters) or as a replacement for LoadAnimImage (provide parameters) Function SafeImageLoad:TImage(path:String, animation = False, width = 0, height = 0, first = 0, count = 0, flags = -1) Local image:TImage If animation 'we are loading an animation strip image = LoadAnimImage(path, width, height, first, count, flags) Else 'we are loading a still image image = LoadImage(path, flags) End If 'check that the image was loaded correctly If Not image RuntimeError "Cannot find " + path End If 'return the image we loaded Return image End Function Local i1:TImage = SafeImageLoad("myfile.png") Local i2:TImage = SafeImageLoad("myanim.png", True, 32, 32, 0, 4) Last edited 2010 |
| ||
I can load some images , just not all images. I loaded a simple ball and drew it , but when I tried to load a ship , I got the same error!!! Is it something to do with my images? Or am I just drawing them incorrectly? twinprogrammer |
| ||
Are you positive the file names are correct? Including the extensions? and the path to the file (if needed) is correct? Sry if this sounds like an obvious thing - but I've had the same problems and it's always been because I didn't give the full path when I should have, or I saved my file as a BMP and not a PNG and still tried to load it as "Pic.png" |