GitHub project page

Struct lodepng::ffi::ColorMode [] [src]

pub struct ColorMode {
    pub colortype: ColorType,
    pub bitdepth: c_uint,
    pub palette: *const RGBA<u8>,
    pub palettesize: size_t,
    // some fields omitted
}

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

color type, see PNG standard

bitdepth

bits per sample, see PNG standard

palette

palette (PLTE and tRNS) Dynamically allocated with the colors of the palette, including alpha. When encoding a PNG, to store your colors in the palette of the LodePNGColorMode, first use lodepng_palette_clear, then for each color use lodepng_palette_add. If you encode an image without alpha with palette, don't forget to put value 255 in each A byte of the palette.

When decoding, by default you can ignore this palette, since LodePNG already fills the palette colors in the pixels of the raw RGBA output.

The palette is only supported for color type 3.

palettesize

palette size in number of colors (amount of bytes is 4 * palettesize)