NONE of these functions work in IDEs other than QB64.
rem image_display cls Dim Image as long x = 1000 'resolution y = 1000 Image = _loadimage("TEST.jpg") 'loading the image screen _newimage(x,y,32) 'putting screen sizes _putimage (0,0),Image 'putting image
So, you were most probably expecting miles of code. And there you have it, all you need to display an image in QB64!
So, what does this astoundingly simple piece of code even do?
A step by step explanation:
- We have DIMed our variable Image as a long value. This is because the image handle returned by the _loadimage function is a long value.
- x and y are our variables. They hold the values we need to put as the resolution. Thus , for a 800 x 900 image, x = 800 , y = 900.
- The image variable Image is next being put the handle values of the image "TEST.jpg". A healthy warning: Keep the image in the folder of the QB64 IDE. Or else , the function wont work!
- Next, we have resized the screen to fit the image. The newimage function requires three parameters, the resolution parameters and the color mode parameters. Here we have used 32 bit color modes, you can also use 256 bit pallete color modes.
- Lastly, we put the image using _putimage, which takes the Image variable(our image handle) as its parameter.
Secondary use of _newimage for setting screen details
Well, you must be thinking , all these commands must be used in this exact same order. Nah, that isnt the case. You can use _newimage solo, to set the screen details, like shown below: