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/README.md b/README.md index 5338bc80..2dd3da05 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,19 @@ and others. It supports a large range of numeric formats, from 8-bit int to JPEG, TIFF, PNG, WebP, FITS, Matlab, OpenEXR, DeepZoom, and OpenSlide. It can also load images via ImageMagick or GraphicsMagick. -It has APIs for C and C++ and comes with a Python -binding and a command-line interface. Bindings are -available for Ruby, JavaScript and others. There is full +It has APIs for +[C](http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-from-c.html) +and +[C++](http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-from-cpp.html) +and comes with a [Python +binding](http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-from-python.html) +and a [command-line +interface](http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-cli.html). +Bindings are available for [Ruby](https://rubygems.org/gems/ruby-vips), +JavaScript and others. There is full [documentation](http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/index.html). -There are several GUIs as well, see the -[VIPS website](http://www.vips.ecs.soton.ac.uk). +There are several GUIs as well, see the [VIPS +website](http://www.vips.ecs.soton.ac.uk). There are packages for most unix-like operating systems and binaries for Windows and OS X. @@ -38,11 +45,10 @@ libvips must have `build-essential`, `pkg-config`, `glib2.0-dev`, and For the vips8 Python binding, you must have `gobject-introspection`, `python-gi-dev`, and `libgirepository1.0-dev`. -You'll need the dev packages for the file format support you want. For basic -jpeg and tiff support, you'll need -`libtiff5-dev`, `libjpeg-turbo8-dev`, and `libgsf-1-dev`. -See the Dependencies section below for a full list of the things that -libvips can be configured to use. +You'll need the dev packages for the file format support you +want. For basic jpeg and tiff support, you'll need `libtiff5-dev`, +`libjpeg-turbo8-dev`, and `libgsf-1-dev`. See the Dependencies section +below for a full list of the things that libvips can be configured to use. Once `configure` is looking OK, compile and install with the usual: diff --git a/doc/gtk-doc.make b/doc/gtk-doc.make index e7916563..9ccd0b04 100644 --- a/doc/gtk-doc.make +++ b/doc/gtk-doc.make @@ -25,6 +25,7 @@ TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) SETUP_FILES = \ $(content_files) \ + $(expand_content_files) \ $(DOC_MAIN_SGML_FILE) \ $(DOC_MODULE)-sections.txt \ $(DOC_MODULE)-overrides.txt @@ -86,7 +87,7 @@ GTK_DOC_V_SETUP_0=@echo " DOC Preparing build"; setup-build.stamp: -$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ - files=`echo $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types`; \ + files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \ if test "x$$files" != "x" ; then \ for file in $$files ; do \ destdir=`dirname $(abs_builddir)/$$file`; \ @@ -118,7 +119,7 @@ scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB) $(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \ scanobj_options=""; \ gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$(?)" = "0"; then \ + if test "$$?" = "0"; then \ if test "x$(V)" = "x1"; then \ scanobj_options="--verbose"; \ fi; \ @@ -162,17 +163,17 @@ GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_$(V)) GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_$(AM_DEFAULT_VERBOSITY)) GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references"; -html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) +html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files) $(GTK_DOC_V_HTML)rm -rf html && mkdir html && \ mkhtml_options=""; \ gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$(?)" = "0"; then \ + if test "$$?" = "0"; then \ if test "x$(V)" = "x1"; then \ mkhtml_options="$$mkhtml_options --verbose"; \ fi; \ fi; \ gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \ - if test "$(?)" = "0"; then \ + if test "$$?" = "0"; then \ mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \ fi; \ cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) @@ -194,11 +195,11 @@ GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_$(V)) GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_$(AM_DEFAULT_VERBOSITY)) GTK_DOC_V_PDF_0=@echo " DOC Building PDF"; -pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) +pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files) $(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \ mkpdf_options=""; \ gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$(?)" = "0"; then \ + if test "$$?" = "0"; then \ if test "x$(V)" = "x1"; then \ mkpdf_options="$$mkpdf_options --verbose"; \ fi; \ @@ -223,12 +224,15 @@ clean-local: @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \ rm -f $(DOC_MODULE).types; \ fi + @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \ + rm -f $(DOC_MODULE)-sections.txt; \ + fi distclean-local: @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \ $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ - rm -f $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types; \ + rm -f $(SETUP_FILES) $(DOC_MODULE).types; \ fi maintainer-clean-local: 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..48fc8068 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 ); @@ -480,6 +482,9 @@ int vips_system( const char *cmd_format, ... ) */ VipsArrayImage *vips_array_image_new( VipsImage **array, int n ); VipsArrayImage *vips_array_image_newv( int n, ... ); +VipsArrayImage *vips_array_image_empty( void ); +VipsArrayImage *vips_array_image_append( VipsArrayImage *array, + VipsImage *image ); VipsImage **vips_array_image_get( VipsArrayImage *array, int *n ); VipsImage **vips_value_get_array_image( const GValue *value, int *n ); void vips_value_set_array_image( GValue *value, int n ); 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/include/vips/type.h b/libvips/include/vips/type.h index e43bdbfa..37ed6b3c 100644 --- a/libvips/include/vips/type.h +++ b/libvips/include/vips/type.h @@ -157,6 +157,7 @@ typedef struct _VipsBlob { VipsBlob *vips_blob_new( VipsCallbackFn free_fn, const void *data, size_t size ); +VipsBlob *vips_blob_copy( const void *data, size_t size ); const void *vips_blob_get( VipsBlob *blob, size_t *size ); GType vips_blob_get_type( void ); 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 ); diff --git a/libvips/iofuncs/type.c b/libvips/iofuncs/type.c index 751b448f..ee76916f 100644 --- a/libvips/iofuncs/type.c +++ b/libvips/iofuncs/type.c @@ -597,6 +597,32 @@ vips_blob_new( VipsCallbackFn free_fn, const void *data, size_t size ) return( (VipsBlob *) area ); } +/** + * vips_blob_copy: + * @data: (array length=size) (element-type guint8) (transfer none): data to store + * @size: number of bytes in @data + * + * Like vips_blob_new(), but take a copy of the data. Useful for bindings + * which strugle with callbacks. + * + * See also: vips_blob_new(). + * + * Returns: (transfer full): the new #VipsBlob. + */ +VipsBlob * +vips_blob_copy( const void *data, size_t size ) +{ + void *data_copy; + VipsArea *area; + + data_copy = vips_malloc( NULL, size ); + memcpy( data_copy, data, size ); + area = vips_area_new( (VipsCallbackFn) g_free, data_copy ); + area->length = size; + + return( (VipsBlob *) area ); +} + /** * vips_blob_get: * @blob: #VipsBlob to fetch from @@ -1179,6 +1205,63 @@ vips_array_image_newv( int n, ... ) return( (VipsArrayImage *) area ); } +/** + * vips_array_image_empty: + * + * Make an empty image array. + * Handy with vips_array_image_add() for bindings + * which can't handle object array arguments. + * + * See also: vips_array_image_add(). + * + * Returns: (transfer full): A new #VipsArrayImage. + */ +VipsArrayImage * +vips_array_image_empty( void ) +{ + return( vips_array_image_new( NULL, 0 ) ); +} + +/** + * vips_array_image_append: + * @array: (transfer none): append to this + * @image: add this + * + * Make a new #VipsArrayImage, one larger than @array, with @image appended + * to the end. + * Handy with vips_array_image_empty() for bindings + * which can't handle object array arguments. + * + * See also: vips_array_image_empty(). + * + * Returns: (transfer full): A new #VipsArrayImage. + */ +VipsArrayImage * +vips_array_image_append( VipsArrayImage *array, VipsImage *image ) +{ + VipsArea *old_area = VIPS_AREA( array ); + int n = old_area->n; + + VipsArea *new_area; + VipsImage **old_vector; + VipsImage **new_vector; + int i; + + new_area = vips_area_new_array_object( n + 1 ); + new_area->type = VIPS_TYPE_IMAGE; + + old_vector = vips_area_get_data( old_area, NULL, NULL, NULL, NULL ); + new_vector = vips_area_get_data( new_area, NULL, NULL, NULL, NULL ); + for( i = 0; i < n; i++ ) { + new_vector[i] = (VipsImage *) old_vector[i]; + g_object_ref( new_vector[i] ); + } + new_vector[i] = image; + g_object_ref( new_vector[i] ); + + return( (VipsArrayImage *) new_area ); +} + /** * vips_array_image_get: * @array: the #VipsArrayImage to fetch from diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 69686d33..75c75b82 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -1165,18 +1165,12 @@ vips__token_get( const char *p, VipsToken *token, char *string, int size ) return( NULL ); switch( (ch = p[0]) ) { - case '{': case '[': - case '(': - case '<': *token = VIPS_TOKEN_LEFT; p += 1; break; - case ')': case ']': - case '}': - case '>': *token = VIPS_TOKEN_RIGHT; p += 1; break;