Skip to main content

Surface

Struct Surface 

Source
pub struct Surface {
    pub px: Vec<u8>,
    pub w: i32,
    pub h: i32,
    pub stride: i32,
    pub fmt: u8,
    pub flags: u8,
    pub opac: u8,
    pub blend: u8,
}
Expand description

pixels of one image: rows of stride bytes (4 per pixel, A8: 1)

Fields§

§px: Vec<u8>§w: i32§h: i32§stride: i32§fmt: u8§flags: u8§opac: u8§blend: u8

Implementations§

Source§

impl Surface

Source

pub fn new(w: i32, h: i32, fmt: u8) -> Surface

zeroed pixels, stride 64-byte aligned; sides outside 0..65536 give an empty surface (surf_alloc fails). Byte lengths beyond the target’s addressable allocation size also give an empty surface, before allocating pixels.

Source

pub fn try_new(w: i32, h: i32, fmt: u8) -> Option<Surface>

like new, but None (instead of an empty surface or an abort) when the size is invalid or the memory is not there (try_zeroed). For sizes that come from a file or from the user.

Source

pub fn new_a8_packed(w: i32, h: i32) -> Surface

a tightly packed A8 surface (glyph masks: stride = w)

Source

pub fn resize(&mut self, w: i32, h: i32)

new size, same format; the contents are NOT kept [surf_resize]

Source

pub fn bpp(&self) -> usize

bytes per pixel

Trait Implementations§

Source§

impl Default for Surface

Source§

fn default() -> Surface

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.