diff --git a/ChangeLog b/ChangeLog index 36b7ef1d..37a38bd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 7/10/15 started 8.2.0 - added im_bufmagick2vips(), a vips7 wrapper for magick load from buffer - fetch unset property now returns default value rather than warning +- many more const declarations to help gobject-introspection 7/5/15 started 8.1.1 - oop, vips-8.0 should be vips-8.1, thanks Danilo diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 37f77d52..2c90622a 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -553,7 +553,7 @@ vips_foreign_load( const char *name, VipsImage **out, ... ) */ static void * vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, - void **buf, size_t *len ) + const void **buf, size_t *len ) { if( load_class->is_a_buffer && load_class->is_a_buffer( *buf, *len ) ) @@ -576,7 +576,7 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, * error. */ const char * -vips_foreign_find_load_buffer( void *data, size_t size ) +vips_foreign_find_load_buffer( const void *data, size_t size ) { VipsForeignLoadClass *load_class; @@ -630,7 +630,7 @@ vips_foreign_is_a( const char *loader, const char *filename ) * Returns: %TRUE if @data can be loaded by @loader. */ gboolean -vips_foreign_is_a_buffer( const char *loader, void *data, size_t size ) +vips_foreign_is_a_buffer( const char *loader, const void *data, size_t size ) { VipsObjectClass *class; VipsForeignLoadClass *load_class; diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index c61ceabd..b776f3a3 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -1157,7 +1157,7 @@ typedef struct { /* Private stuff during read. */ gboolean start_of_file; /* have we gotten any data yet? */ - JOCTET *buf; + const JOCTET *buf; size_t len; } InputBuffer; @@ -1288,7 +1288,7 @@ term_source (j_decompress_ptr cinfo) */ static void -readjpeg_buffer (ReadJpeg *jpeg, void *buf, size_t len) +readjpeg_buffer (ReadJpeg *jpeg, const void *buf, size_t len) { j_decompress_ptr cinfo = &jpeg->cinfo; InputBuffer *src; @@ -1320,7 +1320,7 @@ readjpeg_buffer (ReadJpeg *jpeg, void *buf, size_t len) } int -vips__jpeg_read_buffer( void *buf, size_t len, VipsImage *out, +vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out, gboolean header_only, int shrink, int fail, gboolean readbehind, gboolean autorotate ) { @@ -1344,9 +1344,9 @@ vips__jpeg_read_buffer( void *buf, size_t len, VipsImage *out, } int -vips__isjpeg_buffer( void *buf, size_t len ) +vips__isjpeg_buffer( const void *buf, size_t len ) { - guchar *str = (guchar *) buf; + const guchar *str = (const guchar *) buf; if( len >= 2 && str[0] == 0xff && diff --git a/libvips/foreign/jpegload.c b/libvips/foreign/jpegload.c index cc8cee83..3a5fa031 100644 --- a/libvips/foreign/jpegload.c +++ b/libvips/foreign/jpegload.c @@ -302,7 +302,7 @@ vips_foreign_load_jpeg_buffer_load( VipsForeignLoad *load ) } static gboolean -vips_foreign_load_jpeg_buffer_is_a( void *buf, size_t len ) +vips_foreign_load_jpeg_buffer_is_a( const void *buf, size_t len ) { return( vips__isjpeg_buffer( buf, len ) ); } diff --git a/libvips/foreign/magickload.c b/libvips/foreign/magickload.c index d2ec6ddb..b73efa0a 100644 --- a/libvips/foreign/magickload.c +++ b/libvips/foreign/magickload.c @@ -219,7 +219,7 @@ G_DEFINE_TYPE( VipsForeignLoadMagickBuffer, vips_foreign_load_magick_buffer, vips_foreign_load_magick_get_type() ); static gboolean -vips_foreign_load_magick_buffer_is_a_buffer ( void* buf, size_t len ) +vips_foreign_load_magick_buffer_is_a_buffer( const void *buf, size_t len ) { VipsImage *t; int result; diff --git a/libvips/foreign/tiff.h b/libvips/foreign/tiff.h index 50644094..06ae580e 100644 --- a/libvips/foreign/tiff.h +++ b/libvips/foreign/tiff.h @@ -55,12 +55,12 @@ int vips__tiff_read_header( const char *filename, VipsImage *out, int page ); int vips__tiff_read( const char *filename, VipsImage *out, int page, gboolean readbehind ); gboolean vips__istifftiled( const char *filename ); -gboolean vips__istiff_buffer( void *buf, size_t len ); +gboolean vips__istiff_buffer( const void *buf, size_t len ); gboolean vips__istiff( const char *filename ); -int vips__tiff_read_header_buffer( void *buf, size_t len, VipsImage *out, +int vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out, int page ); -int vips__tiff_read_buffer( void *buf, size_t len, VipsImage *out, +int vips__tiff_read_buffer( const void *buf, size_t len, VipsImage *out, int page, gboolean readbehind ); #ifdef __cplusplus diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index b1a24127..fb620d87 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -224,7 +224,7 @@ typedef struct _ReadTiff { /* Parameters. */ char *filename; - void *buf; + const void *buf; size_t len; VipsImage *out; int page; @@ -1870,7 +1870,7 @@ my_tiff_unmap( thandle_t st, tdata_t start, toff_t len ) } static ReadTiff * -readtiff_new_buffer( void *buf, size_t len, VipsImage *out, int page, +readtiff_new_buffer( const void *buf, size_t len, VipsImage *out, int page, gboolean readbehind ) { ReadTiff *rtiff; @@ -1991,7 +1991,7 @@ vips__istifftiled( const char *filename ) } gboolean -vips__istiff_buffer( void *buf, size_t len ) +vips__istiff_buffer( const void *buf, size_t len ) { char *str = (char *) buf; @@ -2018,7 +2018,8 @@ vips__istiff( const char *filename ) } int -vips__tiff_read_header_buffer( void *buf, size_t len, VipsImage *out, int page ) +vips__tiff_read_header_buffer( const void *buf, size_t len, + VipsImage *out, int page ) { ReadTiff *rtiff; @@ -2034,8 +2035,8 @@ vips__tiff_read_header_buffer( void *buf, size_t len, VipsImage *out, int page ) } int -vips__tiff_read_buffer( void *buf, size_t len, VipsImage *out, - int page, gboolean readbehind ) +vips__tiff_read_buffer( const void *buf, size_t len, + VipsImage *out, int page, gboolean readbehind ) { ReadTiff *rtiff; diff --git a/libvips/foreign/vipsjpeg.h b/libvips/foreign/vipsjpeg.h index 305ff5b2..9c86cb5c 100644 --- a/libvips/foreign/vipsjpeg.h +++ b/libvips/foreign/vipsjpeg.h @@ -48,12 +48,12 @@ int vips__jpeg_write_buffer( VipsImage *in, gboolean no_subsample, gboolean trellis_quant, gboolean overshoot_deringing, gboolean optimize_scans ); -int vips__isjpeg_buffer( void *buf, size_t len ); +int vips__isjpeg_buffer( const void *buf, size_t len ); int vips__isjpeg( const char *filename ); int vips__jpeg_read_file( const char *name, VipsImage *out, gboolean header_only, int shrink, gboolean fail, gboolean readbehind, gboolean autorotate ); -int vips__jpeg_read_buffer( void *buf, size_t len, VipsImage *out, +int vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out, gboolean header_only, int shrink, int fail, gboolean readbehind, gboolean autorotate ); diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 30ea4ab0..155d2032 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -147,7 +147,7 @@ typedef struct { /* For memory input. */ - char *buffer; + const void *buffer; size_t length; size_t read_pos; @@ -614,8 +614,8 @@ vips__png_read( const char *filename, VipsImage *out, gboolean readbehind ) return( 0 ); } -int -vips__png_ispng_buffer( void *buf, size_t len ) +gboolean +vips__png_ispng_buffer( const void *buf, size_t len ) { if( len >= 8 && !png_sig_cmp( (png_bytep) buf, 0, 8 ) ) @@ -650,7 +650,7 @@ vips_png_read_buffer( png_structp pPng, png_bytep data, png_size_t length ) } static Read * -read_new_buffer( VipsImage *out, char *buffer, size_t length, +read_new_buffer( VipsImage *out, const void *buffer, size_t length, gboolean readbehind ) { Read *read; @@ -677,7 +677,7 @@ read_new_buffer( VipsImage *out, char *buffer, size_t length, } int -vips__png_header_buffer( char *buffer, size_t length, VipsImage *out ) +vips__png_header_buffer( const void *buffer, size_t length, VipsImage *out ) { Read *read; @@ -689,7 +689,7 @@ vips__png_header_buffer( char *buffer, size_t length, VipsImage *out ) } int -vips__png_read_buffer( char *buffer, size_t length, VipsImage *out, +vips__png_read_buffer( const void *buffer, size_t length, VipsImage *out, gboolean readbehind ) { Read *read; diff --git a/libvips/foreign/vipspng.h b/libvips/foreign/vipspng.h index 843999b6..053aad6b 100644 --- a/libvips/foreign/vipspng.h +++ b/libvips/foreign/vipspng.h @@ -37,13 +37,14 @@ extern "C" { int vips__png_header( const char *name, VipsImage *out ); int vips__png_read( const char *name, VipsImage *out, gboolean readbehind ); -int vips__png_ispng_buffer( void *buf, size_t len ); +gboolean vips__png_ispng_buffer( const void *buf, size_t len ); int vips__png_ispng( const char *filename ); gboolean vips__png_isinterlaced( const char *filename ); extern const char *vips__png_suffs[]; -int vips__png_read_buffer( char *buffer, size_t length, VipsImage *out, - gboolean readbehind ); -int vips__png_header_buffer( char *buffer, size_t length, VipsImage *out ); +int vips__png_read_buffer( const void *buffer, size_t length, + VipsImage *out, gboolean readbehind ); +int vips__png_header_buffer( const void *buffer, size_t length, + VipsImage *out ); int vips__png_write( VipsImage *in, const char *filename, int compress, int interlace, const char *profile, diff --git a/libvips/foreign/webp.h b/libvips/foreign/webp.h index 28bf0906..1f750ec5 100644 --- a/libvips/foreign/webp.h +++ b/libvips/foreign/webp.h @@ -37,14 +37,16 @@ extern "C" { extern const char *vips__webp_suffs[]; -int vips__iswebp_buffer( void *buf, size_t len ); +int vips__iswebp_buffer( const void *buf, size_t len ); int vips__iswebp( const char *filename ); int vips__webp_read_file_header( const char *name, VipsImage *out ); int vips__webp_read_file( const char *name, VipsImage *out ); -int vips__webp_read_buffer_header( void *buf, size_t len, VipsImage *out ); -int vips__webp_read_buffer( void *buf, size_t len, VipsImage *out ); +int vips__webp_read_buffer_header( const void *buf, size_t len, + VipsImage *out ); +int vips__webp_read_buffer( const void *buf, size_t len, + VipsImage *out ); int vips__webp_write_file( VipsImage *out, const char *filename, int Q, gboolean lossless ); diff --git a/libvips/foreign/webp2vips.c b/libvips/foreign/webp2vips.c index 7c41808e..722195b8 100644 --- a/libvips/foreign/webp2vips.c +++ b/libvips/foreign/webp2vips.c @@ -69,10 +69,10 @@ typedef struct { */ char *filename; - /* Memory source. We se gint64 rather than size_t since we use + /* Memory source. We use gint64 rather than size_t since we use * vips_file_length() and vips__mmap() for file sources. */ - void *data; + const void *data; gint64 length; /* If we are opening a file object, the fd. @@ -89,7 +89,7 @@ typedef struct { } Read; int -vips__iswebp_buffer( void *buf, size_t len ) +vips__iswebp_buffer( const void *buf, size_t len ) { if( len >= MINIMAL_HEADER && WebPGetInfo( buf, MINIMAL_HEADER, NULL, NULL ) ) @@ -132,7 +132,7 @@ read_free( Read *read ) } static Read * -read_new( const char *filename, void *data, size_t length ) +read_new( const char *filename, const void *data, size_t length ) { Read *read; @@ -266,7 +266,7 @@ vips__webp_read_file( const char *filename, VipsImage *out ) } int -vips__webp_read_buffer_header( void *buf, size_t len, VipsImage *out ) +vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out ) { Read *read; @@ -285,7 +285,7 @@ vips__webp_read_buffer_header( void *buf, size_t len, VipsImage *out ) } int -vips__webp_read_buffer( void *buf, size_t len, VipsImage *out ) +vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out ) { Read *read; diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index 554e213d..4ba61e5f 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -166,7 +166,7 @@ typedef struct _VipsForeignLoadClass { * This function should return %TRUE if the buffer contains an image of * this type. */ - gboolean (*is_a_buffer)( void *data, size_t size ); + gboolean (*is_a_buffer)( const void *data, size_t size ); /* Get the flags from a filename. * @@ -214,11 +214,12 @@ typedef struct _VipsForeignLoadClass { GType vips_foreign_load_get_type( void ); const char *vips_foreign_find_load( const char *filename ); -const char *vips_foreign_find_load_buffer( void *data, size_t size ); +const char *vips_foreign_find_load_buffer( const void *data, size_t size ); VipsForeignFlags vips_foreign_flags( const char *loader, const char *filename ); gboolean vips_foreign_is_a( const char *loader, const char *filename ); -gboolean vips_foreign_is_a_buffer( const char *loader, void *data, size_t size ); +gboolean vips_foreign_is_a_buffer( const char *loader, + const void *data, size_t size ); #define VIPS_TYPE_FOREIGN_SAVE (vips_foreign_save_get_type()) #define VIPS_FOREIGN_SAVE( obj ) \ diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index e4d6b657..f47982cc 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -427,15 +427,17 @@ VipsImage *vips_image_new_from_file( const char *name, ... ) VipsImage *vips_image_new_from_file_RW( const char *filename ); VipsImage *vips_image_new_from_file_raw( const char *filename, int xsize, int ysize, int bands, guint64 offset ); -VipsImage *vips_image_new_from_memory( void *data, size_t size, +VipsImage *vips_image_new_from_memory( const void *data, size_t size, int width, int height, int bands, VipsBandFormat format ); -VipsImage *vips_image_new_from_buffer( void *buf, size_t len, +VipsImage *vips_image_new_from_buffer( const void *buf, size_t len, const char *option_string, ... ) __attribute__((sentinel)); VipsImage *vips_image_new_matrix( int width, int height ); VipsImage *vips_image_new_matrixv( int width, int height, ... ); VipsImage *vips_image_new_matrix_from_array( int width, int height, - double *array, int size ); + const double *array, int size ); +VipsImage *vips_image_matrix_from_array( int width, int height, + const double *array, int size ); void vips_image_set_delete_on_close( VipsImage *image, gboolean delete_on_close ); guint64 vips_get_disc_threshold( void ); diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index c0bce202..bd36c0af 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -127,7 +127,7 @@ char *vips__b64_encode( const unsigned char *data, size_t data_length ); unsigned char *vips__b64_decode( const char *buffer, size_t *data_length ); void *vips__mmap( int fd, int writeable, size_t length, gint64 offset ); -int vips__munmap( void *start, size_t length ); +int vips__munmap( const void *start, size_t length ); int vips_mapfile( VipsImage * ); int vips_mapfilerw( VipsImage * ); int vips_remapfilerw( VipsImage * ); diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 563e79aa..5969857b 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -1873,7 +1873,7 @@ vips_filename_get_options( const char *vips_filename ) * See also: vips_foreign_find_load(), vips_foreign_is_a(), * vips_image_write_to_file(). * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * vips_image_new_from_file( const char *name, ... ) @@ -1910,7 +1910,7 @@ vips_image_new_from_file( const char *name, ... ) * * See also: vips_draw_circle(). * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * vips_image_new_from_file_RW( const char *filename ) @@ -1934,7 +1934,7 @@ vips_image_new_from_file_RW( const char *filename ) * * See also: vips_copy(), vips_rawload(), vips_image_new_from_file(). * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * vips_image_new_from_file_raw( const char *filename, @@ -1963,7 +1963,7 @@ vips_image_new_from_file_raw( const char *filename, /** * vips_image_new_from_memory: - * @data: (array length=size) (element-type guint8) (transfer full): start of memory area + * @data: (array length=size) (element-type guint8) (transfer none): start of memory area * @size: length of memory area * @width: image width * @height: image height @@ -1983,10 +1983,10 @@ vips_image_new_from_file_raw( const char *filename, * * See also: vips_image_new(), vips_image_write_to_memory(). * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * -vips_image_new_from_memory( void *data, size_t size, +vips_image_new_from_memory( const void *data, size_t size, int width, int height, int bands, VipsBandFormat format ) { VipsImage *image; @@ -2026,7 +2026,7 @@ vips_image_new_from_memory( void *data, size_t size, /** * vips_image_new_from_buffer: - * @buf: start of memory buffer + * @buf: (array length=len) (element-type guint8) (transfer none): image data * @len: length of memory buffer * @option_string: set of extra options as a string * @...: %NULL-terminated list of optional named arguments @@ -2046,10 +2046,10 @@ vips_image_new_from_memory( void *data, size_t size, * * See also: vips_image_write_to_buffer(). * - * Returns: 0 on success, -1 on error + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * -vips_image_new_from_buffer( void *buf, size_t len, +vips_image_new_from_buffer( const void *buf, size_t len, const char *option_string, ... ) { const char *operation_name; @@ -2094,7 +2094,7 @@ vips_image_new_from_buffer( void *buf, size_t len, * * See also: vips_image_new_matrixv() * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * vips_image_new_matrix( int width, int height ) @@ -2138,7 +2138,7 @@ vips_image_new_matrix( int width, int height ) * * See also: vips_image_new_matrix() * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * vips_image_new_matrixv( int width, int height, ... ) @@ -2169,11 +2169,11 @@ vips_image_new_matrixv( int width, int height, ... ) * * A binding-friendly version of vips_image_new_matrixv(). * - * Returns: the new #VipsImage, or %NULL on error. + * Returns: (transfer full): the new #VipsImage, or %NULL on error. */ VipsImage * vips_image_new_matrix_from_array( int width, int height, - double *array, int size ) + const double *array, int size ) { VipsImage *matrix; int x, y; @@ -2198,6 +2198,26 @@ vips_image_new_matrix_from_array( int width, int height, return( matrix ); } +/** + * vips_image_matrix_from_array: + * @width: image width + * @height: image height + * @array: (array length=size) (transfer none): array of elements + * @size: number of elements + * + * A renamed vips_image_new_matrix_from_array(). Some gobject bindings do not + * like more than one _new method. + * + * Returns: (transfer full): the new #VipsImage, or %NULL on error. + */ +VipsImage * +vips_image_matrix_from_array( int width, int height, + const double *array, int size ) +{ + return( vips_image_new_matrix_from_array( width, height, + array, size ) ); +} + /** * vips_image_set_delete_on_close: * @image: image to set diff --git a/libvips/iofuncs/mapfile.c b/libvips/iofuncs/mapfile.c index 38a36554..3c7c3e3d 100644 --- a/libvips/iofuncs/mapfile.c +++ b/libvips/iofuncs/mapfile.c @@ -189,16 +189,16 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset ) } int -vips__munmap( void *start, size_t length ) +vips__munmap( const void *start, size_t length ) { #ifdef OS_WIN32 - if( !UnmapViewOfFile( start ) ) { + if( !UnmapViewOfFile( (void *) start ) ) { vips_error_system( GetLastError(), "vips_mapfile", "%s", _( "unable to UnmapViewOfFile" ) ); return( -1 ); } #else /*!OS_WIN32*/ - if( munmap( start, length ) < 0 ) { + if( munmap( (void *) start, length ) < 0 ) { vips_error_system( errno, "vips_mapfile", "%s", _( "unable to munmap file" ) ); return( -1 );