## VipsInterpolate

VipsInterpolate — various interpolators: nearest, bilinear, and some non-linear

## Stability Level

Stable, unless otherwise indicated

## Functions

void | (*VipsInterpolateMethod) ()
void | vips_interpolate ()
VipsInterpolateMethod | vips_interpolate_get_method ()
int | vips_interpolate_get_window_size ()
int | vips_interpolate_get_window_offset ()
VipsInterpolate * | vips_interpolate_nearest_static ()
VipsInterpolate * | vips_interpolate_bilinear_static ()
VipsInterpolate * | vips_interpolate_new ()

## Types and Values

#define | VIPS_TRANSFORM_SHIFT
#define | VIPS_TRANSFORM_SCALE
#define | VIPS_INTERPOLATE_SHIFT
#define | VIPS_INTERPOLATE_SCALE

## Object Hierarchy

        GObject
        ╰── VipsObject
            ╰── VipsInterpolate

## Includes

    #include <vips/vips.h>

## Description

A number of image interpolators.

## Functions

### VipsInterpolateMethod ()

    void
    (*VipsInterpolateMethod) (VipsInterpolate *interpolate,
                              void *out,
                              VipsRegion *in,
                              double x,
                              double y);

An interpolation function. It should read source pixels from `in` with `VIPS_REGION_ADDR()`, it can look left and up from (x, y) by `window_offset` pixels and it can access pixels in a window of size `window_size` .

The interpolated value should be written to the pixel pointed to by `out` .

See also: VipsInterpolateClass.

#### Parameters

interpolate | the interpolator |
out | write the interpolated pixel here |
in | read source pixels from here |
x | interpolate value at this position |
y | interpolate value at this position |

### vips_interpolate ()

    void
    vips_interpolate (VipsInterpolate *interpolate,
                      void *out,
                      VipsRegion *in,
                      double x,
                      double y);

Look up the `interpolate` method in the class and call it. Use `vips_interpolate_get_method()` to get a direct pointer to the function and avoid the lookup overhead.

You need to set `in` and `out` up correctly.

[skip]

#### Parameters

interpolate | interpolator to use |
out | write result here |
in | read source data from here |
x | interpolate value at this position |
y | interpolate value at this position |

### vips_interpolate_get_method ()

    VipsInterpolateMethod
    vips_interpolate_get_method (VipsInterpolate *interpolate);

Look up the `interpolate` method in the class and return it. Use this instead of `vips_interpolate()` to cache method dispatch.

[skip]

#### Parameters

interpolate | interpolator to use |

#### Returns

a pointer to the interpolation function

### vips_interpolate_get_window_size ()

    int
    vips_interpolate_get_window_size (VipsInterpolate *interpolate);

Look up an interpolators desired window size.

#### Parameters

interpolate | interpolator to use |

#### Returns

the interpolators required window size

### vips_interpolate_get_window_offset ()

    int
    vips_interpolate_get_window_offset (VipsInterpolate *interpolate);

Look up an interpolators desired window offset.

#### Parameters

interpolate | interpolator to use |

#### Returns

the interpolators required window offset

### vips_interpolate_nearest_static ()

    VipsInterpolate *
    vips_interpolate_nearest_static (void);

A convenience function that returns a nearest-neighbour interpolator you don't need to free.

#### Returns

a nearest-neighbour interpolator.

[transfer none]

### vips_interpolate_bilinear_static ()

    VipsInterpolate *
    vips_interpolate_bilinear_static (void);

A convenience function that returns a bilinear interpolator you don't need to free.

#### Returns

a bilinear interpolator.

[transfer none]

### vips_interpolate_new ()

    VipsInterpolate *
    vips_interpolate_new (const char *nickname);

Look up an interpolator from a nickname and make one. You need to free the result with `g_object_unref()` when you're done with it.

See also: `vips_type_find()`.

[constructor]

#### Parameters

nickname | nickname for interpolator |

#### Returns

an interpolator, or `NULL` on error.

## Types and Values

### VIPS_TRANSFORM_SHIFT

    #define VIPS_TRANSFORM_SHIFT (6)

Many of the vips interpolators use fixed-point arithmetic for coordinate calculation. This is how many bits of precision they use.

### VIPS_TRANSFORM_SCALE

    #define VIPS_TRANSFORM_SCALE (1 << VIPS_TRANSFORM_SHIFT)

VIPS_TRANSFORM_SHIFT as a multiplicative constant.

### VIPS_INTERPOLATE_SHIFT

    #define VIPS_INTERPOLATE_SHIFT (12)

Many of the vips interpolators use fixed-point arithmetic for value calcualtion. This is how many bits of precision they use.

### VIPS_INTERPOLATE_SCALE

    #define VIPS_INTERPOLATE_SCALE (1 << VIPS_INTERPOLATE_SHIFT)

VIPS_INTERPOLATE_SHIFT as a multiplicative constant.