CompressedImageData Class

Inheritance diagram of CompressedImageData

class CompressedImageData(width, height, gl_format, data, extension=None, decoder=None)

Image representing some compressed data suitable for direct uploading to driver.

Constructor:

__init__(width, height, gl_format, data, extension=None, decoder=None)

Construct a CompressedImageData with the given compressed data.

Parameters:
  • width (int) – Width of image
  • height (int) – Height of image
  • gl_format (int) – GL constant giving format of compressed data; for example, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT.
  • data (sequence) – String or array/list of bytes giving compressed image data.
  • extension (str or None) – If specified, gives the name of a GL extension to check for before creating a texture.
  • decoder (function(data, width, height) -> AbstractImage) – A function to decode the compressed data, to be used if the required extension is not present.

Methods:

blit(x, y[, z]) Draw this image to the active framebuffers.
blit_into(source, x, y, z) Draw source on this image.
blit_to_texture(target, level, x, y, z)
get_image_data() Get an ImageData view of this image.
get_mipmapped_texture()
get_region(x, y, width, height) Retrieve a rectangular region of this image.
get_texture([rectangle, force_rectangle])
save([filename, file, encoder]) Save this image to a file.
set_mipmap_data(level, data) Set data for a mipmap level.

Attributes:

anchor_x Type: int
anchor_y Type: int
image_data An ImageData view of this image.
mipmapped_texture A Texture view of this image.
texture Get a Texture view of this image.

Methods

CompressedImageData.blit_to_texture(target, level, x, y, z)
CompressedImageData.get_mipmapped_texture()
CompressedImageData.get_texture(rectangle=False, force_rectangle=False)
CompressedImageData.set_mipmap_data(level, data)

Set data for a mipmap level.

Supplied data gives a compressed image for the given mipmap level. The image must be of the correct dimensions for the level (i.e., width >> level, height >> level); but this is not checked. If any mipmap levels are specified, they are used; otherwise, mipmaps for mipmapped_texture are generated automatically.

Parameters:
  • level (int) – Level of mipmap image to set.
  • data (sequence) – String or array/list of bytes giving compressed image data. Data must be in same format as specified in constructor.

Inherited members

Methods

CompressedImageData.blit(x, y, z=0)

Draw this image to the active framebuffers.

The image will be drawn with the lower-left corner at (x - anchor_x, y - anchor_y, z).

CompressedImageData.blit_into(source, x, y, z)

Draw source on this image.

source will be copied into this image such that its anchor point is aligned with the x and y parameters. If this image is a 3D texture, the z coordinate gives the image slice to copy into.

Note that if source is larger than this image (or the positioning would cause the copy to go out of bounds) then you must pass a region of source to this method, typically using get_region().

CompressedImageData.get_image_data()

Get an ImageData view of this image.

Changes to the returned instance may or may not be reflected in this image.

Return type:ImageData

Note

Since pyglet 1.1

CompressedImageData.get_region(x, y, width, height)

Retrieve a rectangular region of this image.

Parameters:
  • x (int) – Left edge of region.
  • y (int) – Bottom edge of region.
  • width (int) – Width of region.
  • height (int) – Height of region.
Return type:

AbstractImage

CompressedImageData.save(filename=None, file=None, encoder=None)

Save this image to a file.

Parameters:
  • filename (str) – Used to set the image file format, and to open the output file if file is unspecified.
  • file (file-like object or None) – File to write image data to.
  • encoder (ImageEncoder or None) – If unspecified, all encoders matching the filename extension are tried. If all fail, the exception from the first one attempted is raised.

Attributes

CompressedImageData.anchor_x = 0
CompressedImageData.anchor_y = 0
CompressedImageData.image_data

An ImageData view of this image.

Changes to the returned instance may or may not be reflected in this image. Read-only.

Warning

Deprecated. Use get_image_data.

Type:ImageData
CompressedImageData.mipmapped_texture

A Texture view of this image.

The returned Texture will have mipmaps filled in for all levels. Requires that image dimensions be powers of 2. Read-only.

Warning

Deprecated. Use get_mipmapped_texture.

Type:Texture
CompressedImageData.texture

Get a Texture view of this image.

Changes to the returned instance may or may not be reflected in this image.

Warning

Deprecated. Use get_texture.

Type:Texture

Table Of Contents

Previous topic

ColorBufferImage Class

Next topic

DepthBufferImage Class