Taking a screenshot - equivalent for SaveBuffer?

BlitzMax Forums/BlitzMax Beginners Area/Taking a screenshot - equivalent for SaveBuffer?

Koekelas(Posted 2005) [#1]
I'm just wondering, I want to have the ability to take screenshots.

In Blitz2D you could say:
SaveBuffer(FrontBuffer(), "screenshot.bmp")


But in BlitzMax???


Thanks, Nicolas.


Koekelas(Posted 2005) [#2]
Is there no one who has an idea? Maybe I make it more interesting if I also want to load the saved buffer :-). If I don't find a solution I'm forced to work for school and I can assure you, programming in BlitzMax is much more fun than working for school.


Thanks, Nicolas.


RexRhino(Posted 2005) [#3]
I managed to get a perfect screen shot by pressing "Print Screen".


Koekelas(Posted 2005) [#4]
Yeah, and when you are on a Macintosh chose Services / Screen / Grab screen... but that's not what I want.

What I want is an equivalent for SaveBuffer() and LoadBuffer().

It's a good attempt RexRhino but it's not it.


Thanks, Nicolas.


tonyg(Posted 2005) [#5]
I haven't found a way to do it.
In addition, with no imagebuffers its not possible to say..
savebuffer(imagebuffer(image),"file.bmp")
and save composite images without additional space.


AntonyWells(Posted 2005) [#6]
Use glReadPixels to read the backbuffer.


Koekelas(Posted 2005) [#7]
Antony, could you hive me an easy example how to do this? I don't have any knowledge of OpenGL.

Thanks in advance, Nicolas.


AntonyWells(Posted 2005) [#8]
Try something like this,

ScreenShot:Tbank = CreateBank( GraphicsWidth()*GraphicsHeight()*3 )

glReadPixels 0,0,GraphicsWidth(),GraphicsHeight(),GL_RGB,GL_UNSIGNED_BYTE,bankBuf( Screenshot )

Now in the bank you have the screen,

byte 0 = red(0-255)
byte 1 = green
byte 2 = blue
etc.


Koekelas(Posted 2005) [#9]
Sorry for your effort but this really looks quite Chinese to me :-). I could just copy/paste your code into my program, but then I don't even know what it does (I suppose it makes a screenshot since that's what I asked for).


Thanks, Nicolas.


dynaman(Posted 2005) [#10]
There is no direct way of doing this. I'm hoping that a saveimage or savepixmap command will be in one of the updates.


Beaker(Posted 2005) [#11]
This might help as well:
http://www.blitzbasic.com/Community/posts.php?topic=41965


ImaginaryHuman(Posted 2005) [#12]
In order to save an image from BlitzMax you would need some commands that allow images or pixmaps to be saved. Currently in the default BlitzMax configuration there is no image saving ability, only loading.

However, I am sure if you check in other areas of the forums - perhaps in the module updates section - there was a thread about someone who has release a module which allows you to save an image in various format. This is probably what you need.

Hopefully they will add image saving to a future update to the official BlitzMax.


DannyD(Posted 2006) [#13]

http://www.blitzbasic.com/codearcs/codearcs.php?code=1571


Perturbatio(Posted 2006) [#14]
I'd have hoped that after a year, he'd have figured it out :)


djdee(Posted 2006) [#15]
' grabimage.bmx

' draws a small graphic then uses grabimage to make an image

' as mask color and cls color both default to black a mask is
' created for the grabbed where any pixels unset on the backbuffer
' become transparent in the grabbed image

Graphics 640,480,32

Cls

DrawLine 0,0,32,32
DrawLine 32,0,0,32
DrawOval 0,0,32,32

Local image=CreateImage(32,32,1,DYNAMICIMAGE|MASKEDIMAGE)

GrabImage image,0,0

Cls
For Local i=1 To 100
DrawImage image,Rnd(640),Rnd(480)
Next
Flip

WaitKey


djdee(Posted 2006) [#16]
I used to use grabimage and then saveimage... but it seems saveimage is not included in max2d module... but there must be some way to save that image...


taxlerendiosk(Posted 2006) [#17]
Try GrabPixmap, and then SavePixmapPNG.