Scaler

Struct Scaler 

Source
pub struct Scaler {
    pub workload_strategy: WorkloadStrategy,
    /* private fields */
}
Expand description

Represents base scaling structure

Fields§

§workload_strategy: WorkloadStrategy

Implementations§

Source§

impl Scaler

Source

pub fn new(filter: ResamplingFunction) -> Self

Creates new Scaler instance with corresponding filter

Creates default crate::Scaler with corresponding filter and default ThreadingPolicy::Single

Source

pub fn set_workload_strategy(&mut self, workload_strategy: WorkloadStrategy)

Sets preferred workload strategy

This is hint only, it may change something, or may not.

Source§

impl Scaler

Source

pub fn resize_ar30( &self, src_image: &ImageStore<'_, u8, 4>, dst_image: &mut ImageStoreMut<'_, u8, 4>, order: Ar30ByteOrder, ) -> Result<(), PicScaleError>

Resizes RGBA2101010 image

This method ignores alpha scaling.

§Arguments

src_image - source AR30 image dst_image - destination AR30 image new_size - New image size

Source

pub fn resize_ra30( &self, src_image: &ImageStore<'_, u8, 4>, dst_image: &mut ImageStoreMut<'_, u8, 4>, order: Ar30ByteOrder, ) -> Result<(), PicScaleError>

Resizes RGBA1010102 image

This method ignores alpha scaling.

§Arguments

src_image - source RA30 image dst_image - destination RA30 image

Source§

impl Scaler

Implements f16 type support

Source

pub fn resize_rgba_f16<'a>( &'a self, store: &ImageStore<'a, f16, 4>, into: &mut ImageStoreMut<'a, f16, 4>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Available on crate feature nightly_f16 only.

Performs rescaling for RGBA f16

Scales RGBA high bit-depth interleaved image in f16 type. Channel order does not matter. To handle alpha pre-multiplication alpha channel expected to be at last position.

§Arguments

store - original image store into - target image store premultiply_alpha - flag if it should handle alpha or not

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<f16, 4>::alloc_with_depth(50, 50, 10);
 scaler.resize_rgba_f16(&src_store, &mut dst_store, false).unwrap();
Source

pub fn resize_rgb_f16<'a>( &'a self, store: &ImageStore<'a, f16, 3>, into: &mut ImageStoreMut<'a, f16, 3>, ) -> Result<(), PicScaleError>

Available on crate feature nightly_f16 only.

Performs rescaling for RGB f16

Scales RGB high bit-depth interleaved image in f16 type. Channel order does not matter.

§Arguments

store - original image store into - target image store

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<f16, 3>::alloc_with_depth(50, 50, 10);
 scaler.resize_rgb_f16(&src_store, &mut dst_store).unwrap();
Source

pub fn resize_cbcr_f16<'a>( &'a self, store: &ImageStore<'a, f16, 2>, into: &mut ImageStoreMut<'a, f16, 2>, ) -> Result<(), PicScaleError>

Available on crate feature nightly_f16 only.

Performs rescaling for CbCr f16

Scales CbCr high bit-depth interleaved image in f16 type, optionally it could handle LumaAlpha images also Channel order does not matter.

§Arguments

store - original image store into - target image store

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<f16, 2>::alloc_with_depth(50, 50, 10);
 scaler.resize_cbcr_f16(&src_store, &mut dst_store).unwrap();
Source

pub fn resize_plane_f16<'a>( &'a self, store: &ImageStore<'a, f16, 1>, into: &mut ImageStoreMut<'a, f16, 1>, ) -> Result<(), PicScaleError>

Available on crate feature nightly_f16 only.

Performs rescaling for Planar image f16

Scales planar high bit-depth image in f16 type, optionally it could handle LumaAlpha images also Channel order does not matter.

§Arguments

store - original image store into - target image store

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<f16, 1>::alloc_with_depth(50, 50, 10);
 scaler.resize_plane_f16(&src_store, &mut dst_store).unwrap();

Trait Implementations§

Source§

impl Clone for Scaler

Source§

fn clone(&self) -> Scaler

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 Scaler

Source§

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

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

impl Scaling for Scaler

Source§

fn set_threading_policy(&mut self, threading_policy: ThreadingPolicy)

Sets threading policy Read more
Source§

fn resize_plane<'a>( &'a self, store: &ImageStore<'a, u8, 1>, into: &mut ImageStoreMut<'a, u8, 1>, ) -> Result<(), PicScaleError>

Performs rescaling for planar image Read more
Source§

fn resize_cbcr8<'a>( &'a self, store: &ImageStore<'a, u8, 2>, into: &mut ImageStoreMut<'a, u8, 2>, ) -> Result<(), PicScaleError>

Performs rescaling for CbCr8 ( or 2 interleaved channels ) Read more
Source§

fn resize_gray_alpha<'a>( &'a self, store: &ImageStore<'a, u8, 2>, into: &mut ImageStoreMut<'a, u8, 2>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Performs rescaling for Gray Alpha ( or 2 interleaved channels with aloha ) Read more
Source§

fn resize_rgb<'a>( &'a self, store: &ImageStore<'a, u8, 3>, into: &mut ImageStoreMut<'a, u8, 3>, ) -> Result<(), PicScaleError>

Performs rescaling for RGB, channel order does not matter Read more
Source§

fn resize_rgba<'a>( &'a self, store: &ImageStore<'a, u8, 4>, into: &mut ImageStoreMut<'a, u8, 4>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Performs rescaling for RGBA Read more
Source§

impl ScalingF32 for Scaler

Source§

fn resize_plane_f32<'a>( &'a self, store: &ImageStore<'a, f32, 1>, into: &mut ImageStoreMut<'a, f32, 1>, ) -> Result<(), PicScaleError>

Performs rescaling planar f32 image Read more
Source§

fn resize_cbcr_f32<'a>( &'a self, store: &ImageStore<'a, f32, 2>, into: &mut ImageStoreMut<'a, f32, 2>, ) -> Result<(), PicScaleError>

Performs rescaling for CbCr f32 image Read more
Source§

fn resize_gray_alpha_f32<'a>( &'a self, store: &ImageStore<'a, f32, 2>, into: &mut ImageStoreMut<'a, f32, 2>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Performs rescaling for Gray Alpha f32 image Read more
Source§

fn resize_rgb_f32<'a>( &'a self, store: &ImageStore<'a, f32, 3>, into: &mut ImageStoreMut<'a, f32, 3>, ) -> Result<(), PicScaleError>

Performs rescaling for RGB f32 Read more
Source§

fn resize_rgba_f32<'a>( &'a self, store: &ImageStore<'a, f32, 4>, into: &mut ImageStoreMut<'a, f32, 4>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Performs rescaling for RGBA f32 Read more
Source§

impl ScalingU16 for Scaler

Source§

fn resize_rgb_u16<'a>( &'a self, store: &ImageStore<'a, u16, 3>, into: &mut ImageStoreMut<'a, u16, 3>, ) -> Result<(), PicScaleError>

Performs rescaling for RGB

Scales RGB high bit-depth image stored in u16 type. To perform scaling image bit-depth should be set in target image, source image expects to have the same one. Channel order does not matter.

§Arguments

store - original image store into - target image store

§Panics

Method panics if bit-depth < 1 or bit-depth > 16

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, ScalingU16};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u16, 3>::alloc_with_depth(50, 50, 10);
 scaler.resize_rgb_u16(&src_store, &mut dst_store).unwrap();
Source§

fn resize_rgba_u16<'a>( &'a self, store: &ImageStore<'a, u16, 4>, into: &mut ImageStoreMut<'a, u16, 4>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Resizes u16 image

§Arguments

store - original image store into - target image store premultiply_alpha - flags is alpha is premultiplied

§Panics

Method panics if bit -depth < 1 or bit-depth > 16

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, ScalingU16};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u16, 4>::alloc_with_depth(50, 50, 10);
 scaler.resize_rgba_u16(&src_store, &mut dst_store, true).unwrap();
Source§

fn resize_plane_u16<'a>( &'a self, store: &ImageStore<'a, u16, 1>, into: &mut ImageStoreMut<'a, u16, 1>, ) -> Result<(), PicScaleError>

Performs rescaling for Planar u16

Scales planar high bit-depth image stored in u16 type. To perform scaling image bit-depth should be set in target image, source image expects to have the same one.

§Arguments

store - original image store into - target image store

§Panic

Method panics if bit-depth < 1 or bit-depth > 16

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, ScalingU16};
 let mut scaler = Scaler::new(ResamplingFunction::Lanczos3);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u16, 1>::alloc_with_depth(50, 50, 10);
 scaler.resize_plane_u16(&src_store, &mut dst_store).unwrap();
Source§

fn resize_cbcr_u16<'a>( &'a self, store: &ImageStore<'a, u16, 2>, into: &mut ImageStoreMut<'a, u16, 2>, ) -> Result<(), PicScaleError>

Performs rescaling for CbCr16 Read more
Source§

fn resize_gray_alpha16<'a>( &'a self, store: &ImageStore<'a, u16, 2>, into: &mut ImageStoreMut<'a, u16, 2>, premultiply_alpha: bool, ) -> Result<(), PicScaleError>

Performs rescaling for Gray Alpha high bit-depth ( or 2 interleaved channels with aloha ) Read more
Source§

impl Copy for Scaler

Auto Trait Implementations§

§

impl Freeze for Scaler

§

impl RefUnwindSafe for Scaler

§

impl Send for Scaler

§

impl Sync for Scaler

§

impl Unpin for Scaler

§

impl UnwindSafe for Scaler

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.