Struct sciter::graphics::Image [−][src]
pub struct Image(_);
Graphics image object.
Methods
impl Image
[src]
impl Image
pub fn new((width, height): (u32, u32), with_alpha: bool) -> Result<Image>
[src]
pub fn new((width, height): (u32, u32), with_alpha: bool) -> Result<Image>
Create a new blank image.
pub fn with_data(
(width, height): (u32, u32),
with_alpha: bool,
pixmap: &[u8]
) -> Result<Image>
[src]
pub fn with_data(
(width, height): (u32, u32),
with_alpha: bool,
pixmap: &[u8]
) -> Result<Image>
Create image from BGRA
data. Size of the pixmap is width * height * 4
bytes.
pub fn load(image_data: &[u8]) -> Result<Image>
[src]
pub fn load(image_data: &[u8]) -> Result<Image>
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]
pub fn save(&self, encoding: SaveImageEncoding) -> Result<Vec<u8>>
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]
pub fn paint<PaintFn>(&mut self, painter: PaintFn) -> Result<()> where
PaintFn: Fn(&mut Graphics, (f32, f32)) -> Result<()>,
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]
pub fn dimensions(&self) -> Result<(u32, u32)>
Get width and height of the image (in pixels).
pub fn clear(&mut self) -> Result<()>
[src]
pub fn clear(&mut self) -> Result<()>
Clear image by filling it with the black color.
pub fn clear_with(&mut self, color: Color) -> Result<()>
[src]
pub fn clear_with(&mut self, color: Color) -> Result<()>
Clear image by filling it with the specified color
.
Trait Implementations
impl Drop for Image
[src]
impl Drop for Image
Destroy pointed image object.
impl Clone for Image
[src]
impl Clone for Image
Copies image object.
All allocated objects are reference counted so copying is just a matter of increasing reference counts.
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl FromValue for Image
[src]
impl FromValue for Image
Get an Image
object contained in the Value
.
fn from_value(v: &Value) -> Option<Image>
[src]
fn from_value(v: &Value) -> Option<Image>
Converts value to specified type.
impl From<Image> for Value
[src]
impl From<Image> for Value
Store the Image
object as a Value
.