Vizard 7 » Command Index » Vizard objects » texture » <texture>.getImageData
7.6

<texture>.getImageData

Returns image data

<texture>.getImageData(  
face = viz.POSITIVE_X  
)  
face = viz.POSITIVE_X
Only used for cube map textures. Specifies which image of the cube map to retrieve the data from. Can be one of the following values:

viz.POSITIVE_X
viz.NEGATIVE_X
viz.POSITIVE_Y
viz.NEGATIVE_Y
viz.POSITIVE_Z
viz.NEGATIVE_Z

Remarks

This command will return a reference to the image data. The data is writable, so changing the value will affect the actual image. After modifying the image data, you must issue the viz.TEXTURE_MODIFIED_HINT hint flag to notify Vizard that the data needs to be uploaded to the graphics card.

Some textures (i.e. render textures, textures with freed memory) do not have image data associated with them. In this case None will be returned.

The returned memoryview object will contain the raw bytes of the image data. Each element is accessible by an integer in the range [0,255].

Return Value

Image data as a Python memoryview object, or None if texture does not contain image data.

Example

#Get reference to image data
data = tex.getImageData()

#Set first pixel to green
data[0] = 0
data[1] = 255
data[2] = 0

#Notify Vizard that texture data has been modified
tex.hint(viz.TEXTURE_MODIFIED_HINT)

See also

<texture>.getPixelSize
<texture>.getSize
<texture>.getType
<texture>.setImageData