<multimedia:image>.saveToBuffer

Save the texture image to a data buffer

 

<multimedia:image>.saveToBuffer(
    filename    
    face = viz.POSITIVE_X    

)

 

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


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 string 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

<multimedia:image>.save