[][src]Type Definition ggez::graphics::Image

type Image = ImageGeneric<GlBackendSpec>;

In-GPU-memory image data available to be drawn on the screen, using the OpenGL backend.

Under the hood this is just an Arc'ed texture handle and some metadata, so cloning it is fairly cheap; it doesn't make another copy of the underlying image data.

Implementations

impl Image[src]

pub fn new<P: AsRef<Path>>(context: &mut Context, path: P) -> GameResult<Self>[src]

Load a new image from the file at the given path. The documentation for the filesystem module explains how the path must be specified.

pub fn from_bytes(context: &mut Context, bytes: &[u8]) -> GameResult<Self>[src]

Creates a new Image from the given buffer, which should contain an image encoded in a supported image file format.

pub fn from_rgba8(
    context: &mut Context,
    width: u16,
    height: u16,
    rgba: &[u8]
) -> GameResult<Self>
[src]

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.

pub fn to_rgba8(&self, ctx: &mut Context) -> GameResult<Vec<u8>>[src]

Dumps the Image's data to a Vec of u8 RGBA values.

pub fn encode<P: AsRef<Path>>(
    &self,
    ctx: &mut Context,
    format: ImageFormat,
    path: P
) -> GameResult
[src]

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.

pub fn solid(context: &mut Context, size: u16, color: Color) -> GameResult<Self>[src]

A little helper function that creates a new Image that is just a solid square of the given size and color. Mainly useful for debugging.

pub fn width(&self) -> u16[src]

Return the width of the image.

pub fn height(&self) -> u16[src]

Return the height of the image.

pub fn filter(&self) -> FilterMode[src]

Get the filter mode for the image.

pub fn set_filter(&mut self, mode: FilterMode)[src]

Set the filter mode for the image.

pub fn dimensions(&self) -> Rect[src]

Returns the dimensions of the image.

pub fn wrap(&self) -> (WrapMode, WrapMode)[src]

Gets the Image's WrapMode along the X and Y axes.

pub fn set_wrap(&mut self, wrap_x: WrapMode, wrap_y: WrapMode)[src]

Sets the Image's WrapMode along the X and Y axes.

Trait Implementations

impl Debug for Image[src]

impl Drawable for Image[src]