S or /

SourceClass ColorImage

from egui import ColorImage
class ColorImage:

A 2D RGBA color image in RAM.

Properties§

Source@property def height(self, /) -> int§
@property def pixels(self, /) -> list[Color32]§
@pixels.setter def pixels(self, /, pixels: Sequence[Color32]) -> None§
@property def size(self, /) -> tuple[int, int]§
@property def source_size(self, /) -> Vec2§
@source_size.setter def source_size(self, /, source_size: Vec2) -> None§
Source@property def width(self, /) -> int§

Methods§

Sourcedef as_raw(self, /) -> bytes§

A view of the underlying data as &[int](https://github.com/emilk/egui/blob/e44f9f60d93bba451c513b3c193f24bd0260f969/crates/epaint/src/image.rs#L177)

Sourcedef as_raw_mut(self, /, raw: Sequence[int]) -> None§

A view of the underlying data as [int](https://github.com/emilk/egui/blob/e44f9f60d93bba451c513b3c193f24bd0260f969/crates/epaint/src/image.rs#L183)

Source@staticmethod def example() -> ColorImage§

An example color image, useful for tests.

Source@staticmethod def filled(width: int, height: int, color: Color32) -> ColorImage§

Create an image filled with the given color.

Source@staticmethod def from_gray(width: int, height: int, gray: Sequence[int]) -> ColorImage§

Create a ColorImage from flat opaque gray data.

Panics if size[0] * size[1] != gray.len().

Source@staticmethod def from_gray_iter(width: int, height: int, gray: Sequence[int]) -> ColorImage§

Alternative method to from_gray. Create a ColorImage from iterator over flat opaque gray data.

Panics if size[0] * size[1] != gray_iter.len().

Source@staticmethod def from_rgb(width: int, height: int, rgb: Sequence[int]) -> ColorImage§

Create a ColorImage from flat RGB data.

This is what you want to use after having loaded an image file (and if you are ignoring the alpha channel - considering it to always be 0xff)

Panics if size[0] * size[1] * 3 != rgb.len().

Source@staticmethod def from_rgba_premultiplied(width: int, height: int, rgba: Sequence[int]) -> ColorImage§
Source@staticmethod def from_rgba_unmultiplied(width: int, height: int, rgba: Sequence[int]) -> ColorImage§

Create a ColorImage from flat un-multiplied RGBA data.

This is usually what you want to use after having loaded an image file.

Panics if size[0] * size[1] * 4 != rgba.len().

Example using the image crate:

def pixel_count(self, /) -> int§
Sourcedef region(self, /, region: Rect, pixels_per_point: float |None) -> ColorImage§

Create a new image from a patch of the current image.

This method is especially convenient for screenshotting a part of the app since region can be interpreted as screen coordinates of the entire screenshot if pixels_per_point is provided for the native application. The floats of emath.Rect are cast to usize, rounding them down in order to interpret them as indices to the image data.

Panics if region.min.x > region.max.x || region.min.y > region.max.y, or if a region larger than the image is passed.

Sourcedef region_by_pixels(self, /, pos: tuple[int, int], size: tuple[int, int]) -> ColorImage§

Clone a sub-region as a new image.

def rgba_unmultiplied_bytes(self, /) -> bytes§
Sourcedef with_source_size(self, /, source_size: Vec2) -> ColorImage§

Set the source size of e.g. the original SVG image.