libvips/include/vips/interpolate.h

124 lines
3.8 KiB
C
Raw Normal View History

2008-10-16 16:08:12 +02:00
/* Various interpolators.
*
* J.Cupitt, 15/10/08
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifndef VIPS_INTERPOLATE_H
#define VIPS_INTERPOLATE_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
#define VIPS_TYPE_INTERPOLATE (vips_interpolate_get_type())
#define VIPS_INTERPOLATE( obj ) \
(G_TYPE_CHECK_INSTANCE_CAST( (obj), \
VIPS_TYPE_INTERPOLATE, VipsInterpolate ))
#define VIPS_INTERPOLATE_CLASS( klass ) \
(G_TYPE_CHECK_CLASS_CAST( (klass), \
VIPS_TYPE_INTERPOLATE, VipsInterpolateClass))
#define VIPS_IS_INTERPOLATE( obj ) \
(G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_INTERPOLATE ))
#define VIPS_IS_INTERPOLATE_CLASS( klass ) \
(G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_INTERPOLATE ))
#define VIPS_INTERPOLATE_GET_CLASS( obj ) \
(G_TYPE_INSTANCE_GET_CLASS( (obj), \
VIPS_TYPE_INTERPOLATE, VipsInterpolateClass ))
typedef struct _VipsInterpolate {
VipsObject parent_object;
} VipsInterpolate;
2008-10-28 19:17:34 +01:00
/* An interpolation function. This is a class method, but we have a lookup
2008-11-17 23:56:16 +01:00
* function for it to speed up dispatch. Write to the memory at "out",
* interpolate the value at position (x, y) in "in".
2008-10-28 19:17:34 +01:00
*/
typedef void (*VipsInterpolateMethod)( VipsInterpolate *,
2008-11-17 23:56:16 +01:00
PEL *out, REGION *in, double x, double y );
2008-10-28 19:17:34 +01:00
2008-10-16 16:08:12 +02:00
typedef struct _VipsInterpolateClass {
VipsObjectClass parent_class;
/* Write to pixel out(x,y), interpolating from in(x,y). The caller has
* to set the regions up.
*/
2008-11-17 23:56:16 +01:00
VipsInterpolateMethod interpolate;
2008-10-16 16:08:12 +02:00
2008-10-19 22:25:48 +02:00
/* This interpolator needs a window this many pixels across and down.
2008-10-16 16:08:12 +02:00
*/
2008-10-19 22:25:48 +02:00
int (*get_window_size)( VipsInterpolate * );
2008-10-16 16:08:12 +02:00
/* Or just set this if you want a constant.
2008-10-19 22:25:48 +02:00
*/
int window_size;
2008-10-16 16:08:12 +02:00
} VipsInterpolateClass;
2008-10-19 22:25:48 +02:00
GType vips_interpolate_get_type( void );
2008-11-17 23:56:16 +01:00
void vips_interpolate( VipsInterpolate *interpolate,
PEL *out, REGION *in, double x, double y );
2008-10-28 19:17:34 +01:00
VipsInterpolateMethod vips_interpolate_get_method( VipsInterpolate * );
2008-10-19 22:25:48 +02:00
int vips_interpolate_get_window_size( VipsInterpolate *interpolate );
/* How many bits of precision we keep for transformations, ie. how many
* pre-computed matricies we have.
*/
#define VIPS_TRANSFORM_SHIFT (5)
#define VIPS_TRANSFORM_SCALE (1 << VIPS_TRANSFORM_SHIFT)
/* How many bits of precision we keep for interpolation, ie. where the decimal
2008-11-17 23:56:16 +01:00
* is in the fixed-point tables. For 16-bit pixels, we need 16 bits for the
2008-12-15 16:11:54 +01:00
* data and 4 bits to add 16 values together. That leaves 12 bits for the
* fractional part.
2008-10-19 22:25:48 +02:00
*/
2008-12-15 16:11:54 +01:00
#define VIPS_INTERPOLATE_SHIFT (12)
2008-10-19 22:25:48 +02:00
#define VIPS_INTERPOLATE_SCALE (1 << VIPS_INTERPOLATE_SHIFT)
/* Convenience: return static interpolators, no need to unref.
*/
VipsInterpolate *vips_interpolate_nearest_static( void );
VipsInterpolate *vips_interpolate_bilinear_static( void );
VipsInterpolate *vips_interpolate_bicubic_static( void );
2008-10-19 22:25:48 +02:00
/* Convenience: make an interpolator from a nickname. g_object_unref() when
* you're done with it.
*/
VipsInterpolate *vips_interpolate_new( const char *nickname );
2008-10-19 22:25:48 +02:00
/* Register base vips types, called during startup.
2008-10-19 22:25:48 +02:00
*/
void vips__interpolate_init( void );
2008-10-16 16:08:12 +02:00
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_INTERPOLATE_H*/