From eada4a7731e1a67175a674cc976e99a60d305261 Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Tue, 27 Mar 2018 21:15:48 +1100 Subject: [PATCH 1/5] Adds MEAN and MEDIAN methods for region shrink --- libvips/foreign/dzsave.c | 4 +- libvips/foreign/vips2tiff.c | 4 +- libvips/include/vips/region.h | 15 ++-- libvips/iofuncs/region.c | 130 +++++++++++++++++++++++++++------- 4 files changed, 121 insertions(+), 32 deletions(-) diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index 44d3ed82..f9e98fcd 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -1401,10 +1401,10 @@ strip_shrink( Layer *layer ) /* None? All done. */ - if( vips_rect_isempty( &target ) ) + if( vips_rect_isempty( &target ) ) break; - (void) vips_region_shrink( from, to, &target ); + (void) vips_region_shrink( from, to, &target, VIPS_REGION_SHRINK_MEAN ); below->write_y += target.height; diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 1350befe..20fb9e99 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1389,10 +1389,10 @@ layer_strip_shrink( Layer *layer ) /* None? All done. */ - if( vips_rect_isempty( &target ) ) + if( vips_rect_isempty( &target ) ) break; - (void) vips_region_shrink( from, to, &target ); + (void) vips_region_shrink( from, to, &target, VIPS_REGION_SHRINK_MEAN ); below->write_y += target.height; diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index 3d5972c4..a1543abe 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -55,6 +55,12 @@ extern "C" { (G_TYPE_INSTANCE_GET_CLASS( (obj), \ VIPS_TYPE_REGION, VipsRegionClass )) +typedef enum { + VIPS_REGION_SHRINK_MEAN, + VIPS_REGION_SHRINK_MEDIAN, + VIPS_REGION_SHRINK_LAST +} VipsRegionShrink; + /* Sub-area of image. */ typedef struct _VipsRegion { @@ -115,13 +121,14 @@ void vips_region_paint( VipsRegion *reg, const VipsRect *r, int value ); void vips_region_paint_pel( VipsRegion *reg, const VipsRect *r, const VipsPel *ink ); void vips_region_black( VipsRegion *reg ); -void vips_region_copy( VipsRegion *reg, VipsRegion *dest, +void vips_region_copy( VipsRegion *reg, VipsRegion *dest, const VipsRect *r, int x, int y ); -int vips_region_shrink( VipsRegion *from, - VipsRegion *to, const VipsRect *target ); +int vips_region_shrink( VipsRegion *from, + VipsRegion *to, const VipsRect *target, + VipsRegionShrink method ); int vips_region_prepare( VipsRegion *reg, const VipsRect *r ); -int vips_region_prepare_to( VipsRegion *reg, +int vips_region_prepare_to( VipsRegion *reg, VipsRegion *dest, const VipsRect *r, int x, int y ); void vips_region_invalidate( VipsRegion *reg ); diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index 48337d44..8b348e25 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -1166,7 +1166,7 @@ vips_region_shrink_labpack( VipsRegion *from, } } -#define SHRINK_TYPE_INT( TYPE ) \ +#define SHRINK_TYPE_MEAN_INT( TYPE ) \ for( x = 0; x < target->width; x++ ) { \ TYPE *tp = (TYPE *) p; \ TYPE *tp1 = (TYPE *) (p + ls); \ @@ -1185,7 +1185,7 @@ vips_region_shrink_labpack( VipsRegion *from, q += ps; \ } -#define SHRINK_TYPE_FLOAT( TYPE ) \ +#define SHRINK_TYPE_MEAN_FLOAT( TYPE ) \ for( x = 0; x < target->width; x++ ) { \ TYPE *tp = (TYPE *) p; \ TYPE *tp1 = (TYPE *) (p + ls); \ @@ -1204,10 +1204,30 @@ vips_region_shrink_labpack( VipsRegion *from, q += ps; \ } +// This *DOES* gurantee the result is taken from one of the input values +// It therefore does *NOT* interpolate between the two middle values +// It is *NOT* stable with respect to the set of values +// It *IS* however stable with respect to the initial arrangement of values +#define SHRINK_TYPE_MEDIAN( TYPE ) \ + for( x = 0; x < target->width; x++ ) { \ + TYPE *tp = (TYPE *) p; \ + TYPE *tp1 = (TYPE *) (p + ls); \ + TYPE *tq = (TYPE *) q; \ + \ + for( z = 0; z < nb; z++ ) { \ + tq[z] = VIPS_MIN( VIPS_MAX( tp[z], tp[z + nb] ), VIPS_MAX( tp1[z], tp1[z + nb] ) ); \ + } \ + \ + /* Move on two pels in input. \ + */ \ + p += ps << 1; \ + q += ps; \ + } + /* Generate area @target in @to using pixels in @from. Non-complex. */ static void -vips_region_shrink_uncoded( VipsRegion *from, +vips_region_shrink_uncoded_mean( VipsRegion *from, VipsRegion *to, const VipsRect *target ) { int ls = VIPS_REGION_LSKIP( from ); @@ -1225,22 +1245,22 @@ vips_region_shrink_uncoded( VipsRegion *from, /* Process this line of pels. */ switch( from->im->BandFmt ) { - case VIPS_FORMAT_UCHAR: - SHRINK_TYPE_INT( unsigned char ); break; - case VIPS_FORMAT_CHAR: - SHRINK_TYPE_INT( signed char ); break; - case VIPS_FORMAT_USHORT: - SHRINK_TYPE_INT( unsigned short ); break; - case VIPS_FORMAT_SHORT: - SHRINK_TYPE_INT( signed short ); break; - case VIPS_FORMAT_UINT: - SHRINK_TYPE_INT( unsigned int ); break; - case VIPS_FORMAT_INT: - SHRINK_TYPE_INT( signed int ); break; - case VIPS_FORMAT_FLOAT: - SHRINK_TYPE_FLOAT( float ); break; - case VIPS_FORMAT_DOUBLE: - SHRINK_TYPE_FLOAT( double ); break; + case VIPS_FORMAT_UCHAR: + SHRINK_TYPE_MEAN_INT( unsigned char ); break; + case VIPS_FORMAT_CHAR: + SHRINK_TYPE_MEAN_INT( signed char ); break; + case VIPS_FORMAT_USHORT: + SHRINK_TYPE_MEAN_INT( unsigned short ); break; + case VIPS_FORMAT_SHORT: + SHRINK_TYPE_MEAN_INT( signed short ); break; + case VIPS_FORMAT_UINT: + SHRINK_TYPE_MEAN_INT( unsigned int ); break; + case VIPS_FORMAT_INT: + SHRINK_TYPE_MEAN_INT( signed int ); break; + case VIPS_FORMAT_FLOAT: + SHRINK_TYPE_MEAN_FLOAT( float ); break; + case VIPS_FORMAT_DOUBLE: + SHRINK_TYPE_MEAN_FLOAT( double ); break; default: g_assert_not_reached(); @@ -1248,6 +1268,67 @@ vips_region_shrink_uncoded( VipsRegion *from, } } +/* Generate area @target in @to using pixels in @from. Non-complex. + */ +static void +vips_region_shrink_uncoded_median( VipsRegion *from, + VipsRegion *to, const VipsRect *target ) +{ + int ls = VIPS_REGION_LSKIP( from ); + int ps = VIPS_IMAGE_SIZEOF_PEL( from->im ); + int nb = from->im->Bands; + + int x, y, z; + + for( y = 0; y < target->height; y++ ) { + VipsPel *p = VIPS_REGION_ADDR( from, + target->left * 2, (target->top + y) * 2 ); + VipsPel *q = VIPS_REGION_ADDR( to, + target->left, target->top + y ); + + /* Process this line of pels. + */ + switch( from->im->BandFmt ) { + case VIPS_FORMAT_UCHAR: + SHRINK_TYPE_MEDIAN( unsigned char ); break; + case VIPS_FORMAT_CHAR: + SHRINK_TYPE_MEDIAN( signed char ); break; + case VIPS_FORMAT_USHORT: + SHRINK_TYPE_MEDIAN( unsigned short ); break; + case VIPS_FORMAT_SHORT: + SHRINK_TYPE_MEDIAN( signed short ); break; + case VIPS_FORMAT_UINT: + SHRINK_TYPE_MEDIAN( unsigned int ); break; + case VIPS_FORMAT_INT: + SHRINK_TYPE_MEDIAN( signed int ); break; + case VIPS_FORMAT_FLOAT: + SHRINK_TYPE_MEDIAN( float ); break; + case VIPS_FORMAT_DOUBLE: + SHRINK_TYPE_MEDIAN( double ); break; + + default: + g_assert_not_reached(); + } + } +} + +/* Generate area @target in @to using pixels in @from. Non-complex. + */ +static void +vips_region_shrink_uncoded( VipsRegion *from, + VipsRegion *to, const VipsRect *target, VipsRegionShrink method ) +{ + switch( method ) { + case VIPS_REGION_SHRINK_MEAN: + vips_region_shrink_uncoded_mean( from, to, target ); break; + case VIPS_REGION_SHRINK_MEDIAN: + vips_region_shrink_uncoded_median( from, to, target ); break; + + default: + g_assert_not_reached(); + } +} + /* No point having an int path, this will always be horribly slow. */ #define SHRINK_ALPHA_TYPE( TYPE ) { \ @@ -1333,9 +1414,10 @@ vips_region_shrink_alpha( VipsRegion *from, /** * vips_region_shrink: - * @from: source region - * @to: (inout): destination region + * @from: source region + * @to: (inout): destination region * @target: #VipsRect of pixels you need to copy + * @method: #VipsRegionShrink method to use when generating target pixels * * Write the pixels @target in @to from the x2 larger area in @from. * Non-complex uncoded images and LABQ only. Images with alpha (see @@ -1344,7 +1426,7 @@ vips_region_shrink_alpha( VipsRegion *from, * See also: vips_region_copy(). */ int -vips_region_shrink( VipsRegion *from, VipsRegion *to, const VipsRect *target ) +vips_region_shrink( VipsRegion *from, VipsRegion *to, const VipsRect *target, VipsRegionShrink method ) { VipsImage *image = from->im; @@ -1355,10 +1437,10 @@ vips_region_shrink( VipsRegion *from, VipsRegion *to, const VipsRect *target ) if( vips_check_noncomplex( "vips_region_shrink", image ) ) return( -1 ); - if( vips_image_hasalpha( image ) ) + if( vips_image_hasalpha( image ) ) vips_region_shrink_alpha( from, to, target ); else - vips_region_shrink_uncoded( from, to, target ); + vips_region_shrink_uncoded( from, to, target, method ); } else vips_region_shrink_labpack( from, to, target ); From 442f4e55c9450400e9853d4c828974791a8ad4a8 Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Tue, 27 Mar 2018 21:27:24 +1100 Subject: [PATCH 2/5] Fix line lengths --- libvips/foreign/dzsave.c | 3 ++- libvips/foreign/vips2tiff.c | 3 ++- libvips/iofuncs/region.c | 28 ++++++++++++++++++++-------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index f9e98fcd..d0982fd6 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -1404,7 +1404,8 @@ strip_shrink( Layer *layer ) if( vips_rect_isempty( &target ) ) break; - (void) vips_region_shrink( from, to, &target, VIPS_REGION_SHRINK_MEAN ); + (void) vips_region_shrink( from, to, &target, + VIPS_REGION_SHRINK_MEAN ); below->write_y += target.height; diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 20fb9e99..d1220821 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1392,7 +1392,8 @@ layer_strip_shrink( Layer *layer ) if( vips_rect_isempty( &target ) ) break; - (void) vips_region_shrink( from, to, &target, VIPS_REGION_SHRINK_MEAN ); + (void) vips_region_shrink( from, to, &target, + VIPS_REGION_SHRINK_MEAN ); below->write_y += target.height; diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index 8b348e25..ce8ec437 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -1204,10 +1204,16 @@ vips_region_shrink_labpack( VipsRegion *from, q += ps; \ } -// This *DOES* gurantee the result is taken from one of the input values -// It therefore does *NOT* interpolate between the two middle values -// It is *NOT* stable with respect to the set of values -// It *IS* however stable with respect to the initial arrangement of values +/* This method is implemented so as to perform well and to always select an + * output pixel from one of the input pixels. As such we make only the + * following guarantees: + * + * ONLY works for non-complex uncoded images pixel types + * ALWAYS draws from the input values + * NEVER interpolates + * NOT stable with respect to the ordered set of input values + * IS stable with respect to the initial arrangement of input values + */ #define SHRINK_TYPE_MEDIAN( TYPE ) \ for( x = 0; x < target->width; x++ ) { \ TYPE *tp = (TYPE *) p; \ @@ -1215,7 +1221,10 @@ vips_region_shrink_labpack( VipsRegion *from, TYPE *tq = (TYPE *) q; \ \ for( z = 0; z < nb; z++ ) { \ - tq[z] = VIPS_MIN( VIPS_MAX( tp[z], tp[z + nb] ), VIPS_MAX( tp1[z], tp1[z + nb] ) ); \ + tq[z] = VIPS_MIN( \ + VIPS_MAX( tp[z], tp[z + nb] ), \ + VIPS_MAX( tp1[z], tp1[z + nb] ) \ + ); \ } \ \ /* Move on two pels in input. \ @@ -1320,9 +1329,11 @@ vips_region_shrink_uncoded( VipsRegion *from, { switch( method ) { case VIPS_REGION_SHRINK_MEAN: - vips_region_shrink_uncoded_mean( from, to, target ); break; + vips_region_shrink_uncoded_mean( from, to, target ); + break; case VIPS_REGION_SHRINK_MEDIAN: - vips_region_shrink_uncoded_median( from, to, target ); break; + vips_region_shrink_uncoded_median( from, to, target ); + break; default: g_assert_not_reached(); @@ -1426,7 +1437,8 @@ vips_region_shrink_alpha( VipsRegion *from, * See also: vips_region_copy(). */ int -vips_region_shrink( VipsRegion *from, VipsRegion *to, const VipsRect *target, VipsRegionShrink method ) +vips_region_shrink( VipsRegion *from, VipsRegion *to, const VipsRect *target, + VipsRegionShrink method ) { VipsImage *image = from->im; From 36076f82942d12430f10cc5706912e194318a1ba Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Wed, 28 Mar 2018 07:35:49 +1100 Subject: [PATCH 3/5] Adds VipsRegionShrink type --- libvips/foreign/dzsave.c | 15 + libvips/include/vips/Makefile.am | 3 +- libvips/include/vips/enumtypes.h | 123 ++-- libvips/include/vips/region.h | 7 + libvips/iofuncs/Makefile.am | 3 +- libvips/iofuncs/enumtypes.c | 1035 +++++++++++++++--------------- 6 files changed, 616 insertions(+), 570 deletions(-) diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index d0982fd6..36fe02e3 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -447,6 +447,7 @@ struct _VipsForeignSaveDz { VipsAngle angle; VipsForeignDzContainer container; int compression; + VipsRegionShrink region_shrink; /* Tile and overlap geometry. The members above are the parameters we * accept, this next set are the derived values which are actually @@ -2099,6 +2100,14 @@ vips_foreign_save_dz_class_init( VipsForeignSaveDzClass *class ) G_STRUCT_OFFSET( VipsForeignSaveDz, compression ), -1, 9, 0 ); + VIPS_ARG_ENUM( class, "region_shrink", 18, + _( "Region shrink" ), + _( "Method for blah" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsForeignSaveDz, region_shrink ), + VIPS_TYPE_REGION_SHRINK, + VIPS_REGION_SHRINK_MEAN ); + /* How annoying. We stupidly had these in earlier versions. */ @@ -2137,6 +2146,7 @@ vips_foreign_save_dz_init( VipsForeignSaveDz *dz ) dz->angle = VIPS_ANGLE_D0; dz->container = VIPS_FOREIGN_DZ_CONTAINER_FS; dz->compression = 0; + dz->region_shrink = VIPS_REGION_SHRINK_MEAN; } typedef struct _VipsForeignSaveDzFile { @@ -2333,6 +2343,7 @@ vips_foreign_save_dz_buffer_init( VipsForeignSaveDzBuffer *buffer ) * * @container: #VipsForeignDzContainer set container type * * @properties: %gboolean write a properties file * * @compression: %gint zip deflate compression level + * * @shrink_region: #VipsRegionShrink How to shrink each 2x2 region. * * Save an image as a set of tiles at various resolutions. By default dzsave * uses DeepZoom layout -- use @layout to pick other conventions. @@ -2370,6 +2381,10 @@ vips_foreign_save_dz_buffer_init( VipsForeignSaveDzBuffer *buffer ) * (use zlib default), 0 (store, compression disabled) to 9 (max compression). * If no value is given, the default is to store files without compression. * + * You can use @region_shrink to control the method for shrinking each 2x2 + * region. This defaults to using the average of the 4 input pixels but you can + * also use the median in cases where you want to preseve the range of values. + * * See also: vips_tiffsave(). * * Returns: 0 on success, -1 on error. diff --git a/libvips/include/vips/Makefile.am b/libvips/include/vips/Makefile.am index 636b33a3..6d296905 100644 --- a/libvips/include/vips/Makefile.am +++ b/libvips/include/vips/Makefile.am @@ -72,7 +72,8 @@ vips_scan_headers = \ ${top_srcdir}/libvips/include/vips/morphology.h \ ${top_srcdir}/libvips/include/vips/draw.h \ ${top_srcdir}/libvips/include/vips/basic.h \ - ${top_srcdir}/libvips/include/vips/object.h + ${top_srcdir}/libvips/include/vips/object.h \ + ${top_srcdir}/libvips/include/vips/region.h enumtypes.h: $(vips_scan_headers) Makefile.am glib-mkenums --template enumtemplate $(vips_scan_headers) > enumtypes.h diff --git a/libvips/include/vips/enumtypes.h b/libvips/include/vips/enumtypes.h index 339f3d22..87cea5fd 100644 --- a/libvips/include/vips/enumtypes.h +++ b/libvips/include/vips/enumtypes.h @@ -1,15 +1,58 @@ -/* Generated data (by glib-mkenums) */ +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ #ifndef VIPS_ENUM_TYPES_H #define VIPS_ENUM_TYPES_H G_BEGIN_DECLS -/* enumerations from "../../../libvips/include/vips/resample.h" */ -GType vips_kernel_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_KERNEL (vips_kernel_get_type()) -GType vips_size_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_SIZE (vips_size_get_type()) +/* enumerations from "../../../libvips/include/vips/arithmetic.h" */ +GType vips_operation_math_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_MATH (vips_operation_math_get_type()) +GType vips_operation_math2_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_MATH2 (vips_operation_math2_get_type()) +GType vips_operation_round_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_ROUND (vips_operation_round_get_type()) +GType vips_operation_relational_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_RELATIONAL (vips_operation_relational_get_type()) +GType vips_operation_boolean_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_BOOLEAN (vips_operation_boolean_get_type()) +GType vips_operation_complex_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_COMPLEX (vips_operation_complex_get_type()) +GType vips_operation_complex2_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_COMPLEX2 (vips_operation_complex2_get_type()) +GType vips_operation_complexget_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_COMPLEXGET (vips_operation_complexget_get_type()) +/* enumerations from "../../../libvips/include/vips/basic.h" */ +GType vips_precision_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_PRECISION (vips_precision_get_type()) +/* enumerations from "../../../libvips/include/vips/colour.h" */ +GType vips_intent_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_INTENT (vips_intent_get_type()) +GType vips_pcs_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_PCS (vips_pcs_get_type()) +/* enumerations from "../../../libvips/include/vips/conversion.h" */ +GType vips_extend_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_EXTEND (vips_extend_get_type()) +GType vips_compass_direction_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_COMPASS_DIRECTION (vips_compass_direction_get_type()) +GType vips_direction_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_DIRECTION (vips_direction_get_type()) +GType vips_align_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_ALIGN (vips_align_get_type()) +GType vips_angle_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_ANGLE (vips_angle_get_type()) +GType vips_angle45_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_ANGLE45 (vips_angle45_get_type()) +GType vips_interesting_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_INTERESTING (vips_interesting_get_type()) +GType vips_blend_mode_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_BLEND_MODE (vips_blend_mode_get_type()) +/* enumerations from "../../../libvips/include/vips/convolution.h" */ +GType vips_combine_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_COMBINE (vips_combine_get_type()) +/* enumerations from "../../../libvips/include/vips/draw.h" */ +GType vips_combine_mode_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_COMBINE_MODE (vips_combine_mode_get_type()) /* enumerations from "../../../libvips/include/vips/foreign.h" */ GType vips_foreign_flags_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_FOREIGN_FLAGS (vips_foreign_flags_get_type()) @@ -31,43 +74,6 @@ GType vips_foreign_dz_depth_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_FOREIGN_DZ_DEPTH (vips_foreign_dz_depth_get_type()) GType vips_foreign_dz_container_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_FOREIGN_DZ_CONTAINER (vips_foreign_dz_container_get_type()) -/* enumerations from "../../../libvips/include/vips/arithmetic.h" */ -GType vips_operation_math_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_MATH (vips_operation_math_get_type()) -GType vips_operation_math2_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_MATH2 (vips_operation_math2_get_type()) -GType vips_operation_round_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_ROUND (vips_operation_round_get_type()) -GType vips_operation_relational_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_RELATIONAL (vips_operation_relational_get_type()) -GType vips_operation_boolean_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_BOOLEAN (vips_operation_boolean_get_type()) -GType vips_operation_complex_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_COMPLEX (vips_operation_complex_get_type()) -GType vips_operation_complex2_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_COMPLEX2 (vips_operation_complex2_get_type()) -GType vips_operation_complexget_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_COMPLEXGET (vips_operation_complexget_get_type()) -/* enumerations from "../../../libvips/include/vips/conversion.h" */ -GType vips_extend_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_EXTEND (vips_extend_get_type()) -GType vips_compass_direction_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_COMPASS_DIRECTION (vips_compass_direction_get_type()) -GType vips_direction_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_DIRECTION (vips_direction_get_type()) -GType vips_align_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_ALIGN (vips_align_get_type()) -GType vips_angle_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_ANGLE (vips_angle_get_type()) -GType vips_angle45_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_ANGLE45 (vips_angle45_get_type()) -GType vips_interesting_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_INTERESTING (vips_interesting_get_type()) -GType vips_blend_mode_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_BLEND_MODE (vips_blend_mode_get_type()) -/* enumerations from "../../../libvips/include/vips/util.h" */ -GType vips_token_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_TOKEN (vips_token_get_type()) /* enumerations from "../../../libvips/include/vips/image.h" */ GType vips_demand_style_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_DEMAND_STYLE (vips_demand_style_get_type()) @@ -81,29 +87,26 @@ GType vips_coding_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_CODING (vips_coding_get_type()) GType vips_access_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_ACCESS (vips_access_get_type()) -/* enumerations from "../../../libvips/include/vips/colour.h" */ -GType vips_intent_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_INTENT (vips_intent_get_type()) -GType vips_pcs_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_PCS (vips_pcs_get_type()) -/* enumerations from "../../../libvips/include/vips/operation.h" */ -GType vips_operation_flags_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_OPERATION_FLAGS (vips_operation_flags_get_type()) -/* enumerations from "../../../libvips/include/vips/convolution.h" */ -GType vips_combine_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_COMBINE (vips_combine_get_type()) /* enumerations from "../../../libvips/include/vips/morphology.h" */ GType vips_operation_morphology_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_OPERATION_MORPHOLOGY (vips_operation_morphology_get_type()) -/* enumerations from "../../../libvips/include/vips/draw.h" */ -GType vips_combine_mode_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_COMBINE_MODE (vips_combine_mode_get_type()) -/* enumerations from "../../../libvips/include/vips/basic.h" */ -GType vips_precision_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_PRECISION (vips_precision_get_type()) /* enumerations from "../../../libvips/include/vips/object.h" */ GType vips_argument_flags_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_ARGUMENT_FLAGS (vips_argument_flags_get_type()) +/* enumerations from "../../../libvips/include/vips/operation.h" */ +GType vips_operation_flags_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_OPERATION_FLAGS (vips_operation_flags_get_type()) +/* enumerations from "../../../libvips/include/vips/region.h" */ +GType vips_region_shrink_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_REGION_SHRINK (vips_region_shrink_get_type()) +/* enumerations from "../../../libvips/include/vips/resample.h" */ +GType vips_kernel_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_KERNEL (vips_kernel_get_type()) +GType vips_size_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_SIZE (vips_size_get_type()) +/* enumerations from "../../../libvips/include/vips/util.h" */ +GType vips_token_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_TOKEN (vips_token_get_type()) G_END_DECLS #endif /*VIPS_ENUM_TYPES_H*/ diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index a1543abe..b5362e16 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -55,6 +55,13 @@ extern "C" { (G_TYPE_INSTANCE_GET_CLASS( (obj), \ VIPS_TYPE_REGION, VipsRegionClass )) +/** + * VipsRegionShrink: + * @VIPS_REGION_SHRINK_MEAN: use the average + * @VIPS_REGION_SHRINK_MEDIAN: use the median + * + * How to calculate the output pixels when shrinking a 2x2 region. + */ typedef enum { VIPS_REGION_SHRINK_MEAN, VIPS_REGION_SHRINK_MEDIAN, diff --git a/libvips/iofuncs/Makefile.am b/libvips/iofuncs/Makefile.am index 7e57b716..76115ba8 100644 --- a/libvips/iofuncs/Makefile.am +++ b/libvips/iofuncs/Makefile.am @@ -70,7 +70,8 @@ vips_scan_headers = \ ${top_srcdir}/libvips/include/vips/morphology.h \ ${top_srcdir}/libvips/include/vips/draw.h \ ${top_srcdir}/libvips/include/vips/basic.h \ - ${top_srcdir}/libvips/include/vips/object.h + ${top_srcdir}/libvips/include/vips/object.h \ + ${top_srcdir}/libvips/include/vips/region.h enumtypes.c: $(vips_scan_headers) Makefile.am glib-mkenums --template enumtemplate $(vips_scan_headers) > enumtypes.c diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 805045ad..c50d040e 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -1,47 +1,454 @@ -/* Generated data (by glib-mkenums) */ +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ /* auto-generated enums for vips introspection */ #include -/* enumerations from "../../libvips/include/vips/resample.h" */ +/* enumerations from "../../libvips/include/vips/arithmetic.h" */ GType -vips_kernel_get_type( void ) +vips_operation_math_get_type( void ) { static GType etype = 0; if( etype == 0 ) { static const GEnumValue values[] = { - {VIPS_KERNEL_NEAREST, "VIPS_KERNEL_NEAREST", "nearest"}, - {VIPS_KERNEL_LINEAR, "VIPS_KERNEL_LINEAR", "linear"}, - {VIPS_KERNEL_CUBIC, "VIPS_KERNEL_CUBIC", "cubic"}, - {VIPS_KERNEL_LANCZOS2, "VIPS_KERNEL_LANCZOS2", "lanczos2"}, - {VIPS_KERNEL_LANCZOS3, "VIPS_KERNEL_LANCZOS3", "lanczos3"}, - {VIPS_KERNEL_LAST, "VIPS_KERNEL_LAST", "last"}, + {VIPS_OPERATION_MATH_SIN, "VIPS_OPERATION_MATH_SIN", "sin"}, + {VIPS_OPERATION_MATH_COS, "VIPS_OPERATION_MATH_COS", "cos"}, + {VIPS_OPERATION_MATH_TAN, "VIPS_OPERATION_MATH_TAN", "tan"}, + {VIPS_OPERATION_MATH_ASIN, "VIPS_OPERATION_MATH_ASIN", "asin"}, + {VIPS_OPERATION_MATH_ACOS, "VIPS_OPERATION_MATH_ACOS", "acos"}, + {VIPS_OPERATION_MATH_ATAN, "VIPS_OPERATION_MATH_ATAN", "atan"}, + {VIPS_OPERATION_MATH_LOG, "VIPS_OPERATION_MATH_LOG", "log"}, + {VIPS_OPERATION_MATH_LOG10, "VIPS_OPERATION_MATH_LOG10", "log10"}, + {VIPS_OPERATION_MATH_EXP, "VIPS_OPERATION_MATH_EXP", "exp"}, + {VIPS_OPERATION_MATH_EXP10, "VIPS_OPERATION_MATH_EXP10", "exp10"}, + {VIPS_OPERATION_MATH_LAST, "VIPS_OPERATION_MATH_LAST", "last"}, {0, NULL, NULL} }; - etype = g_enum_register_static( "VipsKernel", values ); + etype = g_enum_register_static( "VipsOperationMath", values ); } return( etype ); } GType -vips_size_get_type( void ) +vips_operation_math2_get_type( void ) { static GType etype = 0; if( etype == 0 ) { static const GEnumValue values[] = { - {VIPS_SIZE_BOTH, "VIPS_SIZE_BOTH", "both"}, - {VIPS_SIZE_UP, "VIPS_SIZE_UP", "up"}, - {VIPS_SIZE_DOWN, "VIPS_SIZE_DOWN", "down"}, - {VIPS_SIZE_FORCE, "VIPS_SIZE_FORCE", "force"}, - {VIPS_SIZE_LAST, "VIPS_SIZE_LAST", "last"}, + {VIPS_OPERATION_MATH2_POW, "VIPS_OPERATION_MATH2_POW", "pow"}, + {VIPS_OPERATION_MATH2_WOP, "VIPS_OPERATION_MATH2_WOP", "wop"}, + {VIPS_OPERATION_MATH2_LAST, "VIPS_OPERATION_MATH2_LAST", "last"}, {0, NULL, NULL} }; - etype = g_enum_register_static( "VipsSize", values ); + etype = g_enum_register_static( "VipsOperationMath2", values ); + } + + return( etype ); +} +GType +vips_operation_round_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_OPERATION_ROUND_RINT, "VIPS_OPERATION_ROUND_RINT", "rint"}, + {VIPS_OPERATION_ROUND_CEIL, "VIPS_OPERATION_ROUND_CEIL", "ceil"}, + {VIPS_OPERATION_ROUND_FLOOR, "VIPS_OPERATION_ROUND_FLOOR", "floor"}, + {VIPS_OPERATION_ROUND_LAST, "VIPS_OPERATION_ROUND_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsOperationRound", values ); + } + + return( etype ); +} +GType +vips_operation_relational_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_OPERATION_RELATIONAL_EQUAL, "VIPS_OPERATION_RELATIONAL_EQUAL", "equal"}, + {VIPS_OPERATION_RELATIONAL_NOTEQ, "VIPS_OPERATION_RELATIONAL_NOTEQ", "noteq"}, + {VIPS_OPERATION_RELATIONAL_LESS, "VIPS_OPERATION_RELATIONAL_LESS", "less"}, + {VIPS_OPERATION_RELATIONAL_LESSEQ, "VIPS_OPERATION_RELATIONAL_LESSEQ", "lesseq"}, + {VIPS_OPERATION_RELATIONAL_MORE, "VIPS_OPERATION_RELATIONAL_MORE", "more"}, + {VIPS_OPERATION_RELATIONAL_MOREEQ, "VIPS_OPERATION_RELATIONAL_MOREEQ", "moreeq"}, + {VIPS_OPERATION_RELATIONAL_LAST, "VIPS_OPERATION_RELATIONAL_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsOperationRelational", values ); + } + + return( etype ); +} +GType +vips_operation_boolean_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_OPERATION_BOOLEAN_AND, "VIPS_OPERATION_BOOLEAN_AND", "and"}, + {VIPS_OPERATION_BOOLEAN_OR, "VIPS_OPERATION_BOOLEAN_OR", "or"}, + {VIPS_OPERATION_BOOLEAN_EOR, "VIPS_OPERATION_BOOLEAN_EOR", "eor"}, + {VIPS_OPERATION_BOOLEAN_LSHIFT, "VIPS_OPERATION_BOOLEAN_LSHIFT", "lshift"}, + {VIPS_OPERATION_BOOLEAN_RSHIFT, "VIPS_OPERATION_BOOLEAN_RSHIFT", "rshift"}, + {VIPS_OPERATION_BOOLEAN_LAST, "VIPS_OPERATION_BOOLEAN_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsOperationBoolean", values ); + } + + return( etype ); +} +GType +vips_operation_complex_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_OPERATION_COMPLEX_POLAR, "VIPS_OPERATION_COMPLEX_POLAR", "polar"}, + {VIPS_OPERATION_COMPLEX_RECT, "VIPS_OPERATION_COMPLEX_RECT", "rect"}, + {VIPS_OPERATION_COMPLEX_CONJ, "VIPS_OPERATION_COMPLEX_CONJ", "conj"}, + {VIPS_OPERATION_COMPLEX_LAST, "VIPS_OPERATION_COMPLEX_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsOperationComplex", values ); + } + + return( etype ); +} +GType +vips_operation_complex2_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_OPERATION_COMPLEX2_CROSS_PHASE, "VIPS_OPERATION_COMPLEX2_CROSS_PHASE", "cross-phase"}, + {VIPS_OPERATION_COMPLEX2_LAST, "VIPS_OPERATION_COMPLEX2_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsOperationComplex2", values ); + } + + return( etype ); +} +GType +vips_operation_complexget_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_OPERATION_COMPLEXGET_REAL, "VIPS_OPERATION_COMPLEXGET_REAL", "real"}, + {VIPS_OPERATION_COMPLEXGET_IMAG, "VIPS_OPERATION_COMPLEXGET_IMAG", "imag"}, + {VIPS_OPERATION_COMPLEXGET_LAST, "VIPS_OPERATION_COMPLEXGET_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsOperationComplexget", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/basic.h" */ +GType +vips_precision_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_PRECISION_INTEGER, "VIPS_PRECISION_INTEGER", "integer"}, + {VIPS_PRECISION_FLOAT, "VIPS_PRECISION_FLOAT", "float"}, + {VIPS_PRECISION_APPROXIMATE, "VIPS_PRECISION_APPROXIMATE", "approximate"}, + {VIPS_PRECISION_LAST, "VIPS_PRECISION_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsPrecision", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/colour.h" */ +GType +vips_intent_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_INTENT_PERCEPTUAL, "VIPS_INTENT_PERCEPTUAL", "perceptual"}, + {VIPS_INTENT_RELATIVE, "VIPS_INTENT_RELATIVE", "relative"}, + {VIPS_INTENT_SATURATION, "VIPS_INTENT_SATURATION", "saturation"}, + {VIPS_INTENT_ABSOLUTE, "VIPS_INTENT_ABSOLUTE", "absolute"}, + {VIPS_INTENT_LAST, "VIPS_INTENT_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsIntent", values ); + } + + return( etype ); +} +GType +vips_pcs_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_PCS_LAB, "VIPS_PCS_LAB", "lab"}, + {VIPS_PCS_XYZ, "VIPS_PCS_XYZ", "xyz"}, + {VIPS_PCS_LAST, "VIPS_PCS_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsPCS", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/conversion.h" */ +GType +vips_extend_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_EXTEND_BLACK, "VIPS_EXTEND_BLACK", "black"}, + {VIPS_EXTEND_COPY, "VIPS_EXTEND_COPY", "copy"}, + {VIPS_EXTEND_REPEAT, "VIPS_EXTEND_REPEAT", "repeat"}, + {VIPS_EXTEND_MIRROR, "VIPS_EXTEND_MIRROR", "mirror"}, + {VIPS_EXTEND_WHITE, "VIPS_EXTEND_WHITE", "white"}, + {VIPS_EXTEND_BACKGROUND, "VIPS_EXTEND_BACKGROUND", "background"}, + {VIPS_EXTEND_LAST, "VIPS_EXTEND_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsExtend", values ); + } + + return( etype ); +} +GType +vips_compass_direction_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_COMPASS_DIRECTION_CENTRE, "VIPS_COMPASS_DIRECTION_CENTRE", "centre"}, + {VIPS_COMPASS_DIRECTION_NORTH, "VIPS_COMPASS_DIRECTION_NORTH", "north"}, + {VIPS_COMPASS_DIRECTION_EAST, "VIPS_COMPASS_DIRECTION_EAST", "east"}, + {VIPS_COMPASS_DIRECTION_SOUTH, "VIPS_COMPASS_DIRECTION_SOUTH", "south"}, + {VIPS_COMPASS_DIRECTION_WEST, "VIPS_COMPASS_DIRECTION_WEST", "west"}, + {VIPS_COMPASS_DIRECTION_NORTH_EAST, "VIPS_COMPASS_DIRECTION_NORTH_EAST", "north-east"}, + {VIPS_COMPASS_DIRECTION_SOUTH_EAST, "VIPS_COMPASS_DIRECTION_SOUTH_EAST", "south-east"}, + {VIPS_COMPASS_DIRECTION_SOUTH_WEST, "VIPS_COMPASS_DIRECTION_SOUTH_WEST", "south-west"}, + {VIPS_COMPASS_DIRECTION_NORTH_WEST, "VIPS_COMPASS_DIRECTION_NORTH_WEST", "north-west"}, + {VIPS_COMPASS_DIRECTION_LAST, "VIPS_COMPASS_DIRECTION_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsCompassDirection", values ); + } + + return( etype ); +} +GType +vips_direction_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_DIRECTION_HORIZONTAL, "VIPS_DIRECTION_HORIZONTAL", "horizontal"}, + {VIPS_DIRECTION_VERTICAL, "VIPS_DIRECTION_VERTICAL", "vertical"}, + {VIPS_DIRECTION_LAST, "VIPS_DIRECTION_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsDirection", values ); + } + + return( etype ); +} +GType +vips_align_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_ALIGN_LOW, "VIPS_ALIGN_LOW", "low"}, + {VIPS_ALIGN_CENTRE, "VIPS_ALIGN_CENTRE", "centre"}, + {VIPS_ALIGN_HIGH, "VIPS_ALIGN_HIGH", "high"}, + {VIPS_ALIGN_LAST, "VIPS_ALIGN_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsAlign", values ); + } + + return( etype ); +} +GType +vips_angle_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_ANGLE_D0, "VIPS_ANGLE_D0", "d0"}, + {VIPS_ANGLE_D90, "VIPS_ANGLE_D90", "d90"}, + {VIPS_ANGLE_D180, "VIPS_ANGLE_D180", "d180"}, + {VIPS_ANGLE_D270, "VIPS_ANGLE_D270", "d270"}, + {VIPS_ANGLE_LAST, "VIPS_ANGLE_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsAngle", values ); + } + + return( etype ); +} +GType +vips_angle45_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_ANGLE45_D0, "VIPS_ANGLE45_D0", "d0"}, + {VIPS_ANGLE45_D45, "VIPS_ANGLE45_D45", "d45"}, + {VIPS_ANGLE45_D90, "VIPS_ANGLE45_D90", "d90"}, + {VIPS_ANGLE45_D135, "VIPS_ANGLE45_D135", "d135"}, + {VIPS_ANGLE45_D180, "VIPS_ANGLE45_D180", "d180"}, + {VIPS_ANGLE45_D225, "VIPS_ANGLE45_D225", "d225"}, + {VIPS_ANGLE45_D270, "VIPS_ANGLE45_D270", "d270"}, + {VIPS_ANGLE45_D315, "VIPS_ANGLE45_D315", "d315"}, + {VIPS_ANGLE45_LAST, "VIPS_ANGLE45_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsAngle45", values ); + } + + return( etype ); +} +GType +vips_interesting_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_INTERESTING_NONE, "VIPS_INTERESTING_NONE", "none"}, + {VIPS_INTERESTING_CENTRE, "VIPS_INTERESTING_CENTRE", "centre"}, + {VIPS_INTERESTING_ENTROPY, "VIPS_INTERESTING_ENTROPY", "entropy"}, + {VIPS_INTERESTING_ATTENTION, "VIPS_INTERESTING_ATTENTION", "attention"}, + {VIPS_INTERESTING_LAST, "VIPS_INTERESTING_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsInteresting", values ); + } + + return( etype ); +} +GType +vips_blend_mode_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_BLEND_MODE_CLEAR, "VIPS_BLEND_MODE_CLEAR", "clear"}, + {VIPS_BLEND_MODE_SOURCE, "VIPS_BLEND_MODE_SOURCE", "source"}, + {VIPS_BLEND_MODE_OVER, "VIPS_BLEND_MODE_OVER", "over"}, + {VIPS_BLEND_MODE_IN, "VIPS_BLEND_MODE_IN", "in"}, + {VIPS_BLEND_MODE_OUT, "VIPS_BLEND_MODE_OUT", "out"}, + {VIPS_BLEND_MODE_ATOP, "VIPS_BLEND_MODE_ATOP", "atop"}, + {VIPS_BLEND_MODE_DEST, "VIPS_BLEND_MODE_DEST", "dest"}, + {VIPS_BLEND_MODE_DEST_OVER, "VIPS_BLEND_MODE_DEST_OVER", "dest-over"}, + {VIPS_BLEND_MODE_DEST_IN, "VIPS_BLEND_MODE_DEST_IN", "dest-in"}, + {VIPS_BLEND_MODE_DEST_OUT, "VIPS_BLEND_MODE_DEST_OUT", "dest-out"}, + {VIPS_BLEND_MODE_DEST_ATOP, "VIPS_BLEND_MODE_DEST_ATOP", "dest-atop"}, + {VIPS_BLEND_MODE_XOR, "VIPS_BLEND_MODE_XOR", "xor"}, + {VIPS_BLEND_MODE_ADD, "VIPS_BLEND_MODE_ADD", "add"}, + {VIPS_BLEND_MODE_SATURATE, "VIPS_BLEND_MODE_SATURATE", "saturate"}, + {VIPS_BLEND_MODE_MULTIPLY, "VIPS_BLEND_MODE_MULTIPLY", "multiply"}, + {VIPS_BLEND_MODE_SCREEN, "VIPS_BLEND_MODE_SCREEN", "screen"}, + {VIPS_BLEND_MODE_OVERLAY, "VIPS_BLEND_MODE_OVERLAY", "overlay"}, + {VIPS_BLEND_MODE_DARKEN, "VIPS_BLEND_MODE_DARKEN", "darken"}, + {VIPS_BLEND_MODE_LIGHTEN, "VIPS_BLEND_MODE_LIGHTEN", "lighten"}, + {VIPS_BLEND_MODE_COLOUR_DODGE, "VIPS_BLEND_MODE_COLOUR_DODGE", "colour-dodge"}, + {VIPS_BLEND_MODE_COLOUR_BURN, "VIPS_BLEND_MODE_COLOUR_BURN", "colour-burn"}, + {VIPS_BLEND_MODE_HARD_LIGHT, "VIPS_BLEND_MODE_HARD_LIGHT", "hard-light"}, + {VIPS_BLEND_MODE_SOFT_LIGHT, "VIPS_BLEND_MODE_SOFT_LIGHT", "soft-light"}, + {VIPS_BLEND_MODE_DIFFERENCE, "VIPS_BLEND_MODE_DIFFERENCE", "difference"}, + {VIPS_BLEND_MODE_EXCLUSION, "VIPS_BLEND_MODE_EXCLUSION", "exclusion"}, + {VIPS_BLEND_MODE_LAST, "VIPS_BLEND_MODE_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsBlendMode", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/convolution.h" */ +GType +vips_combine_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_COMBINE_MAX, "VIPS_COMBINE_MAX", "max"}, + {VIPS_COMBINE_SUM, "VIPS_COMBINE_SUM", "sum"}, + {VIPS_COMBINE_MIN, "VIPS_COMBINE_MIN", "min"}, + {VIPS_COMBINE_LAST, "VIPS_COMBINE_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsCombine", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/draw.h" */ +GType +vips_combine_mode_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_COMBINE_MODE_SET, "VIPS_COMBINE_MODE_SET", "set"}, + {VIPS_COMBINE_MODE_ADD, "VIPS_COMBINE_MODE_ADD", "add"}, + {VIPS_COMBINE_MODE_LAST, "VIPS_COMBINE_MODE_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsCombineMode", values ); } return( etype ); @@ -247,378 +654,6 @@ vips_foreign_dz_container_get_type( void ) return( etype ); } -/* enumerations from "../../libvips/include/vips/conversion.h" */ -GType -vips_extend_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_EXTEND_BLACK, "VIPS_EXTEND_BLACK", "black"}, - {VIPS_EXTEND_COPY, "VIPS_EXTEND_COPY", "copy"}, - {VIPS_EXTEND_REPEAT, "VIPS_EXTEND_REPEAT", "repeat"}, - {VIPS_EXTEND_MIRROR, "VIPS_EXTEND_MIRROR", "mirror"}, - {VIPS_EXTEND_WHITE, "VIPS_EXTEND_WHITE", "white"}, - {VIPS_EXTEND_BACKGROUND, "VIPS_EXTEND_BACKGROUND", "background"}, - {VIPS_EXTEND_LAST, "VIPS_EXTEND_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsExtend", values ); - } - - return( etype ); -} -GType -vips_compass_direction_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_COMPASS_DIRECTION_CENTRE, "VIPS_COMPASS_DIRECTION_CENTRE", "centre"}, - {VIPS_COMPASS_DIRECTION_NORTH, "VIPS_COMPASS_DIRECTION_NORTH", "north"}, - {VIPS_COMPASS_DIRECTION_EAST, "VIPS_COMPASS_DIRECTION_EAST", "east"}, - {VIPS_COMPASS_DIRECTION_SOUTH, "VIPS_COMPASS_DIRECTION_SOUTH", "south"}, - {VIPS_COMPASS_DIRECTION_WEST, "VIPS_COMPASS_DIRECTION_WEST", "west"}, - {VIPS_COMPASS_DIRECTION_NORTH_EAST, "VIPS_COMPASS_DIRECTION_NORTH_EAST", "north-east"}, - {VIPS_COMPASS_DIRECTION_SOUTH_EAST, "VIPS_COMPASS_DIRECTION_SOUTH_EAST", "south-east"}, - {VIPS_COMPASS_DIRECTION_SOUTH_WEST, "VIPS_COMPASS_DIRECTION_SOUTH_WEST", "south-west"}, - {VIPS_COMPASS_DIRECTION_NORTH_WEST, "VIPS_COMPASS_DIRECTION_NORTH_WEST", "north-west"}, - {VIPS_COMPASS_DIRECTION_LAST, "VIPS_COMPASS_DIRECTION_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsCompassDirection", values ); - } - - return( etype ); -} -GType -vips_direction_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_DIRECTION_HORIZONTAL, "VIPS_DIRECTION_HORIZONTAL", "horizontal"}, - {VIPS_DIRECTION_VERTICAL, "VIPS_DIRECTION_VERTICAL", "vertical"}, - {VIPS_DIRECTION_LAST, "VIPS_DIRECTION_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsDirection", values ); - } - - return( etype ); -} -GType -vips_align_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_ALIGN_LOW, "VIPS_ALIGN_LOW", "low"}, - {VIPS_ALIGN_CENTRE, "VIPS_ALIGN_CENTRE", "centre"}, - {VIPS_ALIGN_HIGH, "VIPS_ALIGN_HIGH", "high"}, - {VIPS_ALIGN_LAST, "VIPS_ALIGN_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsAlign", values ); - } - - return( etype ); -} -GType -vips_angle_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_ANGLE_D0, "VIPS_ANGLE_D0", "d0"}, - {VIPS_ANGLE_D90, "VIPS_ANGLE_D90", "d90"}, - {VIPS_ANGLE_D180, "VIPS_ANGLE_D180", "d180"}, - {VIPS_ANGLE_D270, "VIPS_ANGLE_D270", "d270"}, - {VIPS_ANGLE_LAST, "VIPS_ANGLE_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsAngle", values ); - } - - return( etype ); -} -GType -vips_angle45_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_ANGLE45_D0, "VIPS_ANGLE45_D0", "d0"}, - {VIPS_ANGLE45_D45, "VIPS_ANGLE45_D45", "d45"}, - {VIPS_ANGLE45_D90, "VIPS_ANGLE45_D90", "d90"}, - {VIPS_ANGLE45_D135, "VIPS_ANGLE45_D135", "d135"}, - {VIPS_ANGLE45_D180, "VIPS_ANGLE45_D180", "d180"}, - {VIPS_ANGLE45_D225, "VIPS_ANGLE45_D225", "d225"}, - {VIPS_ANGLE45_D270, "VIPS_ANGLE45_D270", "d270"}, - {VIPS_ANGLE45_D315, "VIPS_ANGLE45_D315", "d315"}, - {VIPS_ANGLE45_LAST, "VIPS_ANGLE45_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsAngle45", values ); - } - - return( etype ); -} -GType -vips_interesting_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_INTERESTING_NONE, "VIPS_INTERESTING_NONE", "none"}, - {VIPS_INTERESTING_CENTRE, "VIPS_INTERESTING_CENTRE", "centre"}, - {VIPS_INTERESTING_ENTROPY, "VIPS_INTERESTING_ENTROPY", "entropy"}, - {VIPS_INTERESTING_ATTENTION, "VIPS_INTERESTING_ATTENTION", "attention"}, - {VIPS_INTERESTING_LAST, "VIPS_INTERESTING_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsInteresting", values ); - } - - return( etype ); -} -GType -vips_blend_mode_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_BLEND_MODE_CLEAR, "VIPS_BLEND_MODE_CLEAR", "clear"}, - {VIPS_BLEND_MODE_SOURCE, "VIPS_BLEND_MODE_SOURCE", "source"}, - {VIPS_BLEND_MODE_OVER, "VIPS_BLEND_MODE_OVER", "over"}, - {VIPS_BLEND_MODE_IN, "VIPS_BLEND_MODE_IN", "in"}, - {VIPS_BLEND_MODE_OUT, "VIPS_BLEND_MODE_OUT", "out"}, - {VIPS_BLEND_MODE_ATOP, "VIPS_BLEND_MODE_ATOP", "atop"}, - {VIPS_BLEND_MODE_DEST, "VIPS_BLEND_MODE_DEST", "dest"}, - {VIPS_BLEND_MODE_DEST_OVER, "VIPS_BLEND_MODE_DEST_OVER", "dest-over"}, - {VIPS_BLEND_MODE_DEST_IN, "VIPS_BLEND_MODE_DEST_IN", "dest-in"}, - {VIPS_BLEND_MODE_DEST_OUT, "VIPS_BLEND_MODE_DEST_OUT", "dest-out"}, - {VIPS_BLEND_MODE_DEST_ATOP, "VIPS_BLEND_MODE_DEST_ATOP", "dest-atop"}, - {VIPS_BLEND_MODE_XOR, "VIPS_BLEND_MODE_XOR", "xor"}, - {VIPS_BLEND_MODE_ADD, "VIPS_BLEND_MODE_ADD", "add"}, - {VIPS_BLEND_MODE_SATURATE, "VIPS_BLEND_MODE_SATURATE", "saturate"}, - {VIPS_BLEND_MODE_MULTIPLY, "VIPS_BLEND_MODE_MULTIPLY", "multiply"}, - {VIPS_BLEND_MODE_SCREEN, "VIPS_BLEND_MODE_SCREEN", "screen"}, - {VIPS_BLEND_MODE_OVERLAY, "VIPS_BLEND_MODE_OVERLAY", "overlay"}, - {VIPS_BLEND_MODE_DARKEN, "VIPS_BLEND_MODE_DARKEN", "darken"}, - {VIPS_BLEND_MODE_LIGHTEN, "VIPS_BLEND_MODE_LIGHTEN", "lighten"}, - {VIPS_BLEND_MODE_COLOUR_DODGE, "VIPS_BLEND_MODE_COLOUR_DODGE", "colour-dodge"}, - {VIPS_BLEND_MODE_COLOUR_BURN, "VIPS_BLEND_MODE_COLOUR_BURN", "colour-burn"}, - {VIPS_BLEND_MODE_HARD_LIGHT, "VIPS_BLEND_MODE_HARD_LIGHT", "hard-light"}, - {VIPS_BLEND_MODE_SOFT_LIGHT, "VIPS_BLEND_MODE_SOFT_LIGHT", "soft-light"}, - {VIPS_BLEND_MODE_DIFFERENCE, "VIPS_BLEND_MODE_DIFFERENCE", "difference"}, - {VIPS_BLEND_MODE_EXCLUSION, "VIPS_BLEND_MODE_EXCLUSION", "exclusion"}, - {VIPS_BLEND_MODE_LAST, "VIPS_BLEND_MODE_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsBlendMode", values ); - } - - return( etype ); -} -/* enumerations from "../../libvips/include/vips/arithmetic.h" */ -GType -vips_operation_math_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_MATH_SIN, "VIPS_OPERATION_MATH_SIN", "sin"}, - {VIPS_OPERATION_MATH_COS, "VIPS_OPERATION_MATH_COS", "cos"}, - {VIPS_OPERATION_MATH_TAN, "VIPS_OPERATION_MATH_TAN", "tan"}, - {VIPS_OPERATION_MATH_ASIN, "VIPS_OPERATION_MATH_ASIN", "asin"}, - {VIPS_OPERATION_MATH_ACOS, "VIPS_OPERATION_MATH_ACOS", "acos"}, - {VIPS_OPERATION_MATH_ATAN, "VIPS_OPERATION_MATH_ATAN", "atan"}, - {VIPS_OPERATION_MATH_LOG, "VIPS_OPERATION_MATH_LOG", "log"}, - {VIPS_OPERATION_MATH_LOG10, "VIPS_OPERATION_MATH_LOG10", "log10"}, - {VIPS_OPERATION_MATH_EXP, "VIPS_OPERATION_MATH_EXP", "exp"}, - {VIPS_OPERATION_MATH_EXP10, "VIPS_OPERATION_MATH_EXP10", "exp10"}, - {VIPS_OPERATION_MATH_LAST, "VIPS_OPERATION_MATH_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationMath", values ); - } - - return( etype ); -} -GType -vips_operation_math2_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_MATH2_POW, "VIPS_OPERATION_MATH2_POW", "pow"}, - {VIPS_OPERATION_MATH2_WOP, "VIPS_OPERATION_MATH2_WOP", "wop"}, - {VIPS_OPERATION_MATH2_LAST, "VIPS_OPERATION_MATH2_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationMath2", values ); - } - - return( etype ); -} -GType -vips_operation_round_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_ROUND_RINT, "VIPS_OPERATION_ROUND_RINT", "rint"}, - {VIPS_OPERATION_ROUND_CEIL, "VIPS_OPERATION_ROUND_CEIL", "ceil"}, - {VIPS_OPERATION_ROUND_FLOOR, "VIPS_OPERATION_ROUND_FLOOR", "floor"}, - {VIPS_OPERATION_ROUND_LAST, "VIPS_OPERATION_ROUND_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationRound", values ); - } - - return( etype ); -} -GType -vips_operation_relational_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_RELATIONAL_EQUAL, "VIPS_OPERATION_RELATIONAL_EQUAL", "equal"}, - {VIPS_OPERATION_RELATIONAL_NOTEQ, "VIPS_OPERATION_RELATIONAL_NOTEQ", "noteq"}, - {VIPS_OPERATION_RELATIONAL_LESS, "VIPS_OPERATION_RELATIONAL_LESS", "less"}, - {VIPS_OPERATION_RELATIONAL_LESSEQ, "VIPS_OPERATION_RELATIONAL_LESSEQ", "lesseq"}, - {VIPS_OPERATION_RELATIONAL_MORE, "VIPS_OPERATION_RELATIONAL_MORE", "more"}, - {VIPS_OPERATION_RELATIONAL_MOREEQ, "VIPS_OPERATION_RELATIONAL_MOREEQ", "moreeq"}, - {VIPS_OPERATION_RELATIONAL_LAST, "VIPS_OPERATION_RELATIONAL_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationRelational", values ); - } - - return( etype ); -} -GType -vips_operation_boolean_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_BOOLEAN_AND, "VIPS_OPERATION_BOOLEAN_AND", "and"}, - {VIPS_OPERATION_BOOLEAN_OR, "VIPS_OPERATION_BOOLEAN_OR", "or"}, - {VIPS_OPERATION_BOOLEAN_EOR, "VIPS_OPERATION_BOOLEAN_EOR", "eor"}, - {VIPS_OPERATION_BOOLEAN_LSHIFT, "VIPS_OPERATION_BOOLEAN_LSHIFT", "lshift"}, - {VIPS_OPERATION_BOOLEAN_RSHIFT, "VIPS_OPERATION_BOOLEAN_RSHIFT", "rshift"}, - {VIPS_OPERATION_BOOLEAN_LAST, "VIPS_OPERATION_BOOLEAN_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationBoolean", values ); - } - - return( etype ); -} -GType -vips_operation_complex_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_COMPLEX_POLAR, "VIPS_OPERATION_COMPLEX_POLAR", "polar"}, - {VIPS_OPERATION_COMPLEX_RECT, "VIPS_OPERATION_COMPLEX_RECT", "rect"}, - {VIPS_OPERATION_COMPLEX_CONJ, "VIPS_OPERATION_COMPLEX_CONJ", "conj"}, - {VIPS_OPERATION_COMPLEX_LAST, "VIPS_OPERATION_COMPLEX_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationComplex", values ); - } - - return( etype ); -} -GType -vips_operation_complex2_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_COMPLEX2_CROSS_PHASE, "VIPS_OPERATION_COMPLEX2_CROSS_PHASE", "cross-phase"}, - {VIPS_OPERATION_COMPLEX2_LAST, "VIPS_OPERATION_COMPLEX2_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationComplex2", values ); - } - - return( etype ); -} -GType -vips_operation_complexget_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_OPERATION_COMPLEXGET_REAL, "VIPS_OPERATION_COMPLEXGET_REAL", "real"}, - {VIPS_OPERATION_COMPLEXGET_IMAG, "VIPS_OPERATION_COMPLEXGET_IMAG", "imag"}, - {VIPS_OPERATION_COMPLEXGET_LAST, "VIPS_OPERATION_COMPLEXGET_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsOperationComplexget", values ); - } - - return( etype ); -} -/* enumerations from "../../libvips/include/vips/util.h" */ -GType -vips_token_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_TOKEN_LEFT, "VIPS_TOKEN_LEFT", "left"}, - {VIPS_TOKEN_RIGHT, "VIPS_TOKEN_RIGHT", "right"}, - {VIPS_TOKEN_STRING, "VIPS_TOKEN_STRING", "string"}, - {VIPS_TOKEN_EQUALS, "VIPS_TOKEN_EQUALS", "equals"}, - {VIPS_TOKEN_COMMA, "VIPS_TOKEN_COMMA", "comma"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsToken", values ); - } - - return( etype ); -} /* enumerations from "../../libvips/include/vips/image.h" */ GType vips_demand_style_get_type( void ) @@ -766,86 +801,6 @@ vips_access_get_type( void ) return( etype ); } -/* enumerations from "../../libvips/include/vips/colour.h" */ -GType -vips_intent_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_INTENT_PERCEPTUAL, "VIPS_INTENT_PERCEPTUAL", "perceptual"}, - {VIPS_INTENT_RELATIVE, "VIPS_INTENT_RELATIVE", "relative"}, - {VIPS_INTENT_SATURATION, "VIPS_INTENT_SATURATION", "saturation"}, - {VIPS_INTENT_ABSOLUTE, "VIPS_INTENT_ABSOLUTE", "absolute"}, - {VIPS_INTENT_LAST, "VIPS_INTENT_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsIntent", values ); - } - - return( etype ); -} -GType -vips_pcs_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_PCS_LAB, "VIPS_PCS_LAB", "lab"}, - {VIPS_PCS_XYZ, "VIPS_PCS_XYZ", "xyz"}, - {VIPS_PCS_LAST, "VIPS_PCS_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsPCS", values ); - } - - return( etype ); -} -/* enumerations from "../../libvips/include/vips/operation.h" */ -GType -vips_operation_flags_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GFlagsValue values[] = { - {VIPS_OPERATION_NONE, "VIPS_OPERATION_NONE", "none"}, - {VIPS_OPERATION_SEQUENTIAL, "VIPS_OPERATION_SEQUENTIAL", "sequential"}, - {VIPS_OPERATION_SEQUENTIAL_UNBUFFERED, "VIPS_OPERATION_SEQUENTIAL_UNBUFFERED", "sequential-unbuffered"}, - {VIPS_OPERATION_NOCACHE, "VIPS_OPERATION_NOCACHE", "nocache"}, - {VIPS_OPERATION_DEPRECATED, "VIPS_OPERATION_DEPRECATED", "deprecated"}, - {0, NULL, NULL} - }; - - etype = g_flags_register_static( "VipsOperationFlags", values ); - } - - return( etype ); -} -/* enumerations from "../../libvips/include/vips/convolution.h" */ -GType -vips_combine_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_COMBINE_MAX, "VIPS_COMBINE_MAX", "max"}, - {VIPS_COMBINE_SUM, "VIPS_COMBINE_SUM", "sum"}, - {VIPS_COMBINE_MIN, "VIPS_COMBINE_MIN", "min"}, - {VIPS_COMBINE_LAST, "VIPS_COMBINE_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsCombine", values ); - } - - return( etype ); -} /* enumerations from "../../libvips/include/vips/morphology.h" */ GType vips_operation_morphology_get_type( void ) @@ -865,45 +820,6 @@ vips_operation_morphology_get_type( void ) return( etype ); } -/* enumerations from "../../libvips/include/vips/draw.h" */ -GType -vips_combine_mode_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_COMBINE_MODE_SET, "VIPS_COMBINE_MODE_SET", "set"}, - {VIPS_COMBINE_MODE_ADD, "VIPS_COMBINE_MODE_ADD", "add"}, - {VIPS_COMBINE_MODE_LAST, "VIPS_COMBINE_MODE_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsCombineMode", values ); - } - - return( etype ); -} -/* enumerations from "../../libvips/include/vips/basic.h" */ -GType -vips_precision_get_type( void ) -{ - static GType etype = 0; - - if( etype == 0 ) { - static const GEnumValue values[] = { - {VIPS_PRECISION_INTEGER, "VIPS_PRECISION_INTEGER", "integer"}, - {VIPS_PRECISION_FLOAT, "VIPS_PRECISION_FLOAT", "float"}, - {VIPS_PRECISION_APPROXIMATE, "VIPS_PRECISION_APPROXIMATE", "approximate"}, - {VIPS_PRECISION_LAST, "VIPS_PRECISION_LAST", "last"}, - {0, NULL, NULL} - }; - - etype = g_enum_register_static( "VipsPrecision", values ); - } - - return( etype ); -} /* enumerations from "../../libvips/include/vips/object.h" */ GType vips_argument_flags_get_type( void ) @@ -929,6 +845,109 @@ vips_argument_flags_get_type( void ) return( etype ); } +/* enumerations from "../../libvips/include/vips/operation.h" */ +GType +vips_operation_flags_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GFlagsValue values[] = { + {VIPS_OPERATION_NONE, "VIPS_OPERATION_NONE", "none"}, + {VIPS_OPERATION_SEQUENTIAL, "VIPS_OPERATION_SEQUENTIAL", "sequential"}, + {VIPS_OPERATION_SEQUENTIAL_UNBUFFERED, "VIPS_OPERATION_SEQUENTIAL_UNBUFFERED", "sequential-unbuffered"}, + {VIPS_OPERATION_NOCACHE, "VIPS_OPERATION_NOCACHE", "nocache"}, + {VIPS_OPERATION_DEPRECATED, "VIPS_OPERATION_DEPRECATED", "deprecated"}, + {0, NULL, NULL} + }; + + etype = g_flags_register_static( "VipsOperationFlags", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/region.h" */ +GType +vips_region_shrink_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_REGION_SHRINK_MEAN, "VIPS_REGION_SHRINK_MEAN", "mean"}, + {VIPS_REGION_SHRINK_MEDIAN, "VIPS_REGION_SHRINK_MEDIAN", "median"}, + {VIPS_REGION_SHRINK_LAST, "VIPS_REGION_SHRINK_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsRegionShrink", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/resample.h" */ +GType +vips_kernel_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_KERNEL_NEAREST, "VIPS_KERNEL_NEAREST", "nearest"}, + {VIPS_KERNEL_LINEAR, "VIPS_KERNEL_LINEAR", "linear"}, + {VIPS_KERNEL_CUBIC, "VIPS_KERNEL_CUBIC", "cubic"}, + {VIPS_KERNEL_LANCZOS2, "VIPS_KERNEL_LANCZOS2", "lanczos2"}, + {VIPS_KERNEL_LANCZOS3, "VIPS_KERNEL_LANCZOS3", "lanczos3"}, + {VIPS_KERNEL_LAST, "VIPS_KERNEL_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsKernel", values ); + } + + return( etype ); +} +GType +vips_size_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_SIZE_BOTH, "VIPS_SIZE_BOTH", "both"}, + {VIPS_SIZE_UP, "VIPS_SIZE_UP", "up"}, + {VIPS_SIZE_DOWN, "VIPS_SIZE_DOWN", "down"}, + {VIPS_SIZE_FORCE, "VIPS_SIZE_FORCE", "force"}, + {VIPS_SIZE_LAST, "VIPS_SIZE_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsSize", values ); + } + + return( etype ); +} +/* enumerations from "../../libvips/include/vips/util.h" */ +GType +vips_token_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_TOKEN_LEFT, "VIPS_TOKEN_LEFT", "left"}, + {VIPS_TOKEN_RIGHT, "VIPS_TOKEN_RIGHT", "right"}, + {VIPS_TOKEN_STRING, "VIPS_TOKEN_STRING", "string"}, + {VIPS_TOKEN_EQUALS, "VIPS_TOKEN_EQUALS", "equals"}, + {VIPS_TOKEN_COMMA, "VIPS_TOKEN_COMMA", "comma"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsToken", values ); + } + + return( etype ); +} /* Generated data ends here */ From 5578347c194ce08d07344d3322a3c50be003c3d2 Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Wed, 28 Mar 2018 13:43:54 +1100 Subject: [PATCH 4/5] dzsave now uses the specified region shrink method --- libvips/foreign/dzsave.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index 36fe02e3..8ed2f596 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -1356,6 +1356,8 @@ strip_shrink( Layer *layer ) Layer *below = layer->below; VipsRegion *from = layer->strip; VipsRegion *to = below->strip; + VipsForeignSaveDz *dz = layer->dz; + VipsRegionShrink region_shrink = dz->region_shrink; VipsRect target; VipsRect source; @@ -1406,7 +1408,7 @@ strip_shrink( Layer *layer ) break; (void) vips_region_shrink( from, to, &target, - VIPS_REGION_SHRINK_MEAN ); + region_shrink ); below->write_y += target.height; From a14f3acdf5516b5f73005dbeda7d0efa782ae456 Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Wed, 28 Mar 2018 21:59:17 +1100 Subject: [PATCH 5/5] Adds a first cut for region shrink mode --- libvips/include/vips/region.h | 2 + libvips/iofuncs/enumtypes.c | 1 + libvips/iofuncs/region.c | 77 +++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index b5362e16..bf0c877d 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -59,12 +59,14 @@ extern "C" { * VipsRegionShrink: * @VIPS_REGION_SHRINK_MEAN: use the average * @VIPS_REGION_SHRINK_MEDIAN: use the median + * @VIPS_REGION_SHRINK_MODE: use the mode * * How to calculate the output pixels when shrinking a 2x2 region. */ typedef enum { VIPS_REGION_SHRINK_MEAN, VIPS_REGION_SHRINK_MEDIAN, + VIPS_REGION_SHRINK_MODE, VIPS_REGION_SHRINK_LAST } VipsRegionShrink; diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index c50d040e..242c2b01 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -876,6 +876,7 @@ vips_region_shrink_get_type( void ) static const GEnumValue values[] = { {VIPS_REGION_SHRINK_MEAN, "VIPS_REGION_SHRINK_MEAN", "mean"}, {VIPS_REGION_SHRINK_MEDIAN, "VIPS_REGION_SHRINK_MEDIAN", "median"}, + {VIPS_REGION_SHRINK_MODE, "VIPS_REGION_SHRINK_MODE", "mode"}, {VIPS_REGION_SHRINK_LAST, "VIPS_REGION_SHRINK_LAST", "last"}, {0, NULL, NULL} }; diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index ce8ec437..6c9c8e35 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -1233,6 +1233,36 @@ vips_region_shrink_labpack( VipsRegion *from, q += ps; \ } +/* This method is implemented so as to perform well and to always select an + * output pixel from one of the input pixels. As such we make only the + * following guarantees: + * + * ONLY works for non-complex uncoded images pixel types + * ALWAYS draws from the input values + * NEVER interpolates + * NOT stable with respect to the ordered set of input values + * IS stable with respect to the initial arrangement of input values + */ +#define SHRINK_TYPE_MODE( TYPE ) \ + for( x = 0; x < target->width; x++ ) { \ + TYPE *tp = (TYPE *) p; \ + TYPE *tp1 = (TYPE *) (p + ls); \ + TYPE *tq = (TYPE *) q; \ + \ + for( z = 0; z < nb; z++ ) { \ + TYPE v[] = {tp[z], tp[z + nb], tp1[z], tp1[z + nb]}; \ + int b0 = (v[0] == v[1]) | (v[0] == v[2]) | (v[0] == v[3]); \ + int b1 = (v[1] == v[0]) | (v[1] == v[2]) | (v[1] == v[3]); \ + int index = ((~b0) & 0x1) + (~(b0 ^ b1) & 0x1); \ + tq[z] = v[index]; \ + } \ + \ + /* Move on two pels in input. \ + */ \ + p += ps << 1; \ + q += ps; \ + } + /* Generate area @target in @to using pixels in @from. Non-complex. */ static void @@ -1321,6 +1351,50 @@ vips_region_shrink_uncoded_median( VipsRegion *from, } } +/* Generate area @target in @to using pixels in @from. Non-complex. + */ +static void +vips_region_shrink_uncoded_mode( VipsRegion *from, + VipsRegion *to, const VipsRect *target ) +{ + int ls = VIPS_REGION_LSKIP( from ); + int ps = VIPS_IMAGE_SIZEOF_PEL( from->im ); + int nb = from->im->Bands; + + int x, y, z; + + for( y = 0; y < target->height; y++ ) { + VipsPel *p = VIPS_REGION_ADDR( from, + target->left * 2, (target->top + y) * 2 ); + VipsPel *q = VIPS_REGION_ADDR( to, + target->left, target->top + y ); + + /* Process this line of pels. + */ + switch( from->im->BandFmt ) { + case VIPS_FORMAT_UCHAR: + SHRINK_TYPE_MODE( unsigned char ); break; + case VIPS_FORMAT_CHAR: + SHRINK_TYPE_MODE( signed char ); break; + case VIPS_FORMAT_USHORT: + SHRINK_TYPE_MODE( unsigned short ); break; + case VIPS_FORMAT_SHORT: + SHRINK_TYPE_MODE( signed short ); break; + case VIPS_FORMAT_UINT: + SHRINK_TYPE_MODE( unsigned int ); break; + case VIPS_FORMAT_INT: + SHRINK_TYPE_MODE( signed int ); break; + case VIPS_FORMAT_FLOAT: + SHRINK_TYPE_MODE( float ); break; + case VIPS_FORMAT_DOUBLE: + SHRINK_TYPE_MODE( double ); break; + + default: + g_assert_not_reached(); + } + } +} + /* Generate area @target in @to using pixels in @from. Non-complex. */ static void @@ -1334,6 +1408,9 @@ vips_region_shrink_uncoded( VipsRegion *from, case VIPS_REGION_SHRINK_MEDIAN: vips_region_shrink_uncoded_median( from, to, target ); break; + case VIPS_REGION_SHRINK_MODE: + vips_region_shrink_uncoded_mode( from, to, target ); + break; default: g_assert_not_reached();