Expand description
A lib crate for extracting a color palette from an image represented as a u8
slice.
Supports RGB
and RGBA
.
§Examples
See examples
directory in code repo for a full set of functioning examples!
§Basic
use palette_extract::get_palette_rgb;
let pixels: [u8; 12] = [255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0];
let palette = get_palette_rgb(&pixels);
§With options
use palette_extract::{get_palette_with_options, Quality, MaxColors, PixelEncoding, PixelFilter};
let pixels: [u8; 12] = [255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0];
let color_palette = get_palette_with_options(&pixels,
PixelEncoding::Rgb,
Quality::new(1),
MaxColors::new(4),
PixelFilter::White);
Structs§
- Color
- A struct representing a color - the output of the palette extraction.
- MaxColors
- Represents the max number of colors to extract from the image. Defaults to 10.
- Quality
- Represents the quality level used to extract the color palette. Defaults to 5.
Enums§
- Pixel
Encoding - Enum representing a pixel encoding.
- Pixel
Filter - Represents a filter that can be applied to algorithm to filter out particular pixels.
Functions§
- get_
palette_ rgb - Extracts a color palette from a slice of RGB color bytes represented with
u8
. Uses ‘Quality’ of 5, ‘MaxColors’ of 10, and ‘PixelFilter::None’. - get_
palette_ with_ options - Extracts a color palette from a slice of RGB color bytes represented with
u8
. Allows setting of various options.