Imagepointer help

BlitzMax Forums/BlitzMax Beginners Area/Imagepointer help

Blacky(Posted 2014) [#1]
Hi Guys,

i am new to blitzmax and own Blitz3d. Its hard to start but it seems that i cant store the pointer to an Image like in Blitz3D. Anyone can help me to code this ?

Here is the short example

Global grid[5]

Graphics 640, 480,0
setmaskcolor 0, 0, 0
my_Image:Timage = LoadImage("gfx\Reaktor.bmp")


grid[0]] = pointer to my_Image ?

While Not KeyDown(Key_Escape)
Drawimage grid[0], 10, 10
flip; cls
Wend


Brucey(Posted 2014) [#2]
Something like this should work (untested) :
SuperStrict

Global grid:TImage[5]

Graphics 640, 480,0
setmaskcolor 0, 0, 0
Local my_Image:Timage = LoadImage("gfx\Reaktor.bmp")


grid[0] = my_Image

While Not KeyDown(Key_Escape)
Drawimage grid[0], 10, 10
flip; cls
Wend



Blacky(Posted 2014) [#3]
it doesnt work get a Null Pointer


Derron(Posted 2014) [#4]
If "grid[0]" is null, then "my_Image" is also null ... which means "LoadImage" failed - eg. the path isn't correct.


When using "more complex" types (not integers, strings, ...) you already are using some kind of "pointers" (better "handles").
So when assigning

grid[0] = my_Image

you do not "copy" the image, but the handler.


bye
Ron


Brucey(Posted 2014) [#5]
it doesnt work get a Null Pointer

As Derron says, your image probably hasn't loaded.


Blacky(Posted 2014) [#6]
my Image is loaded, because if i do this i get shown my image


Global grid[5]

Graphics 640, 480,0
setmaskcolor 0, 0, 0
my_Image:Timage = LoadImage("gfx\Reaktor.bmp")



While Not KeyDown(Key_Escape)
Drawimage my_image, 10, 10
flip; cls
Wend


GfK(Posted 2014) [#7]
Can you provide the exact code you're using to get the error? Because Brucey's example works perfectly, for me.


Blacky(Posted 2014) [#8]
sorry my mistake, all fine with the code