VipsInterpolate

Struct VipsInterpolate 

Source
pub struct VipsInterpolate {
    pub c: *mut VipsInterpolate,
    /* private fields */
}
Expand description

VipsInterpolate struct wrapping libvips VipsInterpolate

§Example

use vips::*;

fn main() -> Result<()> {
    let _instance = VipsInstance::new("app_test", true)?;
    let interpolate = VipsInterpolate::bilinear_static();
    let method = interpolate.method();
    let img = VipsImage::from_file("examples/images/kodim01.png")?;
    let region = VipsRegion::new(&img);
    let mut out = vec![0u8; 3]; // assuming 3 channels
    method.call(&interpolate, &region, &mut out, 1.5, 1.5);
    Ok(())
}

Fields§

§c: *mut VipsInterpolate

Implementations§

Source§

impl VipsInterpolate

Source

pub fn new(nickname: &str) -> Result<VipsInterpolate>

Create a new VipsInterpolate by nickname

§Arguments
  • nickname - The nickname of the interpolation method
§Errors

Returns an error if the nickname is invalid

§Example
use vips::*;
fn main() -> Result<()> {
    let _instance = VipsInstance::new("app_test", true)?;
    let interpolate = VipsInterpolate::new("bilinear")?;
    let method = interpolate.method();
    let img = VipsImage::from_file("examples/images/kodim01.png")?;
    let region = VipsRegion::new(&img);
    let mut out = vec![0u8; 3]; // assuming 3 channels
    method.call(&interpolate, &region, &mut out, 1.5, 1.5);
    Ok(())
}
Source

pub fn nearest_static() -> VipsInterpolate

Create a new nearest static VipsInterpolate

§Returns

A VipsInterpolate instance for nearest neighbor interpolation

§Example
use vips::*;
fn main() -> Result<()> {
    let _instance = VipsInstance::new("app_test", true)?;
    let interpolate = VipsInterpolate::nearest_static();
    let method = interpolate.method();
    let img = VipsImage::from_file("examples/images/kodim01.png")?;
    let region = VipsRegion::new(&img);
    let mut out = vec![0u8; 3]; // assuming 3 channels
    method.call(&interpolate, &region, &mut out, 1.5, 1.5);
    Ok(())
}
Source

pub fn bilinear_static() -> VipsInterpolate

Create a new bilinear static VipsInterpolate

§Returns

A VipsInterpolate instance for bilinear interpolation

§Example
use vips::*;

fn main() -> Result<()> {
    let _instance = VipsInstance::new("app_test", true)?;
    let interpolate = VipsInterpolate::bilinear_static();
    let method = interpolate.method();
    let img = VipsImage::from_file("examples/images/kodim01.png")?;
    let region = VipsRegion::new(&img);
    let mut out = vec![0u8; 3]; // assuming 3 channels
    method.call(&interpolate, &region, &mut out, 1.5, 1.5);
    Ok(())
}
Source

pub fn method(&self) -> VipsInterpolateMethod

Get the interpolation method

§Returns

A VipsInterpolateMethod instance representing the interpolation method

§Example
use vips::*;

fn main() -> Result<()> {
    let _instance = VipsInstance::new("app_test", true)?;
    let interpolate = VipsInterpolate::bilinear_static();
    let method = interpolate.method();
    let img = VipsImage::from_file("examples/images/kodim01.png")?;
    let region = VipsRegion::new(&img);
    let mut out = vec![0u8; 3]; // assuming 3 channels
    method.call(&interpolate, &region, &mut out, 1.5, 1.5);
    Ok(())
}
Source

pub fn window_size(&self) -> i32

Get the window size

§Returns

The window size used by the interpolation method

§Example
use vips::*;

fn main() -> Result<()> {
   let interpolate = VipsInterpolate::bilinear_static();
   let window_size = interpolate.window_size();
    println!("Window size: {}", window_size);
    Ok(())
}
Source

pub fn window_offset(&self) -> i32

Get the window offset

§Returns

The window offset used by the interpolation method

§Example
use vips::*;

fn main() -> Result<()> {
    let interpolate = VipsInterpolate::bilinear_static();
    let window_offset = interpolate.window_offset();
    println!("Window offset: {}", window_offset);
    Ok(())
}

Trait Implementations§

Source§

impl Drop for VipsInterpolate

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> 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, 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.