[−][src]Struct fae::Image
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(&self) -> 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
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,