WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   vizard texture PIL image (https://forum.worldviz.com/showthread.php?t=4887)

subbu 11-24-2013 08:05 AM

vizard texture PIL image
 
Please someone let me know how to convert viz texture to PIL image.

Kevin Chiu 11-26-2013 02:56 PM

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')



All times are GMT -7. The time now is 04:37 AM.

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