diff --git a/libvips/include/vips/enumtypes.h b/libvips/include/vips/enumtypes.h index 9ae0673e..95df929c 100644 --- a/libvips/include/vips/enumtypes.h +++ b/libvips/include/vips/enumtypes.h @@ -12,15 +12,17 @@ GType vips_token_get_type (void) G_GNUC_CONST; /* 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()) -GType vips_type_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_TYPE (vips_type_get_type()) -GType vips_format_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_FORMAT (vips_format_get_type()) +GType vips_image_type_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_IMAGE_TYPE (vips_image_type_get_type()) +GType vips_interpretation_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_INTERPRETATION (vips_interpretation_get_type()) +GType vips_band_format_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_BAND_FORMAT (vips_band_format_get_type()) GType vips_coding_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_CODING (vips_coding_get_type()) /* enumerations from "../../../libvips/include/vips/object.h" */ -GType vips_argument_get_type (void) G_GNUC_CONST; -#define VIPS_TYPE_ARGUMENT (vips_argument_get_type()) +GType vips_argument_flags_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_ARGUMENT_FLAGS (vips_argument_flags_get_type()) G_END_DECLS #endif /*VIPS_ENUM_TYPES_H*/ diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index 19e3d3c9..221c2f4a 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -30,8 +30,8 @@ */ -#ifndef IM_IMAGE_H -#define IM_IMAGE_H +#ifndef VIPS_IMAGE_H +#define VIPS_IMAGE_H #ifdef __cplusplus extern "C" { @@ -208,7 +208,7 @@ typedef struct _VipsImage { GSList *Meta_traverse; /* traverse order for Meta */ /* Part of mmap() read ... the sizeof() the header we skip from the - * file start. Usually IM_SIZEOF_HEADER, but can be something else + * file start. Usually VIPS_SIZEOF_HEADER, but can be something else * for binary file read. */ int sizeof_header; @@ -296,9 +296,9 @@ extern const size_t vips__sizeof_bandfmt[]; #define VIPS_IMAGE_SIZEOF_ELEMENT( I ) \ (vips__sizeof_bandfmt[(I)->BandFmt]) #define VIPS_IMAGE_SIZEOF_PEL( I ) \ - (IM_IMAGE_SIZEOF_ELEMENT( I ) * (I)->Bands) + (VIPS_IMAGE_SIZEOF_ELEMENT( I ) * (I)->Bands) #define VIPS_IMAGE_SIZEOF_LINE( I ) \ - (IM_IMAGE_SIZEOF_PEL( I ) * (I)->Xsize) + (VIPS_IMAGE_SIZEOF_PEL( I ) * (I)->Xsize) #define VIPS_IMAGE_N_ELEMENTS( I ) \ ((I)->Bands * (I)->Xsize) @@ -312,7 +312,7 @@ extern const size_t vips__sizeof_bandfmt[]; (Y) * VIPS_IMAGE_SIZEOF_LINE( I ) + \ (X) * VIPS_IMAGE_SIZEOF_PEL( I )) : \ (fprintf( stderr, \ - "IM_IMAGE_ADDR: point out of bounds, " \ + "VIPS_IMAGE_ADDR: point out of bounds, " \ "file \"%s\", line %d\n" \ "(point x=%d, y=%d\n" \ " should have been within Rect left=%d, top=%d, " \ @@ -408,4 +408,4 @@ int im_bits_of_fmt( VipsBandFormat fmt ); } #endif /*__cplusplus*/ -#endif /*IM_IMAGE_H*/ +#endif /*VIPS_IMAGE_H*/ diff --git a/libvips/include/vips/memory.h b/libvips/include/vips/memory.h index 0a76850c..119a2824 100644 --- a/libvips/include/vips/memory.h +++ b/libvips/include/vips/memory.h @@ -61,7 +61,7 @@ G_STMT_START { \ \ if( (S) != sst ) { \ if( !(S) || !sst || strcmp( (S), sst ) != 0 ) { \ - IM_FREE( S ); \ + VIPS_FREE( S ); \ if( sst ) \ (S) = im_strdup( NULL, sst ); \ } \ diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 9272a2b4..d0b97973 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -36,7 +36,7 @@ extern "C" { /* Handy! */ -#define VIPS_UNREF( O ) IM_FREEF( g_object_unref, (O) ) +#define VIPS_UNREF( O ) VIPS_FREEF( g_object_unref, (O) ) typedef struct _VipsObject VipsObject; typedef struct _VipsObjectClass VipsObjectClass; diff --git a/libvips/include/vips/util.h b/libvips/include/vips/util.h index 7894a72b..1da73ea1 100644 --- a/libvips/include/vips/util.h +++ b/libvips/include/vips/util.h @@ -31,8 +31,8 @@ */ -#ifndef IM_UTIL_H -#define IM_UTIL_H +#ifndef VIPS_UTIL_H +#define VIPS_UTIL_H #ifdef __cplusplus extern "C" { @@ -40,23 +40,23 @@ extern "C" { #include -/* Some platforms don't have M_PI in math.h :-( +/* Some platforms don't have M_PI :-( */ -#define IM_PI (3.14159265358979323846) +#define VIPS_PI (3.14159265358979323846) /* Convert degrees->rads and vice-versa. */ -#define IM_RAD( R ) (((R) / 360.0) * 2.0 * IM_PI) -#define IM_DEG( A ) (((A) / (2.0 * IM_PI)) * 360.0) +#define VIPS_RAD( R ) (((R) / 360.0) * 2.0 * VIPS_PI) +#define VIPS_DEG( A ) (((A) / (2.0 * VIPS_PI)) * 360.0) -#define IM_MAX( A, B ) ((A) > (B) ? (A) : (B)) -#define IM_MIN( A, B ) ((A) < (B) ? (A) : (B)) -#define IM_ABS( X ) (((X) >= 0) ? (X) : -(X)) +#define VIPS_MAX( A, B ) ((A) > (B) ? (A) : (B)) +#define VIPS_MIN( A, B ) ((A) < (B) ? (A) : (B)) +#define VIPS_ABS( X ) (((X) >= 0) ? (X) : -(X)) -#define IM_CLIP( A, V, B ) IM_MAX( (A), IM_MIN( (B), (V) ) ) -#define IM_NUMBER( R ) ((int) (sizeof(R) / sizeof(R[0]))) +#define VIPS_CLIP( A, V, B ) VIPS_MAX( (A), VIPS_MIN( (B), (V) ) ) +#define VIPS_NUMBER( R ) ((int) (sizeof(R) / sizeof(R[0]))) -#define IM_SWAP( TYPE, A, B ) \ +#define VIPS_SWAP( TYPE, A, B ) \ G_STMT_START { \ TYPE t = (A); \ (A) = (B); \ @@ -65,7 +65,7 @@ G_STMT_START { \ /* Duff's device. Do OPERation N times in a 16-way unrolled loop. */ -#define IM_UNROLL( N, OPER ) \ +#define VIPS_UNROLL( N, OPER ) \ G_STMT_START { \ if( (N) ) { \ int duff_count = ((N) + 15) / 16; \ @@ -94,11 +94,11 @@ G_STMT_START { \ /* Round a float to the nearest integer. Much faster than rint(). */ -#define IM_RINT( R ) ((int) ((R) > 0 ? ((R) + 0.5) : ((R) - 0.5))) +#define VIPS_RINT( R ) ((int) ((R) > 0 ? ((R) + 0.5) : ((R) - 0.5))) /* Various integer range clips. Record over/under flows. */ -#define IM_CLIP_UCHAR( V, SEQ ) \ +#define VIPS_CLIP_UCHAR( V, SEQ ) \ G_STMT_START { \ if( (V) < 0 ) { \ (SEQ)->underflow++; \ @@ -110,7 +110,7 @@ G_STMT_START { \ } \ } G_STMT_END -#define IM_CLIP_USHORT( V, SEQ ) \ +#define VIPS_CLIP_USHORT( V, SEQ ) \ G_STMT_START { \ if( (V) < 0 ) { \ (SEQ)->underflow++; \ @@ -122,7 +122,7 @@ G_STMT_START { \ } \ } G_STMT_END -#define IM_CLIP_CHAR( V, SEQ ) \ +#define VIPS_CLIP_CHAR( V, SEQ ) \ G_STMT_START { \ if( (V) < SCHAR_MIN ) { \ (SEQ)->underflow++; \ @@ -134,7 +134,7 @@ G_STMT_START { \ } \ } G_STMT_END -#define IM_CLIP_SHORT( V, SEQ ) \ +#define VIPS_CLIP_SHORT( V, SEQ ) \ G_STMT_START { \ if( (V) < SHRT_MIN ) { \ (SEQ)->underflow++; \ @@ -146,7 +146,7 @@ G_STMT_START { \ } \ } G_STMT_END -#define IM_CLIP_NONE( V, SEQ ) {} +#define VIPS_CLIP_NONE( V, SEQ ) {} /* Look up the const char * for an enum value. */ @@ -236,4 +236,4 @@ char *im__temp_name( const char *format ); } #endif /*__cplusplus*/ -#endif /*IM_UTIL_H*/ +#endif /*VIPS_UTIL_H*/ diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index 25e99bed..dcbbd573 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -74,8 +74,8 @@ */ -#ifndef IM_VIPS_H -#define IM_VIPS_H +#ifndef VIPS_VIPS_H +#define VIPS_VIPS_H #ifdef __cplusplus extern "C" { @@ -140,12 +140,12 @@ extern "C" { #include #include -#ifdef IM_ENABLE_DEPRECATED +#ifdef VIPS_ENABLE_DEPRECATED #include -#endif /*IM_ENABLE_DEPRECATED*/ +#endif /*VIPS_ENABLE_DEPRECATED*/ #ifdef __cplusplus } #endif /*__cplusplus*/ -#endif /*IM_VIPS_H*/ +#endif /*VIPS_VIPS_H*/ diff --git a/libvips/iofuncs/buf.c b/libvips/iofuncs/buf.c index f283587b..5ea96d25 100644 --- a/libvips/iofuncs/buf.c +++ b/libvips/iofuncs/buf.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index ba516ca3..7a311e7a 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -46,38 +46,61 @@ vips_demand_style_get_type( void ) return( etype ); } GType -vips_type_get_type( void ) +vips_image_type_get_type( void ) { static GType etype = 0; if( etype == 0 ) { static const GEnumValue values[] = { - {VIPS_TYPE_MULTIBAND, "VIPS_TYPE_MULTIBAND", "multiband"}, - {VIPS_TYPE_B_W, "VIPS_TYPE_B_W", "b-w"}, - {VIPS_TYPE_HISTOGRAM, "VIPS_TYPE_HISTOGRAM", "histogram"}, - {VIPS_TYPE_FOURIER, "VIPS_TYPE_FOURIER", "fourier"}, - {VIPS_TYPE_XYZ, "VIPS_TYPE_XYZ", "xyz"}, - {VIPS_TYPE_LAB, "VIPS_TYPE_LAB", "lab"}, - {VIPS_TYPE_CMYK, "VIPS_TYPE_CMYK", "cmyk"}, - {VIPS_TYPE_LABQ, "VIPS_TYPE_LABQ", "labq"}, - {VIPS_TYPE_RGB, "VIPS_TYPE_RGB", "rgb"}, - {VIPS_TYPE_UCS, "VIPS_TYPE_UCS", "ucs"}, - {VIPS_TYPE_LCH, "VIPS_TYPE_LCH", "lch"}, - {VIPS_TYPE_LABS, "VIPS_TYPE_LABS", "labs"}, - {VIPS_TYPE_sRGB, "VIPS_TYPE_sRGB", "srgb"}, - {VIPS_TYPE_YXY, "VIPS_TYPE_YXY", "yxy"}, - {VIPS_TYPE_RGB16, "VIPS_TYPE_RGB16", "rgb16"}, - {VIPS_TYPE_GREY16, "VIPS_TYPE_GREY16", "grey16"}, + {VIPS_IMAGE_NONE, "VIPS_IMAGE_NONE", "none"}, + {VIPS_IMAGE_SETBUF, "VIPS_IMAGE_SETBUF", "setbuf"}, + {VIPS_IMAGE_SETBUF_FOREIGN, "VIPS_IMAGE_SETBUF_FOREIGN", "setbuf-foreign"}, + {VIPS_IMAGE_OPENIN, "VIPS_IMAGE_OPENIN", "openin"}, + {VIPS_IMAGE_MMAPIN, "VIPS_IMAGE_MMAPIN", "mmapin"}, + {VIPS_IMAGE_MMAPINRW, "VIPS_IMAGE_MMAPINRW", "mmapinrw"}, + {VIPS_IMAGE_OPENOUT, "VIPS_IMAGE_OPENOUT", "openout"}, + {VIPS_IMAGE_PARTIAL, "VIPS_IMAGE_PARTIAL", "partial"}, {0, NULL, NULL} }; - etype = g_enum_register_static( "VipsType", values ); + etype = g_enum_register_static( "VipsImageType", values ); } return( etype ); } GType -vips_format_get_type( void ) +vips_interpretation_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_INTERPRETATION_MULTIBAND, "VIPS_INTERPRETATION_MULTIBAND", "multiband"}, + {VIPS_INTERPRETATION_B_W, "VIPS_INTERPRETATION_B_W", "b-w"}, + {VIPS_INTERPRETATION_HISTOGRAM, "VIPS_INTERPRETATION_HISTOGRAM", "histogram"}, + {VIPS_INTERPRETATION_FOURIER, "VIPS_INTERPRETATION_FOURIER", "fourier"}, + {VIPS_INTERPRETATION_XYZ, "VIPS_INTERPRETATION_XYZ", "xyz"}, + {VIPS_INTERPRETATION_LAB, "VIPS_INTERPRETATION_LAB", "lab"}, + {VIPS_INTERPRETATION_CMYK, "VIPS_INTERPRETATION_CMYK", "cmyk"}, + {VIPS_INTERPRETATION_LABQ, "VIPS_INTERPRETATION_LABQ", "labq"}, + {VIPS_INTERPRETATION_RGB, "VIPS_INTERPRETATION_RGB", "rgb"}, + {VIPS_INTERPRETATION_UCS, "VIPS_INTERPRETATION_UCS", "ucs"}, + {VIPS_INTERPRETATION_LCH, "VIPS_INTERPRETATION_LCH", "lch"}, + {VIPS_INTERPRETATION_LABS, "VIPS_INTERPRETATION_LABS", "labs"}, + {VIPS_INTERPRETATION_sRGB, "VIPS_INTERPRETATION_sRGB", "srgb"}, + {VIPS_INTERPRETATION_YXY, "VIPS_INTERPRETATION_YXY", "yxy"}, + {VIPS_INTERPRETATION_RGB16, "VIPS_INTERPRETATION_RGB16", "rgb16"}, + {VIPS_INTERPRETATION_GREY16, "VIPS_INTERPRETATION_GREY16", "grey16"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsInterpretation", values ); + } + + return( etype ); +} +GType +vips_band_format_get_type( void ) { static GType etype = 0; @@ -98,7 +121,7 @@ vips_format_get_type( void ) {0, NULL, NULL} }; - etype = g_enum_register_static( "VipsFormat", values ); + etype = g_enum_register_static( "VipsBandFormat", values ); } return( etype ); @@ -123,7 +146,7 @@ vips_coding_get_type( void ) } /* enumerations from "../../libvips/include/vips/object.h" */ GType -vips_argument_get_type( void ) +vips_argument_flags_get_type( void ) { static GType etype = 0; @@ -138,7 +161,7 @@ vips_argument_get_type( void ) {0, NULL, NULL} }; - etype = g_enum_register_static( "VipsArgument", values ); + etype = g_enum_register_static( "VipsArgumentFlags", values ); } return( etype ); diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index f4a57771..f2ff73f8 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -45,6 +45,7 @@ #ifdef HAVE_UNISTD_H #include #endif /*HAVE_UNISTD_H*/ +#include #include #include @@ -461,7 +462,7 @@ typedef struct { } Lazy; static void -lazy_free( Lazy *lazy ) +lazy_free_cb( Lazy *lazy ) { VIPS_UNREF( lazy->image ); } @@ -471,13 +472,13 @@ lazy_new( VipsImage *out, VipsFormatClass *format, gboolean disc ) { Lazy *lazy; - if( !(lazy = IM_NEW( out, Lazy )) ) + if( !(lazy = VIPS_NEW( out, Lazy )) ) return( NULL ); lazy->out = out; lazy->format = format; lazy->disc = disc; lazy->image = NULL; - g_signal_connect( out, "close", lazy_free, NULL ); + g_signal_connect( out, "close", G_CALLBACK( lazy_free_cb ), NULL ); return( lazy ); } @@ -508,7 +509,7 @@ parse_size( const char *size_string ) if( n > 0 ) size = i; if( n > 1 ) { - for( j = 0; j < IM_NUMBER( units ); j++ ) + for( j = 0; j < VIPS_NUMBER( units ); j++ ) if( tolower( unit[0] ) == units[j].unit ) { size *= units[j].multiplier; break; @@ -568,7 +569,7 @@ lazy_image( Lazy *lazy ) disc_threshold() && !(vips_format_get_flags( lazy->format, lazy->out->filename ) & VIPS_FORMAT_PARTIAL) ) { - size_t size = IM_IMAGE_SIZEOF_LINE( lazy->out ) * + size_t size = VIPS_IMAGE_SIZEOF_LINE( lazy->out ) * lazy->out->Ysize; if( size > disc_threshold() ) { @@ -585,7 +586,7 @@ lazy_image( Lazy *lazy ) /* Otherwise, fall back to a "p". */ if( !image && - !(image = im_open( lazy->out->filename, "p" )) ) + !(image = vips_open( lazy->out->filename, "p" )) ) return( NULL ); return( image ); @@ -693,7 +694,7 @@ vips_attach_save( VipsImage *image, int (*save_fn)(), const char *filename ) { SaveBlock *sb; - if( (sb = IM_NEW( image, SaveBlock )) ) { + if( (sb = VIPS_NEW( image, SaveBlock )) ) { sb->save_fn = save_fn; sb->filename = im_strdup( image, filename ); g_signal_connect( image, "written", vips_image_save_cb, sb ); @@ -768,15 +769,15 @@ vips_image_add_progress( VipsImage *image ) if( im__progress || g_getenv( "IM_PROGRESS" ) ) { - Progress *progress = IM_NEW( image, Progress ); + Progress *progress = VIPS_NEW( image, Progress ); progress->image = image; g_signal_connect( image, "evalstart", - vips_image_evalstart_cb, progress ); + G_CALLBACK( vips_image_evalstart_cb ), progress ); g_signal_connect( image, "eval", - vips_image_eval_cb, progress ); + G_CALLBACK( vips_image_eval_cb ), progress ); g_signal_connect( image, "evalend", - vips_image_evalend_cb, progress ); + G_CALLBACK( vips_image_evalend_cb ), progress ); } } @@ -1157,18 +1158,18 @@ vips_image_posteval( VipsImage *image ) } /** - * im_open: + * vips_open: * @filename: file to open * @mode: mode to open with * - * im_open() examines the mode string, and creates an appropriate #IMAGE. + * vips_open() examines the mode string, and creates an appropriate #IMAGE. * * * * * "r" * opens the named file for reading. If the file is not in the native - * VIPS format for your machine, im_open() automatically converts the + * VIPS format for your machine, vips_open() automatically converts the * file for you in memory. * * For some large files (eg. TIFF) this may @@ -1177,7 +1178,7 @@ vips_image_posteval( VipsImage *image ) * API and control the loading process yourself. See * #VipsFormat. * - * im_open() can read files in most formats. + * vips_open() can read files in most formats. * * Note that "r" mode works in at least two stages. * It should return quickly and let you check header fields. It will @@ -1189,7 +1190,7 @@ vips_image_posteval( VipsImage *image ) * "rd" * opens the named file for reading. If the uncompressed image is larger * than a threshold and the file format does not support random access, - * rather than uncompressing to memory, im_open() will uncompress to a + * rather than uncompressing to memory, vips_open() will uncompress to a * temporary disc file. This file will be automatically deleted when the * IMAGE is closed. * @@ -1218,7 +1219,7 @@ vips_image_posteval( VipsImage *image ) * suffix to determine the type to write -- for example: * * |[ - * im_open( "fred.tif", "w" ) + * vips_open( "fred.tif", "w" ) * ]| * * will write in TIFF format. @@ -1252,7 +1253,7 @@ vips_image_posteval( VipsImage *image ) * Returns: the image descriptor on success and NULL on error. */ VipsImage * -im_open( const char *filename, const char *mode ) +vips_open( const char *filename, const char *mode ) { VipsImage *image;