Canvas Capture

BlitzMax Forums/BlitzMax Beginners Area/Canvas Capture

Hardcoal(Posted 2013) [#1]
Im trying to make a Video from Blitzmax Output Canvas.

Im using Xors3D.

Is it possible to capture the frames at a desired rate say 60fps somehow while Playing?

I dont care if it all become slow..
The purpose is to make a video file.

Cheers


ImaginaryHuman(Posted 2013) [#2]
GrabPixmap
SavePixmapPNG


Hardcoal(Posted 2013) [#3]
Wow that simple, hmm too simple haha :) need check.


Hardcoal(Posted 2013) [#4]
the question now is how do you turn this into a video from blitzmax code


Kryzon(Posted 2013) [#5]
I Googled "PNG to video" and got this: http://stackoverflow.com/questions/618448/tool-to-glue-dozen-of-png-into-video

Then you'd use the Blitzmax\mod\pub.mod\freeprocess.mod\ module to call any of the command lines suggested in that thread (after properly installing the software the command line is calling, ofc).


Hardcoal(Posted 2013) [#6]
Ok . This is new grounds for me.
Thanks kryzon


Kryzon(Posted 2013) [#7]
You can find some threads on CreateProcess() around here with info on how to use it.
It allows you to run executable files with a command line (needed for using ffmpeg or other encoder like described in that thread); It's a very handy tool.


Hardcoal(Posted 2013) [#8]
Just one more question kryzon.

when I capture the screen as png
I also Get the black background.

is there a way to get the png as transparent?


ImaginaryHuman(Posted 2013) [#9]
If you create a backbuffer that includes an alpha buffer, ie when you set up your Graphics screen you ask for an alpha channel, and your graphics card supports 32-bit graphics with an alpha buffer, then you could put it into OpenGL mode and use glReadPixels() to grab all four channels from the backbuffer. However, blitz is already using that command when you do a GrabPixmap.

The thing here is, when you use alpha transparency on your sprites or whatever, the alpha data is in the source sprite data. The graphics card reads the sprite data and pulls out the alpha channel, then uses the value in the alpha channel to cross fade between the sprite colors and the background colors. But it does not DRAW the alpha channel into the backbuffer's alpha channel. So when you go to grab the full screen, even if it's 32-bit, it won't find any alpha pixel values. In order to get the alpha channel values from the sprite to be written to the backbuffer's alpha channel you will have to use OpenGL and manually set the blend modes such that the source alpha is written to the destination, and if you have overlapping images then you'll want to probably use a multiply blend mode that combines the sprite alpha with the destination alpha, such as DEST_ALPHA. It can be done, but it's not what Blitz is normally set up to do.

Another option is to manually draw sprites into a pixmap using your own alphablending algorithm and then make sure to also draw/combine the alpha values from the sprites into the pixmap's alpha channel.


Hardcoal(Posted 2013) [#10]
Thanks for the elaborate Answer @ImaginaryHuman


Kryzon(Posted 2013) [#11]
Why do you want the PNGs with alpha?
Do you want to create a video with transparency?


Hardcoal(Posted 2013) [#12]
hmm good question well. i wanted to create an animated png