[][src]Struct fae::Image

pub struct Image {
    pub pixels: Vec<u8>,
    pub width: i32,
    pub height: i32,
    pub format: u32,
}

Contains the raw pixel color data of an image (u8 per color channel).

Fields

pixels: Vec<u8>

The pixels of the image.

width: i32

The width of the image.

height: i32

The height of the image.

format: u32

The OpenGL format of the image.

GL_RGBA by default, which means that OpenGL will assume pixels is laid out like so: [r, g, b, a, r, g, ...].

Methods

impl Image[src]

pub fn from_png(bytes: &[u8]) -> Result<Image, Box<dyn Error>>[src]

Tries to load a PNG image and make an Image out of it.

Example

use fae::Image;
use std::fs;
let sprite = Image::from_png(&fs::read("sprite.png").unwrap()).unwrap();

pub fn from_color(width: i32, height: i32, color: &[u8]) -> Image[src]

Creates a solid color image. The color can be 1-4 items long. If the length of color isn't 4, call format to set the appropriate format.

Example

use fae::Image;
let image = Image::from_color(128, 128, &[0xB4, 0x6E, 0xC8, 0xFF]);
// image now represents a 128px by 128px image that consists of fully opaque violet pixels.

pub fn format(self, format: u32) -> Image[src]

Sets the internal_format and format parameters given to glTexImage2D.

Example

use fae::{gl, Image};
let image = Image::from_color(128, 128, &[0x88]).format(gl::RED);
// image now represents a 128px by 128px image that consists of half-red pixels taking up only one byte per pixel.

Trait Implementations

impl Clone for Image[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Image[src]

Auto Trait Implementations

impl Send for Image

impl Sync for Image

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.