[][src]Struct sciter::graphics::Image

pub struct Image(_);

Graphics image object.

Implementations

impl Image[src]

pub fn create((width, height): (u32, u32), with_alpha: bool) -> Result<Image>[src]

Create a new blank image.

pub fn new((width, height): (u32, u32), with_alpha: bool) -> Result<Image>[src]

👎 Deprecated:

Use Image::create instead.

Create a new blank image.

pub fn with_data(
    (width, height): (u32, u32),
    with_alpha: bool,
    pixmap: &[u8]
) -> Result<Image>
[src]

Create image from BGRA data. Size of the pixmap is width * height * 4 bytes.

pub fn load(image_data: &[u8]) -> Result<Image>[src]

Load image from memory.

Supported formats are: GIF, JPEG, PNG, WebP. On Windows also are BMP, ICO, TIFF and WMP.

pub fn save(&self, encoding: SaveImageEncoding) -> Result<Vec<u8>>[src]

Save content of the image as a byte vector.

pub fn paint<PaintFn>(&mut self, painter: PaintFn) -> Result<()> where
    PaintFn: Fn(&mut Graphics, (f32, f32)) -> Result<()>, 
[src]

Render on bitmap image using methods of the Graphics object.

The image must be created using Image::new() or Image::with_data() methods or loaded from a BMP file.

PaintFn painter type must be the following:

use sciter::graphics::{Graphics, Result};

fn paint(gfx: &mut Graphics, (width, height): (f32, f32)) -> Result<()>

Note that errors inside painter are promoted back to the caller of the paint().

Example:

let mut image = Image::new((100, 100), false).unwrap();
image.paint(|gfx, size| {
  gfx.rectangle((5.0, 5.0), (size.0 - 5.0, size.1 - 5.0))?;
  Ok(())
}).unwrap();

pub fn dimensions(&self) -> Result<(u32, u32)>[src]

Get width and height of the image (in pixels).

pub fn clear(&mut self) -> Result<()>[src]

Clear image by filling it with the black color.

pub fn clear_with(&mut self, color: Color) -> Result<()>[src]

Clear image by filling it with the specified color.

Trait Implementations

impl Clone for Image[src]

Copies image object.

All allocated objects are reference counted so copying is just a matter of increasing reference counts.

impl Drop for Image[src]

Destroy pointed image object.

impl From<Image> for Value[src]

Store the Image object as a Value.

impl FromValue for Image[src]

Get an Image object contained in the Value.

Auto Trait Implementations

impl RefUnwindSafe for Image

impl !Send for Image

impl !Sync for Image

impl Unpin for Image

impl UnwindSafe for Image

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.