Crate imagequant_sys [] [src]

Small, portable C library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images. It's powering pngquant2.

This is a low-level crate exposing a C API. If you're looking for a Rust library, see imagequant.

License

Libimagequant is dual-licensed:

  • For Free/Libre Open Source Software it's available under GPL v3 or later with additional copyright notices for older parts of the code.

  • For use in non-GPL software (e.g. closed-source or App Store distribution) please ask kornel@pngquant.org for a commercial license.

Overview

The basic flow is:

  1. Create attributes object and configure the library.
  2. Create image object from RGBA pixels or data source.
  3. Perform quantization (generate palette).
  4. Store remapped image and final palette.
  5. Free memory.

Please note that libimagequant only handles raw uncompressed arrays of pixels in memory and is completely independent of any file format.

There are 3 ways to create image object for quantization:

  • liq_image_create_rgba() for simple, contiguous RGBA pixel arrays (width×height×4 bytes large bitmap).
  • liq_image_create_rgba_rows() for non-contiguous RGBA pixel arrays (that have padding between rows or reverse order, e.g. BMP).
  • liq_image_create_custom() for RGB, ABGR, YUV and all other formats that can be converted on-the-fly to RGBA (you have to supply the conversion function).

Note that "image" here means raw uncompressed pixels. If you have a compressed image file, such as PNG, you must use another library (e.g. lodepng) to decode it first.

Structs

liq_histogram_entry
liq_palette

Enums

liq_attr
liq_error
liq_histogram
liq_image
liq_ownership
liq_result

Functions

liq_attr_copy
liq_attr_create

Returns object that will hold initial settings (attributes) for the library.

liq_attr_destroy
liq_attr_set_progress_callback
liq_get_max_colors
liq_get_max_quality
liq_get_min_posterization
liq_get_min_quality
liq_get_output_gamma
liq_get_palette

Returns pointer to palette optimized for image that has been quantized or remapped (final refinements are applied to the palette during remapping).

liq_get_quantization_error
liq_get_quantization_quality
liq_get_remapping_error
liq_get_remapping_quality
liq_get_speed
liq_histogram_add_colors
liq_histogram_add_fixed_color
liq_histogram_add_image
liq_histogram_create
liq_histogram_destroy
liq_histogram_quantize
liq_image_add_fixed_color
liq_image_create_custom
liq_image_create_rgba

Creates an object that represents the image pixels to be used for quantization and remapping.

liq_image_create_rgba_rows
liq_image_destroy
liq_image_get_height
liq_image_get_width
liq_image_quantize
liq_image_set_background

Remap assuming the image will be always presented exactly on top of this background.

liq_image_set_importance_map
liq_quantize_image

Performs quantization (palette generation) based on settings in attr (from liq_attr_create()) and pixels of the image.

liq_result_destroy
liq_result_set_progress_callback
liq_set_dithering_level

Enables/disables dithering in liq_write_remapped_image().

liq_set_last_index_transparent
liq_set_log_callback
liq_set_log_flush_callback
liq_set_max_colors

Specifies maximum number of colors to use.

liq_set_min_posterization
liq_set_output_gamma
liq_set_quality

Quality is in range 0 (worst) to 100 (best) and values are analoguous to JPEG quality (i.e. 80 is usually good enough).

liq_set_speed
liq_version
liq_write_remapped_image

Remaps the image to palette and writes its pixels to the given buffer, 1 pixel per byte.

liq_write_remapped_image_rows

Type Definitions

liq_color
liq_image_get_rgba_row_callback
liq_log_callback_function
liq_log_flush_callback_function
liq_progress_callback_function