Struct photon_rs::PhotonImage
source · 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 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_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.
Trait Implementations§
source§impl Clone for PhotonImage
impl Clone for PhotonImage
source§fn clone(&self) -> PhotonImage
fn clone(&self) -> PhotonImage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<ImageData> for PhotonImage
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
Converts to this type from the input type.
source§impl FromWasmAbi for PhotonImage
impl FromWasmAbi for PhotonImage
source§impl IntoWasmAbi for PhotonImage
impl IntoWasmAbi 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
§type Anchor = Ref<'static, PhotonImage>
type Anchor = Ref<'static, PhotonImage>
The type that holds the reference to
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
Auto Trait Implementations§
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 Swhere
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,
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>,
Convert the source color to the destination color using the specified
method
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere Scheme: ApproxScheme,
§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>
Convert the given value into an approximately equivalent representation.
§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,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, DefaultApprox>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where Self: Sized + ApproxInto<Dst, DefaultApprox>,
Approximate the subject to a given type with the default scheme.
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
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
Convert into T with values clamped to the color defined bounds Read more
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
Convert into T. The resulting color might be invalid in its color space Read more
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere T: IntoWasmAbi,
§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::Abi
source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.§impl<Src> TryFrom<Src> for Src
impl<Src> TryFrom<Src> for Src
§impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
impl<Src, Dst> TryInto<Dst> for Srcwhere Dst: TryFrom<Src>,
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>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an
OutOfBounds
error is returned which contains
the unclamped color. Read more§impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
§fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
§impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Srcwhere Dst: ValueFrom<Src>,
§fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.