pub struct Bitmap {
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
}Expand description
An 8-bit-per-pixel bitmap in system memory: a back buffer, a sprite, a tile sheet.
Drawing into it is free (it is not video memory). Copy it to the screen with
Dos::blit13, ModeX::blit or the per-adapter helpers.
Fields§
§width: u32§height: u32§data: Vec<u8>Implementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn from_rgba(
width: u32,
height: u32,
rgba: &[u8],
palette: &[[u8; 3]],
dither: Dither,
) -> Self
pub fn from_rgba( width: u32, height: u32, rgba: &[u8], palette: &[[u8; 3]], dither: Dither, ) -> Self
Convert true-color RGBA8 pixels to palette indices, the way artwork was prepared for
16- and 256-color modes. palette holds 8-bit RGB (see
crate::palette::CGA or Dos::dac scaled with crate::palette::dac6_to_8);
index i of the result is entry i of palette.
pub fn new(width: u32, height: u32) -> Self
pub fn from_data(width: u32, height: u32, data: Vec<u8>) -> Option<Self>
Sourcepub fn from_art(rows: &[&str], palette: &[(char, u8)]) -> Self
pub fn from_art(rows: &[&str], palette: &[(char, u8)]) -> Self
Build a bitmap from rows of characters, mapping each character through palette
(characters not in it become 0, the transparent color). Handy for small sprites.
pub fn get(&self, x: i32, y: i32) -> u8
pub fn pset(&mut self, x: i32, y: i32, c: u8)
pub fn clear(&mut self, c: u8)
pub fn row(&self, y: u32) -> &[u8] ⓘ
pub fn row_mut(&mut self, y: u32) -> &mut [u8] ⓘ
pub fn fill_rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u8)
pub fn rect(&mut self, x: i32, y: i32, w: i32, h: i32, c: u8)
pub fn hline(&mut self, x0: i32, x1: i32, y: i32, c: u8)
pub fn vline(&mut self, x: i32, y0: i32, y1: i32, c: u8)
Sourcepub fn circle(&mut self, cx: i32, cy: i32, r: i32, c: u8, fill: bool)
pub fn circle(&mut self, cx: i32, cy: i32, r: i32, c: u8, fill: bool)
Midpoint circle; fill draws a disc.
Sourcepub fn blit(&mut self, src: &Bitmap, x: i32, y: i32, transparent: Option<u8>)
pub fn blit(&mut self, src: &Bitmap, x: i32, y: i32, transparent: Option<u8>)
Copy src with its top-left at (x, y); transparent pixels are skipped.
Trait Implementations§
impl Eq for Bitmap
impl StructuralPartialEq for Bitmap
Auto Trait Implementations§
impl Forget for Bitmap
impl Freeze for Bitmap
impl RefUnwindSafe for Bitmap
impl Send for Bitmap
impl Sync for Bitmap
impl Unpin for Bitmap
impl UnsafeUnpin for Bitmap
impl UnwindSafe for Bitmap
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more