View Single Post
  #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