#[repr(C)]
pub struct ColorMode { pub colortype: ColorType, /* private fields */ }
Expand description

Color mode of an image. Contains all information required to decode the pixel bits to RGBA colors. This information is the same as used in the PNG file format, and is used both for PNG and raw image data in LodePNG.

Fields

colortype: ColorType

color type, see PNG standard

Implementations

Set color depth to 8-bit palette and set the colors

Reset to 0 colors

add 1 color to the palette

get the total amount of bits per pixel, based on colortype and bitdepth in the struct

tRNS chunk

get the amount of color channels used, based on colortype in the struct. If a palette is used, it counts as 1 channel.

is it a greyscale type? (only colortype 0 or 4)

has it got an alpha channel? (only colortype 2 or 6)

has it got a palette? (only colortype 3)

only returns true if there is a palette and there is a value in the palette with alpha < 255. Loops through the palette to check this.

Check if the given color info indicates the possibility of having non-opaque pixels in the PNG image. Returns true if the image can have translucent or invisible pixels (it still be opaque if it doesn’t use such pixels). Returns false if the image can only have opaque pixels. In detail, it returns true only if it’s a color type with alpha, or has a palette with non-opaque values, or if “key_defined” is true.

Returns the byte size of a raw image buffer with given width, height and color mode

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. 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.