Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.trade.ImageData2D class

Two-dimensional image data

Implicitly convertible to ImageView2D / MutableImageView2D, so all APIs consuming image views work with this type as well.

Memory ownership and reference counting

The class can be both owning an non-owning depending on the value of data_flags. If they contain neither DataFlags.OWNED nor DataFlags.GLOBAL, the owner property references the object actually owning the pixel data the image points to. This ensures calling del on the original object will not invalidate the data.

Pixel data access

The class makes use of Python’s dynamic nature and provides direct access to pixel data in their concrete types via pixels. See ImageView2D documentation for more information and usage example.

Compared to Image2D and ImageView2D / MutableImageView2D, the data and pixels views are immutable and mutable access is provided depending on the value of data_flags via mutable_data and mutable_pixels.

Properties

compressed_format: CompressedPixelFormat get
Format of compressed pixel data
data: corrade.containers.ArrayView get
Raw image data
data_flags: DataFlags get
Data flags
format: PixelFormat get
Format of pixel data
is_compressed: bool get
Whether the image is compressed
mutable_data: corrade.containers.MutableArrayView get
Mutable raw image data
mutable_pixels: corrade.containers.MutableStridedArrayView2D get
Mutable pixel data
owner: object get
Memory owner
pixel_size: int get
Pixel size (in bytes)
pixels: corrade.containers.StridedArrayView2D get
Pixel data
size: Vector2i get
Image size
storage: PixelStorage get
Storage of pixel data

Property documentation

magnum.trade.ImageData2D.compressed_format: CompressedPixelFormat get

Format of compressed pixel data

Exceptions
AttributeError If is_compressed is False

magnum.trade.ImageData2D.format: PixelFormat get

Format of pixel data

Exceptions
AttributeError If is_compressed is True

magnum.trade.ImageData2D.mutable_data: corrade.containers.MutableArrayView get

Mutable raw image data

Exceptions
AttributeError If data_flags doesn’t contain DataFlags.MUTABLE

magnum.trade.ImageData2D.mutable_pixels: corrade.containers.MutableStridedArrayView2D get

Mutable pixel data

Exceptions
AttributeError If is_compressed is True
AttributeError If data_flags doesn’t contain DataFlags.MUTABLE

magnum.trade.ImageData2D.pixel_size: int get

Pixel size (in bytes)

Exceptions
AttributeError If is_compressed is True

magnum.trade.ImageData2D.pixels: corrade.containers.StridedArrayView2D get

Pixel data

Exceptions
AttributeError If is_compressed is True

magnum.trade.ImageData2D.storage: PixelStorage get

Storage of pixel data

Exceptions
AttributeError If is_compressed is True