Ir al contenido principal

raygeo.ops.part.image_source

WholeImageSource

In-memory ImageSource wrapping a 2-D uint8 raster buffer.

Constructed from a numpy array and read lazily by assemblers via the Rust-side ImageSource trait. May be attached to a Part via part.image_source = WholeImageSource(array); the part.image property is a convenience shim that constructs a WholeImageSource on assignment.

dimensions

dimensions: tuple[int, int]

Pixel dimensions as (width, height).

height

height: int

Pixel height.

width

width: int

Pixel width.

is_cancelled()

is_cancelled() -> bool

Cancellation probe. WholeImageSource is never cancelled.

ParameterTypeDescription
Returnsbool

read_all()

read_all() -> Optional[list[int]]

Return the full image as flat row-major bytes, or None when the source cannot materialise a full buffer.

WholeImageSource always returns Some.

ParameterTypeDescription
ReturnsOptional[list[int]]

read_slab()

read_slab(y_start: int, y_end: int) -> list[int]

Pull a horizontal slab [y_start, y_end) and return it as a flat bytes object of length rows * width.

ParameterTypeDescription
y_startintFirst row to read (inclusive).
y_endintLast row to read (exclusive); clipped to image height.
Returnslist[int]bytes of length (y_end_clamped - y_start) * width. Returns b"" when y_start >= height or y_end <= y_start.