Scaling

Trait Scaling 

Source
pub trait Scaling {
    // Required methods
    fn set_threading_policy(&mut self, threading_policy: ThreadingPolicy);
    fn resize_plane<'a>(
        &'a self,
        store: &ImageStore<'a, u8, 1>,
        into: &mut ImageStoreMut<'a, u8, 1>,
    ) -> Result<(), PicScaleError>;
    fn resize_cbcr8<'a>(
        &'a self,
        store: &ImageStore<'a, u8, 2>,
        into: &mut ImageStoreMut<'a, u8, 2>,
    ) -> Result<(), PicScaleError>;
    fn resize_gray_alpha<'a>(
        &'a self,
        store: &ImageStore<'a, u8, 2>,
        into: &mut ImageStoreMut<'a, u8, 2>,
        premultiply_alpha: bool,
    ) -> Result<(), PicScaleError>;
    fn resize_rgb<'a>(
        &'a self,
        store: &ImageStore<'a, u8, 3>,
        into: &mut ImageStoreMut<'a, u8, 3>,
    ) -> Result<(), PicScaleError>;
    fn resize_rgba<'a>(
        &'a self,
        store: &ImageStore<'a, u8, 4>,
        into: &mut ImageStoreMut<'a, u8, 4>,
        premultiply_alpha: bool,
    ) -> Result<(), PicScaleError>;
}
Expand description

8 bit-depth images scaling trait

Required Methods§

Source

fn set_threading_policy(&mut self, threading_policy: ThreadingPolicy)

Sets threading policy

Setting up threading policy, refer to crate::ThreadingPolicy for more info

§Example

#[no_build]

use pic_scale::{ResamplingFunction, Scaler, Scaling, ThreadingPolicy};
let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
scaler.set_threading_policy(ThreadingPolicy::Adaptive);
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

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, Scaling};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u8, 1>::alloc(50, 50);
 scaler.resize_plane(&src_store, &mut dst_store).unwrap();
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 )

Scales 2 interleaved channels as CbCr8, optionally it could handle LumaAlpha images also

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, Scaling};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u8, 2>::alloc(50, 50);
 scaler.resize_cbcr8(&src_store, &mut dst_store).unwrap();
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 )

Scales 2 interleaved channels as Gray Alpha

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, Scaling};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u8, 2>::alloc(50, 50);
 scaler.resize_gray_alpha(&src_store, &mut dst_store, true).unwrap();
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

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, Scaling};
 let mut scaler = Scaler::new(ResamplingFunction::Bilinear);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u8, 3>::alloc(50, 50);
 scaler.resize_rgb(&src_store, &mut dst_store).unwrap();
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

This method may premultiply and un associate alpha if required. Alpha position is always considered as last

§Example

#[no_build]

 use pic_scale::{ImageStore, ImageStoreMut, ResamplingFunction, Scaler, Scaling};
 let mut scaler = Scaler::new(ResamplingFunction::Lanczos3);
 let src_store = ImageStore::alloc(100, 100);
 let mut dst_store = ImageStoreMut::<u8, 4>::alloc(50, 50);
 scaler.resize_rgba(&src_store, &mut dst_store, false).unwrap();

Implementors§