WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-24-2014, 11:16 AM
BSUGeek BSUGeek is offline
Member
 
Join Date: Oct 2014
Posts: 23
Question 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?
Reply With Quote
  #2  
Old 11-25-2014, 10:01 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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:
Code:
import viz
import viztask
import base64

viz.go()

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])
		viz.window.screenCapture(texture)

		# 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('<raw>'))

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

		# Remove texture
		texture.remove()

viztask.schedule( SaveScreenTask() )
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
screen capture of sub window rlh001 Vizard 1 07-22-2013 04:59 PM
Screen Size and Scaling javadi Vizard 2 04-02-2013 06:56 PM
Attach a TexQuad to pit.osgb screen Ducky Vizard 1 01-17-2013 03:57 PM
screen capture from all cluster computers? dtidrow Vizard 1 09-16-2009 11:25 AM
position of html-file on screen active_world Vizard 1 05-16-2008 08:24 PM


All times are GMT -7. The time now is 12:46 PM.


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