MulDiv

Struct MulDiv 

Source
pub struct MulDiv { /* private fields */ }
Expand description

Methods of this structure used to multiply or divide color-channels (RGB or Luma) by alpha-channel. Supported pixel types: U8x2, U8x4, U16x2, U16x4, F32x2 and F32x4.

By default, the instance of MulDiv created with the best CPU-extension provided by your CPU. You can change this by using method MulDiv::set_cpu_extensions.

§Examples

use fast_image_resize::pixels::PixelType;
use fast_image_resize::images::Image;
use fast_image_resize::MulDiv;

let width: u32 = 10;
let height: u32 = 7;
let src_image = Image::new(width, height, PixelType::U8x4);
let mut dst_image = Image::new(width, height, PixelType::U8x4);

let mul_div = MulDiv::new();
mul_div.multiply_alpha(&src_image, &mut dst_image).unwrap();

Implementations§

Source§

impl MulDiv

Source

pub fn new() -> Self

Source

pub fn cpu_extensions(&self) -> CpuExtensions

Source

pub unsafe fn set_cpu_extensions(&mut self, extensions: CpuExtensions)

§Safety

This is unsafe because this method allows you to set a CPU-extensions that is not actually supported by your CPU.

Source

pub fn multiply_alpha( &self, src_image: &impl IntoImageView, dst_image: &mut impl IntoImageViewMut, ) -> Result<(), MulDivImagesError>

Multiplies color-channels (RGB or Luma) of source image by alpha-channel and store result into destination image.

Source

pub fn multiply_alpha_typed<P: PixelTrait>( &self, src_view: &impl ImageView<Pixel = P>, dst_view: &mut impl ImageViewMut<Pixel = P>, ) -> Result<(), MulDivImagesError>

Source

pub fn multiply_alpha_inplace( &self, image: &mut impl IntoImageViewMut, ) -> Result<(), ImageError>

Multiplies color-channels (RGB or Luma) of image by alpha-channel inplace.

Source

pub fn multiply_alpha_inplace_typed<P: PixelTrait>( &self, img_view: &mut impl ImageViewMut<Pixel = P>, ) -> Result<(), ImageError>

Source

pub fn divide_alpha( &self, src_image: &impl IntoImageView, dst_image: &mut impl IntoImageViewMut, ) -> Result<(), MulDivImagesError>

Divides color-channels (RGB or Luma) of source image by alpha-channel and store result into destination image.

Source

pub fn divide_alpha_typed<P: PixelTrait>( &self, src_view: &impl ImageView<Pixel = P>, dst_view: &mut impl ImageViewMut<Pixel = P>, ) -> Result<(), MulDivImagesError>

Source

pub fn divide_alpha_inplace( &self, image: &mut impl IntoImageViewMut, ) -> Result<(), ImageError>

Divides color-channels (RGB or Luma) of image by alpha-channel inplace.

Source

pub fn divide_alpha_inplace_typed<P: PixelTrait>( &self, img_view: &mut impl ImageViewMut<Pixel = P>, ) -> Result<(), ImageError>

Source

pub fn is_supported(&self, pixel_type: PixelType) -> bool

Trait Implementations§

Source§

impl Clone for MulDiv

Source§

fn clone(&self) -> MulDiv

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MulDiv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MulDiv

Source§

fn default() -> MulDiv

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for MulDiv

§

impl RefUnwindSafe for MulDiv

§

impl Send for MulDiv

§

impl Sync for MulDiv

§

impl Unpin for MulDiv

§

impl UnwindSafe for MulDiv

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.