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

<texture>.saveToBuffer

Save the texture image to a data buffer

<texture>.saveToBuffer(  
filename  
face = viz.POSITIVE_X  
dataType = viz.GL_UNSIGNED_BYTE  
)  
filename
The extension of the filename will determine which image format to encode the data in (bmp, png, jpg, etc..)

Can also use '<raw>' to get the raw image data.
face = viz.POSITIVE_X
This is an optional argument used only with Cube Mapped textures. It specifies which face of the cubemap to save. This 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
dataType = viz.GL_UNSIGNED_BYTE
Specifies the data type to use when reading the image from the GPU. If the texture object already contains image data, then this parameter will be ignored. Can be one of the following values:

viz.GL_BYTE
viz.GL_UNSIGNED_BYTE
viz.GL_SHORT
viz.GL_UNSIGNED_SHORT
viz.GL_INT
viz.GL_UNSIGNED_INT
viz.GL_FLOAT
viz.GL_DOUBLE

Remarks

This command will save the image associated with the texture to a buffer in memory. The extension of the specified filename is used to determine which format to save the image to.

If the texture does not contain image data (e.g. render textures, textures with freed memory, etc..), then the image data will be read from the texture object on the GPU.

Return Value

Buffer data as a Python bytes object, or None if texture does not contain image data.

Example

# Load a PNG image
tex = viz.addTexture('image.png')

# Save to a JPEG buffer
buf = tex.saveToBuffer('.jpg')

See also

<texture>.save