logo
pub struct Image<'pixels> { /* private fields */ }
Expand description

Describes image dimensions and pixels for the library

Create one using Attributes::new_image().

All images are internally in the RGBA format.

Implementations

Makes an image from RGBA pixels.

See the rgb and bytemuck crates for making [RGBA] slices from [u8] slices.

The pixels argument can be Vec<RGBA>, or Box<[RGBA]> or &[RGBA].

If you want to supply RGB or ARGB pixels, convert them to RGBA first, or use Image::new_fn to supply your own pixel-swapping function.

Use 0. for gamma if the image is sRGB (most images are).

Describe dimensions of a slice of RGBA pixels.

Same as Image::new, except it doesn’t copy the pixels, but holds a temporary reference instead.

If you want to supply RGB or ARGB pixels, use Image::new_fn to supply your own pixel-swapping function.

See the rgb and bytemuck crates for making [RGBA] slices from [u8] slices.

Use 0. for gamma if the image is sRGB (most images are).

Generate rows on demand using a callback function.

The callback function should be cheap (e.g. just byte-swap pixels). The parameters are: line of RGBA pixels (slice’s len is equal to image width), and row number (0-indexed). The callback will be called multiple times per row. May be called from multiple threads at once.

Use 0. for gamma if the image is sRGB (most images are).

Safety

This function is marked as unsafe, because the callback function MUST initialize the entire row (call write on every MaybeUninit pixel).

Set which pixels are more important (and more likely to get a palette entry)

The map must be width×height pixels large. Higher numbers = more important.

Remap pixels assuming they will be displayed on this background. This is designed for GIF’s “keep” mode.

Pixels that match the background color will be made transparent if there’s a fully transparent color available in the palette.

The background image’s pixels must outlive this image.

Reserves a color in the output palette created from this image. It behaves as if the given color was used in the image and was very important.

The RGB values are assumed to have the same gamma as the image.

It must be called before the image is quantized.

Returns error if more than 256 colors are added. If image is quantized to fewer colors than the number of fixed colors added, then excess fixed colors will be ignored.

Width of the image in pixels

Height of the image in pixels

Stride is in pixels. Allows defining regions of larger images or images with padding without copying. The stride is in pixels.

Otherwise the same as Image::new_borrowed.

Create new image by copying pixels to an internal buffer, so that it makes a self-contained type.

The pixels argument can be Vec<RGBA>, or Box<[RGBA]> or &[RGBA].

Otherwise the same as Image::new_stride_borrowed.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.