pub struct PhotonImage { /* private fields */ }
Expand description
Provides the image’s height, width, and contains the image’s raw pixels. For use when communicating between JS and WASM, and also natively.
Implementations§
Source§impl PhotonImage
impl PhotonImage
Sourcepub fn new(raw_pixels: Vec<u8>, width: u32, height: u32) -> PhotonImage
pub fn new(raw_pixels: Vec<u8>, width: u32, height: u32) -> PhotonImage
Create a new PhotonImage from a Vec of u8s, which represent raw pixels.
Sourcepub fn new_from_base64(base64: &str) -> PhotonImage
pub fn new_from_base64(base64: &str) -> PhotonImage
Create a new PhotonImage from a base64 string.
Sourcepub fn new_from_byteslice(vec: Vec<u8>) -> PhotonImage
pub fn new_from_byteslice(vec: Vec<u8>) -> PhotonImage
Create a new PhotonImage from a byteslice.
Sourcepub fn new_from_blob(blob: Blob) -> PhotonImage
pub fn new_from_blob(blob: Blob) -> PhotonImage
Create a new PhotonImage from a Blob/File.
Sourcepub fn new_from_image(image: HtmlImageElement) -> PhotonImage
pub fn new_from_image(image: HtmlImageElement) -> PhotonImage
Create a new PhotonImage from a HTMLImageElement
Sourcepub fn get_raw_pixels(&self) -> Vec<u8> ⓘ
pub fn get_raw_pixels(&self) -> Vec<u8> ⓘ
Get the PhotonImage’s pixels as a Vec of u8s.
Sourcepub fn get_height(&self) -> u32
pub fn get_height(&self) -> u32
Get the height of the PhotonImage.
Sourcepub fn get_base64(&self) -> String
pub fn get_base64(&self) -> String
Convert the PhotonImage to base64.
Sourcepub fn get_bytes_jpeg(&self, quality: u8) -> Vec<u8> ⓘ
pub fn get_bytes_jpeg(&self, quality: u8) -> Vec<u8> ⓘ
Convert the PhotonImage to raw bytes. Returns a JPEG.
Sourcepub fn get_bytes_webp(&self) -> Vec<u8> ⓘ
pub fn get_bytes_webp(&self) -> Vec<u8> ⓘ
Convert the PhotonImage to raw bytes. Returns a WEBP.
Sourcepub fn get_image_data(&mut self) -> ImageData
pub fn get_image_data(&mut self) -> ImageData
Convert the PhotonImage’s raw pixels to JS-compatible ImageData.
Sourcepub fn set_imgdata(&mut self, img_data: ImageData)
pub fn set_imgdata(&mut self, img_data: ImageData)
Convert ImageData to raw pixels, and update the PhotonImage’s raw pixels to this.
Sourcepub fn get_estimated_filesize(&self) -> u64
pub fn get_estimated_filesize(&self) -> u64
Calculates estimated filesize and returns number of bytes
Trait Implementations§
Source§impl Clone for PhotonImage
impl Clone for PhotonImage
Source§fn clone(&self) -> PhotonImage
fn clone(&self) -> PhotonImage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PhotonImage
impl Debug for PhotonImage
Source§impl<'de> Deserialize<'de> for PhotonImage
impl<'de> Deserialize<'de> for PhotonImage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<ImageData> for PhotonImage
Create a new PhotonImage from a raw Vec of u8s representing raw image pixels.
impl From<ImageData> for PhotonImage
Create a new PhotonImage from a raw Vec of u8s representing raw image pixels.
Source§impl From<PhotonImage> for JsValue
impl From<PhotonImage> for JsValue
Source§fn from(value: PhotonImage) -> Self
fn from(value: PhotonImage) -> Self
Source§impl FromWasmAbi for PhotonImage
impl FromWasmAbi for PhotonImage
Source§impl IntoWasmAbi for PhotonImage
impl IntoWasmAbi for PhotonImage
Source§impl LongRefFromWasmAbi for PhotonImage
impl LongRefFromWasmAbi for PhotonImage
Source§impl OptionFromWasmAbi for PhotonImage
impl OptionFromWasmAbi for PhotonImage
Source§impl OptionIntoWasmAbi for PhotonImage
impl OptionIntoWasmAbi for PhotonImage
Source§impl RefFromWasmAbi for PhotonImage
impl RefFromWasmAbi for PhotonImage
Source§type Anchor = RcRef<PhotonImage>
type Anchor = RcRef<PhotonImage>
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for PhotonImage
impl RefMutFromWasmAbi for PhotonImage
Source§impl Serialize for PhotonImage
impl Serialize for PhotonImage
Source§impl TryFromJsValue for PhotonImage
impl TryFromJsValue for PhotonImage
Source§impl VectorFromWasmAbi for PhotonImage
impl VectorFromWasmAbi for PhotonImage
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[PhotonImage]>
Source§impl VectorIntoJsValue for PhotonImage
impl VectorIntoJsValue for PhotonImage
fn vector_into_jsvalue(vector: Box<[PhotonImage]>) -> JsValue
Source§impl VectorIntoWasmAbi for PhotonImage
impl VectorIntoWasmAbi for PhotonImage
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[PhotonImage]>) -> Self::Abi
Source§impl WasmDescribeVector for PhotonImage
impl WasmDescribeVector for PhotonImage
impl SupportsConstructor for PhotonImage
impl SupportsInstanceProperty for PhotonImage
impl SupportsStaticProperty for PhotonImage
Auto Trait Implementations§
impl Freeze for PhotonImage
impl RefUnwindSafe for PhotonImage
impl Send for PhotonImage
impl Sync for PhotonImage
impl Unpin for PhotonImage
impl UnwindSafe for PhotonImage
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§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::Abi
Source§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
.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more