WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-09-2009, 09:51 AM
Penguin Penguin is offline
Member
 
Join Date: Mar 2009
Posts: 14
wxImage to Texture

Hi,

I'm using wxPython to get a screenshot from a hidden window how it is described here.

Now I want to use the screenshot image as a texture on a Vizard object (e.g. a plane) without writing it to the harddisk and read it again with viz.addTexture() because this would be slow for repetitive image generation with short time intervals.

Is there a way to load the wxImage direct to a texture? Maybe using viz.addTextureFromBuffer() in some kind?
Reply With Quote
  #2  
Old 04-09-2009, 04:53 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, you can copy the image data directly into an existing Vizard texture using the texture.setImageData() command. Here is a sample script:
Code:
import viz
import wx
viz.go()

def WXIMAGE_TO_TEXTURE(image,texture):
	"""Convert wxImage object to Vizard texture"""
	img = image.Mirror(False)
	tex.setImageData(img.GetData(),[img.GetWidth(),img.GetHeight()])

#Create wxImage from a bitmap
app = wx.PySimpleApp()
img = wx.Image('image.bmp')

#Create blank Vizard texture
tex = viz.addBlankTexture([1,1])

#Copy image to texture
WXIMAGE_TO_TEXTURE(img,tex)

#Create quad to display texture
quad = viz.addTexQuad(pos=(0,1.8,2),texture=tex)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Translating a texture and its Alpha shivanangel Vizard 5 12-02-2008 05:52 PM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 01:14 PM
3D Texture Mapping in Vizard? stefs Vizard 2 03-25-2008 04:34 AM
how I can get my texture to appear exactly as is defined mspusch Vizard 1 04-23-2005 01:12 PM
How to simply texture an avatar's head with a jpeg graphic? vr_boyko Vizard 3 10-26-2004 11:44 AM


All times are GMT -7. The time now is 06:09 AM.


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