Numeric type usable as an offset or size on
PalettizedImageWithMetadata. Blanket-implemented for every Copy
type that round-trips through u32 (u8, u16, u32, u64, i32,
usize, …).
Given a palettized image and a palette, this function will create a PNG
image in the specified output_path. When use_transparency is true
the output is RGBA (palette index 0 is written with alpha 0,
everything else with alpha 255); when false it is RGB.
Given a PalettizedImageWithMetadata and a palette, this function
will create a PNG image in the specified output_path sized to the
original_width × original_height canvas, with the palettized data
placed at (x_offset, y_offset). This is the round-trip counterpart of
read_png with trim_transparent_pixels = true.
Reads a PNG file and creates an PalettizedImageWithMetadata by doing colour
lookups using the given palette. If trim_transparent_pixels is set to true,
any rows or columns where all pixels are transparent will be trimmed away,
so that only the non-transparent parts of the image remains.
Reads a Palette file. Expects exactly 768 bytes (256 RGB entries * 3
bytes); returns Error::PaletteFileWrongLength if the file is shorter
or longer than that. Underlying file-system failures are returned as
Error::Io.
Saves the given pixel buffer to the given output path. When
use_transparency is true the buffer is interpreted as RGBA (4
bytes per pixel); when false it is interpreted as RGB (3 bytes per
pixel). Returns Error::Validation if the buffer length does not
match width * height * channels (or if that product itself overflows
usize), or Error::Image if the underlying encode/write fails.