CreateImage and LoadBuffer

BlitzPlus Forums/BlitzPlus Beginners Area/CreateImage and LoadBuffer

DaveTheRave(Posted 2008) [#1]
I have been looking for an example that uses the LoadBuffer command and the CreateImage command. My understanding is that you can use CreateImage to create an off-screen area for modifying images, and that you can use LoadBuffer to fill this off-screen area. My idea is to use CreateImage to create a drawing buffer, load an image into this buffer using LoadBuffer and then do some other drawing onto this before showing on the front buffer. All my attempts to use LoadBuffer result in Blitzplus crashing (on my Vista laptop)! If you comment out the LoadImage line and enable the LoadBuffer line it will crash!

My attempted source code is
Graphics 800, 600
imgTile = CreateImage(60,60)

SetBuffer  ImageBuffer(imgTile)
imgTile = LoadImage("Tile_RGPB.bmp")
;LoadBuffer(imgTile, "Tile_RGPB.bmp")

SetBuffer FrontBuffer()
Cls

DrawImage(imgTile, 300,300)

Flip

WaitKey


Can above code be made to work with LoadBuffer instead of the LoadImage?

Thanks.


Abrexxes(Posted 2008) [#2]
Hi, it is possible that this command is broken in the new driver and hardware generations. But why you use this? There are few better ways.

By the way, if you use "Frontbuffer", dont use "Flip". See manual.

bye


Moore(Posted 2008) [#3]
Ok the problem was that your were passing loadbuffer the image handle and not the buffer. Also, you didn't need to set the buffer to the image buffer.

Graphics 800, 600 
imgTile = CreateImage(60,60) 
LoadBuffer(ImageBuffer(imgTile), "faces.jpg") ; <<< note ImageBuffer

SetBuffer BackBuffer() ; <<< back buffer not front buffer
Cls 
DrawImage(imgTile, 300,300) 
Flip 
WaitKey 



DaveTheRave(Posted 2008) [#4]
Hi - thanks for the responses!

More daft newbie questions! (Or not knowing the bleeding obvious known by experienced programmers)
1> When you use CreateImage, are you effectively creating a buffer on which to draw, or in my case, loading an image?
And if you want to use this again later, do you issue a SetBuffer ImageBuffer() command, draw on this, and when you want to view it, issue a SetBuffer Backbuffer(), a DrawImage and then a Flip command?

2> Can CreateImage be a size greater than the screen resolution set in say the Graphics statement, albeit if the larger image is shown it would only show what it could fit in the screen resolution with the rest being 'off-screen'?

Thanks again - DaveTheRave.

PS Despite the above newbie questions I have managed to produce a very simple Duck_Shoot program.