Struct exoquant::Remapper [] [src]

pub struct Remapper<'a, T: 'a + ColorSpace, D: 'a + Ditherer + ?Sized> {
    // some fields omitted
}

A helper type to very slightly simplify remapping images using a Ditherer.

The plain remap function remaps a &[Color] to a Vec<u8>, while the remap_iter function remaps a Box<Iterator<Item = Color>> to a Box<Iterator<Item = u8>>. The _usize functions remap to usize instead of u8, in case you need palettes with more than 256 colors.

Examples

let ditherer = ditherer::FloydSteinberg::new();
let remapper = Remapper::new(&palette, &colorspace, &ditherer);
let indexed_image_data = remapper.remap(&image.pixels, image.width);
let ditherer = ditherer::FloydSteinberg::new();
let remapper = Remapper::new(&palette, &colorspace, &ditherer);
let iter = remapper.remap_iter(Box::new(image.pixels.iter().cloned()), image.width);
let indexed_image_data: Vec<u8> = iter.collect();

Methods

impl<'a, T: ColorSpace, D: Ditherer + ?Sized> Remapper<'a, T, D>
[src]

fn new(palette: &[Color], colorspace: &'a T, ditherer: &'a D) -> Remapper<'a, T, D>

Create a new Remapper instance for the given palette, colorspace and ditherer.

fn remap(&self, image: &[Color], width: usize) -> Vec<u8>

Remap and dither a &[Color] to a Vec<u8>.

fn remap_usize(&self, image: &[Color], width: usize) -> Vec<usize>

Remap and dither a &[Color] to a Vec<usize>.

fn remap_iter<'b>(&'b self, image: Box<Iterator<Item=Color> + 'b>, width: usize) -> Box<Iterator<Item=u8> + 'b>

Remap and dither a Box<Iterator<Item = Color>> to a Box<Iterator<Item = u8>>.

fn remap_iter_usize<'b>(&'b self, image: Box<Iterator<Item=Color> + 'b>, width: usize) -> Box<Iterator<Item=usize> + 'b>

Remap and dither a Box<Iterator<Item = Color>> to a Box<Iterator<Item = usize>>.