ImageDataRegion Class

Inheritance diagram of ImageDataRegion

class ImageDataRegion(x, y, width, height, image_data)

Constructor:

__init__(x, y, width, height, image_data)

Methods:

blit(x, y[, z, width, height])
blit_into(source, x, y, z) Draw source on this image.
blit_to_texture(target, level, x, y, z[, ...]) Draw this image to to the currently bound texture at target.
create_texture(cls[, rectangle, force_rectangle]) Create a texture containing this image.
get_data(format, pitch)
get_image_data()
get_mipmapped_texture() Return a Texture with mipmaps.
get_region(x, y, width, height)
get_texture([rectangle, force_rectangle])
save([filename, file, encoder]) Save this image to a file.
set_data(format, pitch, data) Set the byte data of the image.
set_mipmap_image(level, image) Set a mipmap image for a particular level.

Attributes:

anchor_x Type: int
anchor_y Type: int
data
format Format string of the data.
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

ImageDataRegion.get_data(format, pitch)
ImageDataRegion.get_region(x, y, width, height)

Attributes

ImageDataRegion.data

Inherited members

Methods

ImageDataRegion.blit(x, y, z=0, width=None, height=None)
ImageDataRegion.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().

ImageDataRegion.blit_to_texture(target, level, x, y, z, internalformat=None)

Draw this image to to the currently bound texture at target.

This image’s anchor point will be aligned to the given x and y coordinates. If the currently bound texture is a 3D texture, the z parameter gives the image slice to blit into.

If internalformat is specified, glTexImage is used to initialise the texture; otherwise, glTexSubImage is used to update a region.

ImageDataRegion.create_texture(cls, rectangle=False, force_rectangle=False)

Create a texture containing this image.

If the image’s dimensions are not powers of 2, a TextureRegion of a larger Texture will be returned that matches the dimensions of this image.

Parameters:
  • cls (class (subclass of Texture)) – Class to construct.
  • rectangle (bool) – True if a rectangle can be created; see AbstractImage.get_texture. Since: pyglet 1.1
  • force_rectangle (bool) – True if a rectangle must be created; see AbstractImage.get_texture. Since: pyglet 1.1.4
Return type:

cls or cls.region_class

ImageDataRegion.get_image_data()
ImageDataRegion.get_mipmapped_texture()

Return a Texture with mipmaps.

If set_mipmap_image has been called with at least one image, the set of images defined will be used. Otherwise, mipmaps will be automatically generated.

The texture dimensions must be powers of 2 to use mipmaps.

Return type:Texture

Note

Since pyglet 1.1

ImageDataRegion.get_texture(rectangle=False, force_rectangle=False)
ImageDataRegion.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.
ImageDataRegion.set_data(format, pitch, data)

Set the byte data of the image.

Parameters:
  • format (str) – Format string of the return data.
  • pitch (int) – Number of bytes per row. Negative values indicate a top-to-bottom arrangement.
  • data (str or sequence of bytes) – Image data.

Note

Since pyglet 1.1

ImageDataRegion.set_mipmap_image(level, image)

Set a mipmap image for a particular level.

The mipmap image will be applied to textures obtained via get_mipmapped_texture.

Parameters:
  • level (int) – Mipmap level to set image at, must be >= 1.
  • image (AbstractImage) – Image to set. Must have correct dimensions for that mipmap level (i.e., width >> level, height >> level)

Attributes

ImageDataRegion.anchor_x = 0
ImageDataRegion.anchor_y = 0
ImageDataRegion.format

Format string of the data. Read-write.

Type:str
ImageDataRegion.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
ImageDataRegion.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
ImageDataRegion.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

ImageData Class

Next topic

ImageGrid Class