Function lodepng::encode_memory

source ·
pub fn encode_memory<PixelType: Pod>(
    image: &[PixelType],
    w: usize,
    h: usize,
    colortype: ColorType,
    bitdepth: c_uint
) -> Result<Vec<u8>, Error>
Expand description

Converts raw pixel data into a PNG image in memory. The colortype and bitdepth of the output PNG image cannot be chosen, they are automatically determined by the colortype, bitdepth and content of the input pixel data.

Note: for 16-bit per channel colors, needs big endian format like PNG does.

  • image: The raw pixel data to encode. The size of this buffer should be w * h * (bytes per pixel), bytes per pixel depends on colortype and bitdepth.
  • w: width of the raw pixel data in pixels.
  • h: height of the raw pixel data in pixels.
  • colortype: the color type of the raw input image. See ColorType.
  • bitdepth: the bit depth of the raw input image. 1, 2, 4, 8 or 16. Typically 8.

Takes any pixel type, but for safety the type has to be marked as “plain old data”