[−][src]Struct beryllium::Surface
Handle to a "surface", a CPU-side image.
This is fairly easy to edit, but you have to upload it to the GPU before you can get it on the screen.
Methods
impl<'sdl> Surface<'sdl>
[src]
pub unsafe fn lock_edit<F: FnMut(*mut u8)>(
&mut self,
op: F
) -> Result<(), String>
[src]
&mut self,
op: F
) -> Result<(), String>
Lock, edit, unlock, as one easy cycle.
If the Surface cannot be locked you'll get an error, otherwise your closure will be called with the base pointer to the Surface's pixel data.
Safety
- You can't store the pointer and use it past the closure
- You have to follow standard 2D raw pixel editing rules.
y * pitch + x * size_of::<PixelType>()
- Stay in bounds and all that jazz
pub fn width(&self) -> i32
[src]
Width in pixels
pub fn height(&self) -> i32
[src]
Height in pixels
pub fn pitch(&self) -> i32
[src]
Pitch in bytes
pub fn clip_rect(&self) -> Rect
[src]
The current clipping rectangle for blits.
pub fn set_clip_rect(&self, opt_rect: Option<Rect>) -> bool
[src]
Assigns a new clipping rectangle.
Some(rect)
will clip blits to be within that rect only.None
will disable clipping.
Returns true
if the given rectangle intersects at least part of the
Surface
(or if it was None
). Otherwise you get false
and all blits
will be completely clipped.
Either way, blits are clipped to be within bounds of the Surface
, so you
don't have to worry about that.
pub fn palette(&self) -> Option<&Palette>
[src]
Gets the surface's palette, if any.
pub fn set_palette(&mut self, palette: &Palette) -> Result<(), String>
[src]
Updates the palette for the surface's pixel format.
Trait Implementations
Auto Trait Implementations
impl<'sdl> !Send for Surface<'sdl>
impl<'sdl> Unpin for Surface<'sdl>
impl<'sdl> !Sync for Surface<'sdl>
impl<'sdl> UnwindSafe for Surface<'sdl>
impl<'sdl> RefUnwindSafe for Surface<'sdl>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,