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
impl Graphic
sourcepub fn validate(&self, width: u16, height: u16) -> Result<(), GraphicError>
pub fn validate(&self, width: u16, height: u16) -> Result<(), GraphicError>
Check if graphic is valid
sourcepub fn version_id(&self) -> u16
pub fn version_id(&self) -> u16
Get version ID (dmsGraphicId
)
sourcepub fn to_raster(&self) -> Raster<SRgba8>
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§
Auto Trait Implementations§
impl Freeze for Graphic
impl RefUnwindSafe for Graphic
impl Send for Graphic
impl Sync for Graphic
impl Unpin for Graphic
impl UnwindSafe for Graphic
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more