Class pyglet.image.AbstractImage

Known Subclasses:
Texture, BufferImage, CompressedImageData, ImageData, ImageGrid
Abstract class representing an image.

Methods

  __init__(self, width, height)
  __repr__(self)
AbstractImage get_region(self, x, y, width, height)
Retrieve a rectangular region of this image.
  save(self, filename=None, file=None, encoder=None)
Save this image to a file.
  blit(self, x, y, z=0)
Draw this image to the active framebuffers.
  blit_into(self, source, x, y, z)
Draw source on this image.
  blit_to_texture(self, target, level, x, y, z=0)
Draw this image on the currently bound texture at target.

Properties

ImageData image_data
An ImageData view of this image.
Texture texture
A Texture view of this image.
Texture mipmapped_texture
A Texture view of this image.

Instance Variables

int height
Height of image
int width
Width of image

Method Details

get_region

get_region(self, 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.
Returns: AbstractImage

save

save(self, 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.

blit_into

blit_into(self, source, x, y, z)

Draw source on this image.

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().


Property Details

image_data

An ImageData view of this image.

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

Type:
ImageData

texture

A Texture view of this image.

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

Type:
Texture

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.

Type:
Texture