pub struct Image(_);
Expand description
Graphics image object.
Implementations
sourceimpl Image
impl Image
sourcepub fn create((width, height): (u32, u32), with_alpha: bool) -> Result<Image>
pub fn create((width, height): (u32, u32), with_alpha: bool) -> Result<Image>
Create a new blank image.
sourcepub fn new((width, height): (u32, u32), with_alpha: bool) -> Result<Image>
👎 Deprecated: Use Image::create
instead.
pub fn new((width, height): (u32, u32), with_alpha: bool) -> Result<Image>
Use Image::create
instead.
Create a new blank image.
sourcepub fn with_data(
(width, height): (u32, u32),
with_alpha: bool,
pixmap: &[u8]
) -> Result<Image>
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.
sourcepub fn load(image_data: &[u8]) -> Result<Image>
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.
sourcepub fn save(&self, encoding: SaveImageEncoding) -> Result<Vec<u8>>
pub fn save(&self, encoding: SaveImageEncoding) -> Result<Vec<u8>>
Save content of the image as a byte vector.
sourcepub fn paint<PaintFn>(&mut self, painter: PaintFn) -> Result<()> where
PaintFn: Fn(&mut Graphics, (f32, f32)) -> Result<()>,
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();
sourcepub fn clear_with(&mut self, color: Color) -> Result<()>
pub fn clear_with(&mut self, color: Color) -> Result<()>
Clear image by filling it with the specified color
.
Trait Implementations
sourceimpl Clone for Image
impl Clone for Image
Copies image object.
All allocated objects are reference counted so copying is just a matter of increasing reference counts.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more