WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Convert Screen Capture to base64 (

BSUGeek 11-24-2014 10:16 AM

Convert Screen Capture to base64
I was wondering how do you convert a screen capture of the running scene to base64 and put the base64 data into a file?

farshizzo 11-25-2014 09:01 AM

Here is a sample script that will save the raw image data of the screen to a base64 encoded file when the spacebar is pressed:

import viz
import viztask
import base64


model = viz.addChild('maze.osgb')

def SaveScreenTask():

        while True:

                # Wait for key press
                yield viztask.waitKeyDown(' ')

                # Capture screen to texture
                texture = viz.addBlankTexture([1,1])

                # Wait a frame for image to be captured
                yield viztask.waitFrame(1)

                # Save raw texture data to base64 encoded buffer
                data = base64.b64encode(texture.saveToBuffer(''))

                # Save data to file
                with open('screen_data', 'wb') as f:

                # Remove texture

viztask.schedule( SaveScreenTask() )

All times are GMT -7. The time now is 02:29 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC