Struct ggez::graphics::ImageGeneric
source · [−]pub struct ImageGeneric<B>where
B: BackendSpec,{ /* private fields */ }
Expand description
Generic in-GPU-memory image data available to be drawn on the screen.
You probably just want to look at the Image
type.
Implementations
sourceimpl<B> ImageGeneric<B>where
B: BackendSpec,
impl<B> ImageGeneric<B>where
B: BackendSpec,
sourcepub fn get_raw_texture_handle(&self) -> RawTexture<B::Resources>
pub fn get_raw_texture_handle(&self) -> RawTexture<B::Resources>
A helper function to get the raw gfx texture handle
sourcepub fn get_raw_texture_view(&self) -> RawShaderResourceView<B::Resources>
pub fn get_raw_texture_view(&self) -> RawShaderResourceView<B::Resources>
A helper function to get the raw gfx texture view
sourcepub fn filter(&self) -> FilterMode
pub fn filter(&self) -> FilterMode
Get the filter mode for the image.
sourcepub fn set_filter(&mut self, mode: FilterMode)
pub fn set_filter(&mut self, mode: FilterMode)
Set the filter mode for the image.
sourcepub fn dimensions(&self) -> Rect
pub fn dimensions(&self) -> Rect
Returns the dimensions of the image.
sourceimpl ImageGeneric<GlBackendSpec>
impl ImageGeneric<GlBackendSpec>
sourcepub fn new<P: AsRef<Path>>(context: &mut Context, path: P) -> GameResult<Self>
pub fn new<P: AsRef<Path>>(context: &mut Context, path: P) -> GameResult<Self>
Load a new image from the file at the given path. The documentation for the
filesystem
module explains how the path must be specified.
sourcepub fn from_bytes(context: &mut Context, bytes: &[u8]) -> GameResult<Self>
pub fn from_bytes(context: &mut Context, bytes: &[u8]) -> GameResult<Self>
Creates a new Image
from the given buffer, which should contain an image encoded
in a supported image file format.
sourcepub fn from_bytes_with_format(
context: &mut Context,
bytes: &[u8],
format: ImageFormat
) -> GameResult<Self>
pub fn from_bytes_with_format(
context: &mut Context,
bytes: &[u8],
format: ImageFormat
) -> GameResult<Self>
Creates a new Image
from the given buffer, which should contain an image encoded
in the given image file format.
sourcepub fn from_rgba8(
context: &mut Context,
width: u16,
height: u16,
rgba: &[u8]
) -> GameResult<Self>
pub fn from_rgba8(
context: &mut Context,
width: u16,
height: u16,
rgba: &[u8]
) -> GameResult<Self>
Creates a new Image
from the given buffer of u8
RGBA values.
The pixel layout is row-major. That is,
the first 4 u8
values make the top-left pixel in the Image
, the
next 4 make the next pixel in the same row, and so on to the end of
the row. The next width * 4
values make up the second row, and so
on.
sourcepub fn to_rgba8(&self, ctx: &mut Context) -> GameResult<Vec<u8>>
pub fn to_rgba8(&self, ctx: &mut Context) -> GameResult<Vec<u8>>
Dumps the Image
’s data to a Vec
of u8
RGBA values.
sourcepub fn encode<P: AsRef<Path>>(
&self,
ctx: &mut Context,
format: ImageFormat,
path: P
) -> GameResult
pub fn encode<P: AsRef<Path>>(
&self,
ctx: &mut Context,
format: ImageFormat,
path: P
) -> GameResult
Encode the Image
to the given file format and
write it out to the given path.
See the filesystem
module docs for where exactly
the file will end up.
Trait Implementations
sourceimpl<B: Clone> Clone for ImageGeneric<B>where
B: BackendSpec,
B::Resources: Clone,
B::Resources: Clone,
impl<B: Clone> Clone for ImageGeneric<B>where
B: BackendSpec,
B::Resources: Clone,
B::Resources: Clone,
sourcefn clone(&self) -> ImageGeneric<B>
fn clone(&self) -> ImageGeneric<B>
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more