[−][src]Struct quicksilver::graphics::Surface
A Surface is the core struct for rendering to textures, or getting data from them.
If you want to render to a texture, attach
it and then pass the surface to
[Graphics::flush
].
If you want to get data from a texture, attach
it and use Surface::screenshot
.
Implementations
impl Surface
[src]
pub fn new(
gfx: &Graphics,
attachment: Image
) -> Result<Surface, QuicksilverError>
[src]
gfx: &Graphics,
attachment: Image
) -> Result<Surface, QuicksilverError>
Create a Surface with an attached Image
The image must not have any other references to it, or this function will return an error.
pub fn attach(&mut self, attachment: Image) -> Result<(), QuicksilverError>
[src]
Use the attached image as the backing data for this Surface
To either get the data for an image via Surface::screenshot
or set it via
[Graphics::flush
], an image needs to be attached to this Surface.
The image must not have any other references to it, or this function will return an error.
It's generally faster to create one Surface
per Image
, and only attach and
detach
when necessary.
pub fn detach(&mut self) -> Option<Image>
[src]
Take the Image out of this Surface
To use the data that has been rendered to a Surface, its attachment has to be removed to avoid creating a loop (where the Image is both being drawn from and being drawn to.)
pub fn screenshot(
&self,
gfx: &Graphics,
x: u32,
y: u32,
width: u32,
height: u32,
format: ColorFormat
) -> Vec<u8>ⓘ
[src]
&self,
gfx: &Graphics,
x: u32,
y: u32,
width: u32,
height: u32,
format: ColorFormat
) -> Vec<u8>ⓘ
Get the pixel data of a given region of this surface
pub fn size(&self) -> Option<Vector>
[src]
Return the size of the attached image, or None if there is no image
Auto Trait Implementations
impl !RefUnwindSafe for Surface
impl !Send for Surface
impl !Sync for Surface
impl Unpin for Surface
impl !UnwindSafe for Surface
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
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>,