From 1de64a3818875947f7f1044b1d4cfdf271b04fd3 Mon Sep 17 00:00:00 2001 From: Genny Date: Sun, 21 Nov 2021 18:35:57 -0600 Subject: Bring gifprobe into this repository --- src/colorimage.rs | 61 ------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/colorimage.rs (limited to 'src/colorimage.rs') diff --git a/src/colorimage.rs b/src/colorimage.rs deleted file mode 100644 index 69dac1e..0000000 --- a/src/colorimage.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::convert::TryFrom; - -use crate::{block::ColorTable, gif::Image, reader::DecodingError, Color}; - -pub struct ColorImage { - width: u16, - height: u16, - data: Vec, -} - -impl ColorImage { - pub(crate) fn from_indicies( - width: u16, - height: u16, - indicies: &[u8], - table: &ColorTable, - transindex: Option, - ) -> Result { - let mut data = vec![Pixel::Transparent; (width * height) as usize]; - - for (image_index, color_index) in indicies.into_iter().enumerate() { - if let Some(trans) = transindex { - if trans == *color_index { - data[image_index] = Pixel::Transparent; - } - } else { - data[image_index] = Pixel::Color( - table - .get(*color_index) - .ok_or(DecodingError::ColorIndexOutOfBounds)?, - ); - } - } - - Ok(ColorImage { - width, - height, - data, - }) - } -} - -impl<'a> TryFrom> for ColorImage { - type Error = DecodingError; - - fn try_from(img: Image<'a>) -> Result { - ColorImage::from_indicies( - img.width, - img.height, - img.indicies, - img.palette, - img.transparent_index, - ) - } -} - -#[derive(Copy, Clone, Debug, PartialEq)] -pub enum Pixel { - Color(Color), - Transparent, -} -- cgit 1.4.1-3-g733a5