DrawImage Help

Blitz3D Forums/Blitz3D Beginners Area/DrawImage Help

Kirkkaf13(Posted 2010) [#1]
Hi,

I am trying to do something very simple and draw an image to the screen.

IMG_ball = LoadImage ("ball.bmp")

Global ballx% = 50
Global bally% = 100

Graphics 640, 480, 16, 2

DrawImage IMG_ball, ballx%, bally%
WaitKey ()
End


When do i get the message "image doesn't exist" even though they are in the same directory or am I missing something?

OneHitWonder


Matty(Posted 2010) [#2]
Call Graphics before loading any images, I am pretty sure when you call "graphics" it clears all the images out first.


Midimaster(Posted 2010) [#3]
also a FLIP command before WAIKEY() would help!


Kirkkaf13(Posted 2010) [#4]
I was just drawing direct to front buffer so the flip command would be useless I think. Matty was right its due to calling graphics after loading the image.

OneHitWonder


Cold Storage(Posted 2010) [#5]
Matty: "I am pretty sure when you call "graphics" it clears all the images out first."

It does indeed... and it still catches me out from time to time if I'm not 100% focused when I'm coding. I've learned to put the "Graphics" command as close to the top of the code as possible! ;O)

There are a few things like this that aren't obvious, and catch people out and have them scratching their heads! Another one that got me was that you can't have DIM statements within a Function.


Matty(Posted 2010) [#6]
@Cold Storage - Actually you can have DIM statements within a function as long as it is also Dimmed (as an initialisation) outside of the function. eg:

; outside function, perhaps near top of code
DIM MyArray(0,0,0) ;3 dimensional array for example

Function InitArray(maxX,maxY,maxZ)
;inside function, redim the array..clears all contents and re dimensions the array

DIM MyArray(maxX,maxY,maxZ)



End Function