Struct ntcip::dms::Graphic

source ·
pub struct Graphic {
    pub number: u8,
    pub name: FStr<64>,
    pub height: u8,
    pub width: u16,
    pub gtype: ColorScheme,
    pub transparent_color: Option<Color>,
    pub bitmap: Vec<u8>,
}
Expand description

Graphic image — dmsGraphicEntry

Fields§

§number: u8

Graphic number — dmsGraphicNumber

§name: FStr<64>

Name of graphic — dmsGraphicName

§height: u8

Height (pixels) — dmsGraphicHeight

§width: u16

Width (pixels) — dmsGraphicWidth

§gtype: ColorScheme

Graphic type — dmsGraphicType

§transparent_color: Option<Color>

dmsGraphicTransparentEnabled / dmsGraphicTransparentColor

§bitmap: Vec<u8>

Bitmap data — dmsGraphicBitmapTable

Implementations§

source§

impl Graphic

source

pub fn validate(&self, width: u16, height: u16) -> Result<(), GraphicError>

Check if graphic is valid

source

pub fn version_id(&self) -> u16

Get version ID (dmsGraphicId)

source

pub fn to_raster(&self) -> Raster<SRgba8>

Convert graphic to a raster

Examples found in repository?
examples/graphic.rs (line 21)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() {
    let bitmap = vec![
        0x04, 0x00, 0x80, 0x10, 0x42, 0x14, 0x44, 0x49, 0x05, 0x40, 0x70, 0x04,
        0x00,
    ];
    let graphic = Graphic {
        number: 3,
        name: FStr::from_str_lossy("arrow", b'\0'),
        height: 9,
        width: 11,
        gtype: ColorScheme::Monochrome1Bit,
        transparent_color: None,
        bitmap,
    };
    let raster = graphic.to_raster();
    bmp::write(&raster, &format!("graphic.bmp")).unwrap();
}

Trait Implementations§

source§

impl Clone for Graphic

source§

fn clone(&self) -> Graphic

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Graphic

source§

fn default() -> Graphic

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.