Struct glifparser::image::Image
source · pub struct Image {
pub filename: PathBuf,
pub data: ImageData,
pub codec: ImageCodec,
pub matrix: Affine,
pub color: Option<Color>,
}Fields§
§filename: PathBuf§data: ImageData§codec: ImageCodec§matrix: Affine§color: Option<Color>Implementations§
source§impl Image
impl Image
pub fn from_filename<P: Into<PathBuf>>(p: P) -> Result<Self, GlifParserError>
sourcepub fn load(&mut self) -> Result<(), GlifParserError>
pub fn load(&mut self) -> Result<(), GlifParserError>
Examples found in repository?
src/image.rs (line 165)
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
pub fn to_image_of(&self, glif: &dyn GlifLike) -> Result<Image, GlifParserError> {
let mut ret = Image::new();
let mut filename = glif.filename().as_ref().ok_or(GlifParserError::GlifFilenameNotSet(glif.name().clone()))?.clone().parent().ok_or(GlifParserError::GlifFilenameInsane("Failed to parent".to_string()))?.to_path_buf();
filename.push("..");
filename.push("images");
filename.push(self.filename.clone());
ret.filename = filename;
ret.load()?;
ret.matrix = self.matrix().into();
ret.color = self.color;
Ok(ret)
}
}
impl Image {
pub fn from_filename<P: Into<path::PathBuf>>(p: P) -> Result<Self, GlifParserError> {
let mut ret = Self::new();
ret.filename = p.into();
ret.load()?;
Ok(ret)
}pub fn data(self) -> Result<Vec<u8>, GlifParserError>
sourcepub fn decode(&mut self) -> Result<(), GlifParserError>
pub fn decode(&mut self) -> Result<(), GlifParserError>
bitmap is guaranteed to always be in RGBA8888 format. Meaning, for each pixel, there’s a [u8; 4]. So a 3x1 image may look like [3, 3, 3, 255, 3, 3, 3, 255, 3, 3, 3, 255].to_vec().