WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-24-2013, 08:05 AM
subbu subbu is offline
Member
 
Join Date: Aug 2013
Posts: 4
vizard texture PIL image

Please someone let me know how to convert viz texture to PIL image.
Reply With Quote
  #2  
Old 11-26-2013, 02:56 PM
Kevin Chiu Kevin Chiu is offline
WorldViz Team Member
 
Join Date: Feb 2012
Posts: 26
Hi Sabu,

This may show a way for achieving the conversion.


Code:
import viz
import Image

#Create a Vizard texture
tex = viz.addTexture('brick.jpg')

#Get the image data from the VizTexture object
texData = tex.getImageData()

#Get the pixel format from the raw image data which interpreted by the graphics card
if tex.getPixelFormat() == 0:
	PILimageMode = 'RGB'
elif tex.getPixelFormat() == 1:
	PILimageMode = 'RGBA'

#Convert raw image data to PIL image
newImage = Image.fromstring(PILimageMode,(tex.getSize()[0],tex.getSize()[1]),texData)

#Save PIL image to a jpg file
newImage.save('brick2.jpg')
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
granny render to texture image Darkmax Vizard 2 05-16-2011 03:31 PM
Vizard 4 Beta Testing farshizzo Announcements 0 02-01-2011 10:46 AM
Vizard 4 Beta Testing farshizzo Vizard 0 02-01-2011 10:46 AM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 11:13 AM
3D Texture Mapping in Vizard? stefs Vizard 2 03-25-2008 03:34 AM


All times are GMT -7. The time now is 05:56 AM.


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