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§

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)
    }

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().

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.