pub struct WebImage { /* private fields */ }Implementations§
Source§impl WebImage
impl WebImage
pub fn new(raw_pixels: Vec<u8>, width: u32, height: u32) -> Self
Sourcepub fn try_from_byte_slice(bytes: &[u8]) -> Result<WebImage, WebImageError>
pub fn try_from_byte_slice(bytes: &[u8]) -> Result<WebImage, WebImageError>
Try to create a new WebImage from a byte slice
returns: Result<WebImage, WebImageError>
§Errors
Errors if there’s an error while decoding the image from given data
Sourcepub async fn try_from_blob(blob: Blob) -> Result<WebImage, WebImageError>
pub async fn try_from_blob(blob: Blob) -> Result<WebImage, WebImageError>
Try to create a new WebImage from a blob
returns: Result<WebImage, WebImageError>
§Errors
Errors if there’s an error while decoding the image from given data
Sourcepub fn try_into_image_data(self) -> Result<ImageData, JsValue>
pub fn try_into_image_data(self) -> Result<ImageData, JsValue>
Try to convert a WebImage to ImageDate that can be used with
ImageData web APIs
returns: Result<ImageData, JsValue>
§Errors
Errors if the web API throws an exception
Sourcepub async fn into_image_bitmap(self) -> Result<ImageBitmap, JsValue>
pub async fn into_image_bitmap(self) -> Result<ImageBitmap, JsValue>
Try to convert a WebImage to ImageBitmap that can be used with
canvas APIs
returns: Result<ImageBitmap, JsValue>
§Errors
Errors if the web API throws an exception
pub fn raw_pixels(self) -> Vec<u8> ⓘ
pub fn width(&self) -> u32
pub fn height(&self) -> u32
Source§impl WebImage
impl WebImage
Sourcepub fn resize(
self,
max_width: u32,
max_height: u32,
) -> Result<WebImage, WebImageError>
pub fn resize( self, max_width: u32, max_height: u32, ) -> Result<WebImage, WebImageError>
Resize this image while preserving aspect ratio. The image is scaled to the maximum possible size that fits within the bounds specified by max_width and max_height.
returns: Result<WebImage, WebImageError>
§Errors
Errors if conversion to DynamicImage fails
Sourcepub fn resize_exact(
self,
width: u32,
height: u32,
) -> Result<WebImage, WebImageError>
pub fn resize_exact( self, width: u32, height: u32, ) -> Result<WebImage, WebImageError>
Resize this image while ignoring aspect ratio. The width and height provided become the new dimensions for the image
returns: Result<WebImage, WebImageError>
§Errors
Errors if conversion to DynamicImage fails
Sourcepub fn resize_to_fill(
self,
width: u32,
height: u32,
) -> Result<WebImage, WebImageError>
pub fn resize_to_fill( self, width: u32, height: u32, ) -> Result<WebImage, WebImageError>
Resize this image while preserving aspect ratio. The image is scaled to the maximum possible size that fits within the larger (relative to aspect ratio) of the bounds specified by width and height, then cropped to fit within the other bound.
returns: Result<WebImage, WebImageError>
§Errors
Errors if conversion to DynamicImage fails
Trait Implementations§
Source§impl From<&DynamicImage> for WebImage
impl From<&DynamicImage> for WebImage
Source§fn from(image: &DynamicImage) -> Self
fn from(image: &DynamicImage) -> Self
Source§impl FromWasmAbi for WebImage
impl FromWasmAbi for WebImage
Source§impl IntoWasmAbi for WebImage
impl IntoWasmAbi for WebImage
Source§impl LongRefFromWasmAbi for WebImage
impl LongRefFromWasmAbi for WebImage
Source§impl OptionFromWasmAbi for WebImage
impl OptionFromWasmAbi for WebImage
Source§impl OptionIntoWasmAbi for WebImage
impl OptionIntoWasmAbi for WebImage
Source§impl RefFromWasmAbi for WebImage
impl RefFromWasmAbi for WebImage
Source§impl RefMutFromWasmAbi for WebImage
impl RefMutFromWasmAbi for WebImage
Source§impl TryFrom<WebImage> for DynamicImage
impl TryFrom<WebImage> for DynamicImage
Source§impl TryFromJsValue for WebImage
impl TryFromJsValue for WebImage
Source§impl VectorFromWasmAbi for WebImage
impl VectorFromWasmAbi for WebImage
Source§impl VectorIntoWasmAbi for WebImage
impl VectorIntoWasmAbi for WebImage
impl SupportsConstructor for WebImage
impl SupportsInstanceProperty for WebImage
impl SupportsStaticProperty for WebImage
Auto Trait Implementations§
impl Freeze for WebImage
impl RefUnwindSafe for WebImage
impl Send for WebImage
impl Sync for WebImage
impl Unpin for WebImage
impl UnwindSafe for WebImage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.