ImageCanvas
- class plutoprint.ImageCanvas(width: int, height: int, format: ImageFormat = IMAGE_FORMAT_ARGB32)[source]
Bases:
CanvasThe ImageCanvas class provides an interface for rendering to memory buffers.
- __init__(width: int, height: int, format: ImageFormat = IMAGE_FORMAT_ARGB32) None[source]
Initializes a new ImageCanvas with the specified width, height, and format.
- Parameters:
width – The width of the canvas in pixels.
height – The height of the canvas in pixels.
format – The pixel format of the canvas.
- classmethod create_for_data(data: memoryview, width: int, height: int, stride: int, format: ImageFormat = IMAGE_FORMAT_ARGB32) ImageCanvas[source]
Creates a new ImageCanvas for the given writable data buffer.
- Parameters:
data – A writable memoryview representing the image data buffer.
width – The width of the canvas in pixels.
height – The height of the canvas in pixels.
stride – The stride (number of bytes per row) of the image data.
format – The pixel format of the canvas.
- Returns:
A new instance of ImageCanvas.
- get_data() memoryview[source]
Returns a writable memoryview of the image data buffer.
- Returns:
A writable memoryview of the image data.
- get_width() int[source]
Returns the width of the canvas.
- Returns:
The width of the canvas in pixels.
- get_height() int[source]
Returns the height of the canvas.
- Returns:
The height of the canvas in pixels.
- get_stride() int[source]
Returns the stride (number of bytes per row) of the image data.
- Returns:
The stride of the image data.
- get_format() ImageFormat[source]
Returns the pixel format of the canvas.
- Returns:
The pixel format of the canvas.