diff --git a/.travis.yml b/.travis.yml index 7e99cecd..29520296 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ script: - make -Ctest -j$JOBS -s V=0 VERBOSE=1 check matrix: + allow_failures: + - os: osx fast_finish: true include: - os: linux diff --git a/ChangeLog b/ChangeLog index 77c44950..19658e4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,10 +23,14 @@ - better svgload: larger output, handle missing width/height, thanks lovell - add vips_gravity() ... embed, but with direction rather than position - vips_text() can autofit text to a box, thanks gargsms +- add vips_composite(): merge an array of images with porter-duff +- better gobject-introspection annotations, thanks astavale 29/8/17 started 8.5.9 - make --fail stop jpeg read on any libjpeg warning, thanks @mceachen -- don't build enumtypes so often, removing perl as a compile dependancy +- don't build enumtypes so often -- helps remove perl as a compile dependency +- fix a crash with havy use of draw operations from language bindings, + thanks @Nakilon 2/8/17 started 8.5.8 - fix transparency detection in merge, thanks Haida @@ -540,7 +544,7 @@ - vips_system() now supports many input images and you can change image argument order - support 16-bit palette TIFFs, plus palette TIFFs can have an alpha -- libgsf-1 is now an optional dependancy +- libgsf-1 is now an optional dependency - dzsave can directly write a ZIP file - add ".vips" as an alternative suffix for vips files - added vips_tiffload_buffer() @@ -1204,9 +1208,9 @@ - fix gtk-doc warnings - small mask load/save improvements - mask gtk-doc done -- add cfitsio dependancy +- add cfitsio dependency - add FITS reader -- land the vector branch and the orc dependancy ... we have SSE +- land the vector branch and the orc dependency ... we have SSE erode/dilate/add/conv - add IM_SWAP - dilate/erode do (!=0) on non-uchar images @@ -2059,7 +2063,7 @@ - "," allowed as column separator in mask read - better at spotting singular matricies - small im_render() tidies -- glib dependancy reduced to just 2.0, but untested ... helps people building +- glib dependency reduced to just 2.0, but untested ... helps people building on older systems who aren't interested in nip2 - removing leading spaces from IMAGEVEC arguments - load non-interlaced PNGs more efficiently diff --git a/README.md b/README.md index 917d5783..571ce00e 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Clang dynamic analysis: Build with the GCC auto-vectorizer and diagnostics (or just -O3): - $ FLAGS="-O2 -msse4.2 -ffast-math" + $ FLAGS="-O2 -march=native -ffast-math" $ FLAGS="$FLAGS -ftree-vectorize -fdump-tree-vect-details" $ CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \ ./configure --prefix=/home/john/vips diff --git a/configure.ac b/configure.ac index e05cd3d3..b64ac8ca 100644 --- a/configure.ac +++ b/configure.ac @@ -60,8 +60,8 @@ GOBJECT_INTROSPECTION_CHECK([1.30.0]) # # build with a glob and a list of files to exclude from scanning # see also IGNORE_HFILES in doc/Makefile.am -introspection_sources=$(cd libvips ; find . -name "*.c") -filter_list="deprecated " +introspection_sources=$(cd libvips ; find . -name "*.c"; find . -name "*.cpp") +filter_list="deprecated introspect.c dummy.c fuzz " # contains(string, substring) # @@ -101,18 +101,23 @@ headers="\ image.h \ error.h \ foreign.h \ + freqfilt.h \ interpolate.h \ header.h \ + histogram.h \ operation.h \ enumtypes.h \ conversion.h \ arithmetic.h \ colour.h \ convolution.h \ + create.h \ draw.h \ morphology.h \ + mosaicing.h \ type.h \ rect.h \ + resample.h \ memory.h \ region.h" @@ -253,8 +258,6 @@ AC_PROG_AWK AC_PROG_CC AC_PROG_CC_STDC AC_PROG_CXX -AC_C_CONST -AC_C_RESTRICT AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_LN_S @@ -302,6 +305,29 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", ALL_LINGUAS="en_GB de" AM_GLIB_GNU_GETTEXT +# we need to disable some features on some known-bad gcc versions +# these will be "" for clang etc. +# +# I couldn't get this to work, mysterious! do it ourselves +# +# AX_CHECK_COMPILE_FLAG([-dumpversion], +# [ax_gcc_version_option=yes], +# [ax_gcc_version_option=no] +# ) +AC_MSG_CHECKING([for gcc version]) +GCC_VERSION="" +version=$($CC -dumpversion) +if test $? = 0; then + GCC_VERSION=$version + AC_MSG_RESULT([$GCC_VERSION]) +else + AC_MSG_RESULT([-dumpversion not supported]) +fi + +GCC_VERSION_MAJOR=$(echo $GCC_VERSION | cut -d'.' -f1) +GCC_VERSION_MINOR=$(echo $GCC_VERSION | cut -d'.' -f2) +GCC_VERSION_PATCH=$(echo $GCC_VERSION | cut -d'.' -f3) + # Checks for libraries. # build list of pkg-config packages we used here @@ -333,11 +359,69 @@ AC_PROVIDE([AC_LIBTOOL_WIN32_DLL]) AC_PROG_LIBTOOL # Checks for typedefs, structures, and compiler characteristics. +AC_C_RESTRICT +AX_GCC_VAR_ATTRIBUTE(vector_size) AC_C_CONST AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_SIZE_T +# g++/gcc 4.x have rather broken vector support +AC_MSG_CHECKING([for gcc with working vector support]) +if test x$GCC_VERSION_MAJOR != x"4"; then + AC_MSG_RESULT([yes]) +else + ax_cv_have_var_attribute_vector_size=no + AC_MSG_RESULT([no]) +fi + +# we need to be able to shuffle vectors in C++ +if test x$ax_cv_have_var_attribute_vector_size = x"yes"; then + AC_MSG_CHECKING([for C++ vector shuffle]) + AC_LANG_PUSH([C++]) + AC_TRY_COMPILE([ + typedef float v4f __attribute__((vector_size(4 * sizeof(float)))); + ],[ + v4f f; f[3] = 99; + ],[ + AC_MSG_RESULT([yes]) + have_vector_shuffle=yes + ], [ + AC_MSG_RESULT([no]) + have_vector_shuffle=no + ]) + AC_LANG_POP([C++]) + + if test x$have_vector_shuffle = x"yes"; then + AC_DEFINE_UNQUOTED(HAVE_VECTOR_SHUFFLE, 1, + [define if your C++ can shuffle vectors]) + fi +fi + +# we also need to be able to mix vector and scalar arithmetic +if test x$have_vector_shuffle = x"yes"; then + AC_MSG_CHECKING([for C++ vector arithmetic]) + AC_LANG_PUSH([C++]) + AC_TRY_COMPILE([ + typedef float v4f __attribute__((vector_size(4 * sizeof(float)))); + ],[ + v4f f = {1, 2, 3, 4}; f *= 12.0; + v4f g = {5, 6, 7, 8}; f = g > 0 ? g : -1 * g; + ],[ + AC_MSG_RESULT([yes]) + have_vector_arith=yes + ], [ + AC_MSG_RESULT([no]) + have_vector_arith=no + ]) + AC_LANG_POP([C++]) + + if test x$have_vector_arith = x"yes"; then + AC_DEFINE_UNQUOTED(HAVE_VECTOR_ARITH, 1, + [define if your C++ can mix vector and scalar arithmetic]) + fi +fi + # Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_MMAP @@ -961,40 +1045,43 @@ if test x"$with_libexif" != "xno"; then CPPFLAGS="$save_CPPFLAGS" fi -# make python binding? -with_python="no (default)" -AC_ARG_WITH([python], - AS_HELP_STRING([--with-python], - [build with vips7 Python bindings (default: no)])) +# make vips7 (swig-based) py binding +AC_ARG_ENABLE([pyvips7], + AS_HELP_STRING([--enable-pyvips7], [build vips7 Python binding (default: no)]), + [enable_pyvips7=$enableval + ], + [enable_pyvips7="no (default)" + ] +) -if test x"$with_python" = x"yes"; then +if test x"$enable_pyvips7" = x"yes"; then if test x"$enable_cxx" = x"no"; then # if C++ is off, we can't do Python - with_python=no + enable_pyvips7=no AC_MSG_WARN([C++ is off, disabling vips7 Python binding]) fi fi -if test x"$with_python" = x"yes"; then +if test x"$enable_pyvips7" = x"yes"; then JD_PATH_PYTHON(2.7,, - [with_python=no + [enable_pyvips7=no AC_MSG_WARN([Python >= 2.7 not found; disabling vips7 Python binding]) ] ) fi -if test x"$with_python" = x"yes"; then +if test x"$enable_pyvips7" = x"yes"; then # The SWIG bindings don't compile on python3 (see issue #334). AM_PYTHON_CHECK_VERSION([$PYTHON], [3.0], - [with_python=no + [enable_pyvips7=no AC_MSG_WARN([Python >= 3.0 found; disabling vips7 Python binding]) ] ) fi -if test x"$with_python" = x"yes"; then +if test x"$enable_pyvips7" = x"yes"; then AM_CHECK_PYTHON_HEADERS(, - [with_python=no + [enable_pyvips7=no AC_MSG_WARN([Python headers not found; disabling vips7 Python binding]) ] ) @@ -1003,7 +1090,7 @@ fi # we don't check for swig: we include the generated bindings in the # distribution -if test x"$with_python" = x"yes"; then +if test x"$enable_pyvips7" = x"yes"; then AM_CONDITIONAL(HAVE_PYTHON, true) else AM_CONDITIONAL(HAVE_PYTHON, false) @@ -1093,7 +1180,7 @@ enable debug: $enable_debug build deprecated components: $enable_deprecated build docs with gtkdoc: $enable_gtk_doc gobject introspection: $found_introspection -build vips7 Python binding: $with_python +build vips7 Python binding: $enable_pyvips7 install vips8 Python overrides: $enable_pyvips8 (requires pygobject-3.13.0 or later) build radiance support: $with_radiance diff --git a/cplusplus/VImage.cpp b/cplusplus/VImage.cpp index 93b2e56e..da1eef17 100644 --- a/cplusplus/VImage.cpp +++ b/cplusplus/VImage.cpp @@ -205,6 +205,30 @@ VOption::set( const char *name, std::vector value ) return( this ); } +// input int array +VOption * +VOption::set( const char *name, std::vector value ) +{ + Pair *pair = new Pair( name ); + + int *array; + unsigned int i; + + pair->input = true; + + g_value_init( &pair->value, VIPS_TYPE_ARRAY_INT ); + vips_value_set_array_int( &pair->value, NULL, + static_cast< int >( value.size() ) ); + array = vips_value_get_array_int( &pair->value, NULL ); + + for( i = 0; i < value.size(); i++ ) + array[i] = value[i]; + + options.push_back( pair ); + + return( this ); +} + // input image array VOption * VOption::set( const char *name, std::vector value ) @@ -465,8 +489,7 @@ VImage::call_option_string( const char *operation_name, operation_name ); if( !(operation = vips_operation_new( operation_name )) ) { - if( options ) - delete options; + delete options; throw( VError() ); } @@ -671,6 +694,17 @@ VImage::bandjoin( VImage other, VOption *options ) return( bandjoin( vec, options ) ); } +VImage +VImage::composite( VImage other, VipsBlendMode mode, VOption *options ) +{ + VImage v[2] = { *this, other }; + std::vector ivec( v, v + VIPS_NUMBER( v ) ); + int m[1] = { static_cast( mode ) }; + std::vector mvec( m, m + VIPS_NUMBER( m ) ); + + return( composite( ivec, mvec, options ) ); +} + std::complex VImage::minpos( VOption *options ) { diff --git a/cplusplus/gen-operators.py b/cplusplus/gen-operators.py index 9be011fb..b8eea7a3 100755 --- a/cplusplus/gen-operators.py +++ b/cplusplus/gen-operators.py @@ -37,6 +37,7 @@ gtype_to_cpp = { "gdouble" : "double", "gboolean" : "bool", "gchararray" : "char *", + "VipsArrayInt" : "std::vector", "VipsArrayDouble" : "std::vector", "VipsArrayImage" : "std::vector", "VipsBlob" : "VipsBlob *" diff --git a/cplusplus/include/vips/VImage8.h b/cplusplus/include/vips/VImage8.h index be30f09e..578504cc 100644 --- a/cplusplus/include/vips/VImage8.h +++ b/cplusplus/include/vips/VImage8.h @@ -219,6 +219,7 @@ public: VOption *set( const char *name, VInterpolate value ); VOption *set( const char *name, std::vector value ); VOption *set( const char *name, std::vector value ); + VOption *set( const char *name, std::vector value ); VOption *set( const char *name, VipsBlob *value ); VOption *set( const char *name, bool *value ); @@ -541,6 +542,9 @@ public: return( bandjoin_const( other, options ) ); } + VImage composite( VImage other, VipsBlendMode mode, + VOption *options = 0 ); + std::complex minpos( VOption *options = 0 ); std::complex maxpos( VOption *options = 0 ); diff --git a/cplusplus/include/vips/gen-operators-h.py b/cplusplus/include/vips/gen-operators-h.py index aa0a96d0..cb62a018 100755 --- a/cplusplus/include/vips/gen-operators-h.py +++ b/cplusplus/include/vips/gen-operators-h.py @@ -27,6 +27,7 @@ gtype_to_cpp = { "gdouble" : "double", "gboolean" : "bool", "gchararray" : "char *", + "VipsArrayInt" : "std::vector", "VipsArrayDouble" : "std::vector", "VipsArrayImage" : "std::vector", "VipsBlob" : "VipsBlob *" diff --git a/cplusplus/include/vips/vips-operators.h b/cplusplus/include/vips/vips-operators.h index 68df252a..76adb9e8 100644 --- a/cplusplus/include/vips/vips-operators.h +++ b/cplusplus/include/vips/vips-operators.h @@ -1,5 +1,5 @@ // headers for vips operations -// Mon 13 Mar 13:22:09 GMT 2017 +// Fri 6 Oct 16:31:27 BST 2017 // this file is generated automatically, do not edit! static void system( char * cmd_format , VOption *options = 0 ); @@ -40,6 +40,7 @@ VImage project( VImage * rows , VOption *options = 0 ); VImage profile( VImage * rows , VOption *options = 0 ); VImage measure( int h , int v , VOption *options = 0 ); std::vector getpoint( int x , int y , VOption *options = 0 ); +int find_trim( int * top , int * width , int * height , VOption *options = 0 ); VImage copy( VOption *options = 0 ); VImage tilecache( VOption *options = 0 ); VImage linecache( VOption *options = 0 ); @@ -79,6 +80,7 @@ VImage msb( VOption *options = 0 ); VImage byteswap( VOption *options = 0 ); VImage falsecolour( VOption *options = 0 ); VImage gamma( VOption *options = 0 ); +static VImage composite( std::vector in , std::vector mode , VOption *options = 0 ); static VImage black( int width , int height , VOption *options = 0 ); static VImage gaussnoise( int width , int height , VOption *options = 0 ); static VImage text( char * text , VOption *options = 0 ); @@ -156,6 +158,7 @@ VipsBlob * tiffsave_buffer( VOption *options = 0 ); void fitssave( char * filename , VOption *options = 0 ); static VImage thumbnail( char * filename , int width , VOption *options = 0 ); static VImage thumbnail_buffer( VipsBlob * buffer , int width , VOption *options = 0 ); +VImage thumbnail_image( int width , VOption *options = 0 ); VImage mapim( VImage index , VOption *options = 0 ); VImage shrink( double hshrink , double vshrink , VOption *options = 0 ); VImage shrinkh( int hshrink , VOption *options = 0 ); diff --git a/cplusplus/vips-operators.cpp b/cplusplus/vips-operators.cpp index bff2a745..b0fdc783 100644 --- a/cplusplus/vips-operators.cpp +++ b/cplusplus/vips-operators.cpp @@ -1,5 +1,5 @@ // bodies for vips operations -// Mon 13 Mar 13:22:17 GMT 2017 +// Fri 6 Oct 16:30:42 BST 2017 // this file is generated automatically, do not edit! void VImage::system( char * cmd_format , VOption *options ) @@ -487,6 +487,21 @@ std::vector VImage::getpoint( int x , int y , VOption *options ) return( out_array ); } +int VImage::find_trim( int * top , int * width , int * height , VOption *options ) +{ + int left; + + call( "find_trim" , + (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "left", &left ) -> + set( "top", top ) -> + set( "width", width ) -> + set( "height", height ) ); + + return( left ); +} + VImage VImage::copy( VOption *options ) { VImage out; @@ -988,6 +1003,19 @@ VImage VImage::gamma( VOption *options ) return( out ); } +VImage VImage::composite( std::vector in , std::vector mode , VOption *options ) +{ + VImage out; + + call( "composite" , + (options ? options : VImage::option()) -> + set( "in", in ) -> + set( "out", &out ) -> + set( "mode", mode ) ); + + return( out ); +} + VImage VImage::black( int width , int height , VOption *options ) { VImage out; @@ -1904,6 +1932,19 @@ VImage VImage::thumbnail_buffer( VipsBlob * buffer , int width , VOption *option return( out ); } +VImage VImage::thumbnail_image( int width , VOption *options ) +{ + VImage out; + + call( "thumbnail_image" , + (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "out", &out ) -> + set( "width", width ) ); + + return( out ); +} + VImage VImage::mapim( VImage index , VOption *options ) { VImage out; diff --git a/doc/Makefile.am b/doc/Makefile.am index 60597702..befd7ce2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -148,6 +148,7 @@ markdown_content_files = \ How-it-opens-files.md \ Examples.md \ Cite.md \ + binding.md \ Making-image-pyramids.md # converted to xml in this dir by pandoc @@ -159,13 +160,11 @@ content_files = \ using-command-line.xml \ using-C.xml \ using-threads.xml \ - using-python.xml \ using-cpp.xml \ extending.xml \ function-list.xml \ file-format.xml \ - ${markdown_content_files_docbook} \ - binding.xml + ${markdown_content_files_docbook} # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files @@ -174,13 +173,11 @@ expand_content_files = \ using-command-line.xml \ using-C.xml \ using-threads.xml \ - using-python.xml \ using-cpp.xml \ extending.xml \ function-list.xml \ file-format.xml \ - ${markdown_content_files_docbook} \ - binding.xml + ${markdown_content_files_docbook} # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget diff --git a/doc/binding.md b/doc/binding.md new file mode 100644 index 00000000..da81d782 --- /dev/null +++ b/doc/binding.md @@ -0,0 +1,219 @@ + + How to write bindings + 3 + libvips + + + + Binding + Writing bindings for libvips + + +There are full libvips bindings for quite a few environments now: C, C++, +command-line, Ruby, PHP, Python and JavaScript (node). + +This chapter runs through the four main styles that have been found to work +well. If you want to write a new binding, one of these should be close +to what you need. + +# C API + +The libvips C API (vips_add() and so on) is very inconvenient to use from other +languages due to its heavy use of varargs. + +It's much better to use the layer below. This lower layer is structured as: +create operator, set parameters, execute, extract results. For example, you can +execute vips_invert() like this: + +```C +/* compile with + * + * gcc -g -Wall callvips.c `pkg-config vips --cflags --libs` + * + */ + +#include + +int +main( int argc, char **argv ) +{ + VipsImage *in; + VipsImage *out; + VipsOperation *op; + VipsOperation *new_op; + GValue gvalue = { 0 }; + + if( VIPS_INIT( argv[0] ) ) + /* This shows the vips error buffer and quits with a fail exit + * code. + */ + vips_error_exit( NULL ); + + /* This will print a table of any ref leaks on exit, very handy for + * development. + */ + vips_leak_set( TRUE ); + + if( argc != 3 ) + vips_error_exit( "usage: %s input-filename output-filename", + argv[0] ); + + if( !(in = vips_image_new_from_file( argv[1], NULL )) ) + vips_error_exit( NULL ); + + /* Create a new operator from a nickname. NULL for unknown operator. + */ + op = vips_operation_new( "invert" ); + + /* Init a gvalue as an image, set it to in, use the gvalue to set the + * operator property. + */ + g_value_init( &gvalue, VIPS_TYPE_IMAGE ); + g_value_set_object( &gvalue, in ); + g_object_set_property( G_OBJECT( op ), "in", &gvalue ); + g_value_unset( &gvalue ); + + /* We no longer need in: op will hold a ref to it as long as it needs + * it. + */ + g_object_unref( in ); + + /* Call the operation. This will look up the operation+args in the vips + * operation cache and either return a previous operation, or build + * this one. In either case, we have a new ref we mst release. + */ + if( !(new_op = vips_cache_operation_build( op )) ) { + g_object_unref( op ); + vips_error_exit( NULL ); + } + g_object_unref( op ); + op = new_op; + + /* Now get the result from op. g_value_get_object() does not ref the + * object, so we need to make a ref for out to hold. + */ + g_value_init( &gvalue, VIPS_TYPE_IMAGE ); + g_object_get_property( G_OBJECT( op ), "out", &gvalue ); + out = VIPS_IMAGE( g_value_get_object( &gvalue ) ); + g_object_ref( out ); + g_value_unset( &gvalue ); + + /* All done: we can unref op. The output objects from op actually hold + * refs back to it, so before we can unref op, we must unref them. + */ + vips_object_unref_outputs( VIPS_OBJECT( op ) ); + g_object_unref( op ); + + if( vips_image_write_to_file( out, argv[2], NULL ) ) + vips_error_exit( NULL ); + + g_object_unref( out ); + + return( 0 ); +} +``` + +libvips has a couple of extra things to let you fetch the arguments and types +of an operator. Use vips_lib.vips_argument_map() to loop over all the arguments +of an operator, and vips_object_get_argument() to fetch the type and flags +of a specific argument. + +Use vips_operation_get_flags() to get general information about an operator. + +# Compiled language which can call C + +The C++ binding uses this lower layer to define a function called +`VImage::call()` which can call any libvips operator with a not-varargs set of +variable arguments. + +A small Python program walks the set of all libvips operators and generates a +set of static bindings. For example: + +```c++ +VImage VImage::invert( VOption *options ) +{ + VImage out; + + call( "invert", (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "out", &out ) ); + + return( out ); +} +``` + +So from C++ you can call any libvips operator, though without type-safety, with +`VImage::call()`, or use the member functions on `VImage` to get type-safe +calls for at least the required operator arguments. + +The `VImage` class also adds automatic reference counting, constant expansion, +operator overloads, and various other useful features. + +# Dynamic language with FFI + +Languages like Ruby, Python, JavaScript and Lua can't call C directly, but +they do support FFI. The bindings for these languages work rather like C++, +but use FFI to call into libvips and run operations. + +Since these languages are dynamic, they can add another trick: they intercept +the method-missing hook and attempt to run any method calls not implemented by +the `Image` class as libvips operators. This makes these bindings self-writing: +they only contain a small amount of codeand just expose everything they find in +the libvips class hierarchy. + +# Dynamic langauge without FFI + +PHP does not have FFI, unfortunately, so for this language a small native +module implements the general `vips_call()` function for PHP language types, +and a larger pure PHP layer makes it convenient to use. + +# `gobject-introspection` + +The C source code to libvips has been marked up with special comments +describing the interface in a standard way. These comments are read by +the `gobject-introspection` package when libvips is compiled and used to +generate a typelib, a description of how to call the library. Many languages +have gobject-introspection packages: all you need to do to call libvips +from your favorite language is to start g-o-i, load the libvips typelib, +and you should have the whole library available. For example, from Python +it's as simple as: + +```python +from gi.repository import Vips +``` + +You can now use all of the libvips introspection machinery, as noted above. + +Unfortunately g-o-i has some strong disadvantages. It is not very portable, +since you will need a g-o-i layer for whatever platform you are targetting; +it does not cross-compile well, since typelibs include a lot of very-low +level data (such as exact structure layouts); and installation for your +users is likely to be tricky. + +If you have a choice, I would recommend simply using FFI. + +# Documentation + +You can generate searchable docs from a .gir (the thing that +is built from scanning libvips and which in turn turn the typelib is +made from) with g-ir-doc-tool, for example: + +``` +$ g-ir-doc-tool --language=Python -o ~/mydocs Vips-8.0.gir +``` + +Then to view them, either: + +``` +$ yelp ~/mydocs +``` + +Or perhaps: + +``` +$ cd ~/mydocs +$ yelp-build html . +``` + +To make HTML docs. This is an easy way to see what you can call in the +library. diff --git a/doc/binding.xml b/doc/binding.xml index bf547fb0..6ed37b94 100644 --- a/doc/binding.xml +++ b/doc/binding.xml @@ -1,94 +1,208 @@ - - - - - - Writing bindings for libvips - 3 - VIPS Library - + + + - - Binding - How to write bindings for libvips - - - Binding and gobject-introspection - - The C source code - to libvips has been marked up with special comments describing the - interface in a standard way. These comments are read by - gobject-introspection - when libvips is compiled and used to generate a - typelib, a description of how to call the library. Many languages have - gobject-introspection packages: all you need to do to call libvips - from your favorite language is to start g-o-i, load the libvips typelib, - and you should have the whole library available. For example, from - Python it's as simple as: + + How to write bindings 3 libvips + + + Binding Writing bindings for libvips + + + There are full libvips bindings for quite a few environments now: C, C++, command-line, Ruby, PHP, Python and JavaScript (node). + + + This chapter runs through the four main styles that have been found to work well. If you want to write a new binding, one of these should be close to what you need. + + + C API + + The libvips C API (vips_add() and so on) is very inconvenient to use from other languages due to its heavy use of varargs. + + + It’s much better to use the layer below. This lower layer is structured as: create operator, set parameters, execute, extract results. For example, you can execute vips_invert() like this: + + +/* compile with + * + * gcc -g -Wall callvips.c `pkg-config vips --cflags --libs` + * + */ - +#include <vips/vips.h> + +int +main( int argc, char **argv ) +{ + VipsImage *in; + VipsImage *out; + VipsOperation *op; + VipsOperation *new_op; + GValue gvalue = { 0 }; + + if( VIPS_INIT( argv[0] ) ) + /* This shows the vips error buffer and quits with a fail exit + * code. + */ + vips_error_exit( NULL ); + + /* This will print a table of any ref leaks on exit, very handy for + * development. + */ + vips_leak_set( TRUE ); + + if( argc != 3 ) + vips_error_exit( "usage: %s input-filename output-filename", + argv[0] ); + + if( !(in = vips_image_new_from_file( argv[1], NULL )) ) + vips_error_exit( NULL ); + + /* Create a new operator from a nickname. NULL for unknown operator. + */ + op = vips_operation_new( "invert" ); + + /* Init a gvalue as an image, set it to in, use the gvalue to set the + * operator property. + */ + g_value_init( &gvalue, VIPS_TYPE_IMAGE ); + g_value_set_object( &gvalue, in ); + g_object_set_property( G_OBJECT( op ), "in", &gvalue ); + g_value_unset( &gvalue ); + + /* We no longer need in: op will hold a ref to it as long as it needs + * it. + */ + g_object_unref( in ); + + /* Call the operation. This will look up the operation+args in the vips + * operation cache and either return a previous operation, or build + * this one. In either case, we have a new ref we mst release. + */ + if( !(new_op = vips_cache_operation_build( op )) ) { + g_object_unref( op ); + vips_error_exit( NULL ); + } + g_object_unref( op ); + op = new_op; + + /* Now get the result from op. g_value_get_object() does not ref the + * object, so we need to make a ref for out to hold. + */ + g_value_init( &gvalue, VIPS_TYPE_IMAGE ); + g_object_get_property( G_OBJECT( op ), "out", &gvalue ); + out = VIPS_IMAGE( g_value_get_object( &gvalue ) ); + g_object_ref( out ); + g_value_unset( &gvalue ); + + /* All done: we can unref op. The output objects from op actually hold + * refs back to it, so before we can unref op, we must unref them. + */ + vips_object_unref_outputs( VIPS_OBJECT( op ) ); + g_object_unref( op ); + + if( vips_image_write_to_file( out, argv[2], NULL ) ) + vips_error_exit( NULL ); + + g_object_unref( out ); + + return( 0 ); +} + + + libvips has a couple of extra things to let you fetch the arguments and types of an operator. Use vips_lib.vips_argument_map() to loop over all the arguments of an operator, and vips_object_get_argument() to fetch the type and flags of a specific argument. + + + Use vips_operation_get_flags() to get general information about an operator. + + + + Compiled language which can call C + + The C++ binding uses this lower layer to define a function called VImage::call() which can call any libvips operator with a not-varargs set of variable arguments. + + + A small Python program walks the set of all libvips operators and generates a set of static bindings. For example: + + +VImage VImage::invert( VOption *options ) +{ + VImage out; + + call( "invert", (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "out", &out ) ); + + return( out ); +} + + + So from C++ you can call any libvips operator, though without type-safety, with VImage::call(), or use the member functions on VImage to get type-safe calls for at least the required operator arguments. + + + The VImage class also adds automatic reference counting, constant expansion, operator overloads, and various other useful features. + + + + Dynamic language with FFI + + Languages like Ruby, Python, JavaScript and Lua can’t call C directly, but they do support FFI. The bindings for these languages work rather like C++, but use FFI to call into libvips and run operations. + + + Since these languages are dynamic, they can add another trick: they intercept the method-missing hook and attempt to run any method calls not implemented by the Image class as libvips operators. This makes these bindings self-writing: they only contain a small amount of codeand just expose everything they find in the libvips class hierarchy. + + + + Dynamic langauge without FFI + + PHP does not have FFI, unfortunately, so for this language a small native module implements the general vips_call() function for PHP language types, and a larger pure PHP layer makes it convenient to use. + + + + <literal>gobject-introspection</literal> + + The C source code to libvips has been marked up with special comments describing the interface in a standard way. These comments are read by the gobject-introspection package when libvips is compiled and used to generate a typelib, a description of how to call the library. Many languages have gobject-introspection packages: all you need to do to call libvips from your favorite language is to start g-o-i, load the libvips typelib, and you should have the whole library available. For example, from Python it’s as simple as: + + from gi.repository import Vips - - - - libvips used in this way is likely to be rather bare-bones. For Python, - we wrote a set of overrides which layer a more Pythonesque interface - on top of the one provided for libvips by pygobject. These overrides - are simply a set of Python classes. - - - - To call a vips operation, you'll need to make a new operation with - vips_operation_new() (all it does is look up the operation by name - with vips_type_find(), then call g_object_new() for you), then - use vips_argument_map() and friends to loop over the operation's - arguments setting them. Once you have set all arguments, use - vips_cache_operation_build() to look up the operation in the cache - and either build or dup it. If something goes wrong, you'll need - to use vips_object_unref_outputs() and g_object_unref() to free the - partially-built object. - The Python binding uses this technique to implement a function which - can call any vips operation, turning optional vips arguments into - Python keyword arguments. - - - - If your language does not have a gobject-introspection package, you'll - need to write something in C or C++ doing approximately the same thing. - The C++ API takes this route. - - - - You can generate searchable docs from a .gir (the thing that - is built from scanning libvips and which in turn turn the typelib is - made from) with g-ir-doc-tool, for example: - - + + You can now use all of the libvips introspection machinery, as noted above. + + + Unfortunately g-o-i has some strong disadvantages. It is not very portable, since you will need a g-o-i layer for whatever platform you are targetting; it does not cross-compile well, since typelibs include a lot of very-low level data (such as exact structure layouts); and installation for your users is likely to be tricky. + + + If you have a choice, I would recommend simply using FFI. + + + + Documentation + + You can generate searchable docs from a .gir (the thing that is built from scanning libvips and which in turn turn the typelib is made from) with g-ir-doc-tool, for example: + + $ g-ir-doc-tool --language=Python -o ~/mydocs Vips-8.0.gir - - Then to view them, either: - - + + Then to view them, either: + + $ yelp ~/mydocs - - Or perhaps - - + + Or perhaps: + + $ cd ~/mydocs $ yelp-build html . + + To make HTML docs. This is an easy way to see what you can call in the library. + + - To make HTML docs. This is an easy way to see what you can call in the - library. - - - - diff --git a/doc/libvips-docs.xml.in b/doc/libvips-docs.xml.in index 4bd2a812..aa8ab93a 100644 --- a/doc/libvips-docs.xml.in +++ b/doc/libvips-docs.xml.in @@ -32,7 +32,6 @@ - diff --git a/doc/using-python.xml b/doc/using-python.xml deleted file mode 100644 index cafe1711..00000000 --- a/doc/using-python.xml +++ /dev/null @@ -1,681 +0,0 @@ - - - - - - VIPS from Python - 3 - VIPS Library - - - - Using VIPS - How to use the VIPS library from Python - - - - Introduction - - VIPS comes with a convenient, high-level Python API built on - on gobject-introspection. As long as you can get GOI - for your platform, you should be able to use libvips. - - - - To test the binding, start up Python and at the console enter: - - ->>> from gi.repository import Vips ->>> x = Vips.Image.new_from_file("/path/to/some/image/file.jpg") ->>> x.width -1450 ->>> - - - - - - If import fails, check you have the Python - gobject-introspection packages installed, that you have the - libvips typelib installed, and that the typelib is either - in the system area or on your GI_TYPELIB_PATH. - - - - - - If .new_from_file() fails, the vips overrides - have not been found. Make sure Vips.py is in - your system overrides area. - - - - - - - - Example program - - - Here's a complete example program: - - -#!/usr/bin/python - -import sys - -from gi.repository import Vips - -im = Vips.Image.new_from_file(sys.argv[1]) - -im = im.extract_area(100, 100, im.width - 200, im.height - 200) -im = im.similarity(scale = 0.9) -mask = Vips.Image.new_from_array([[-1, -1, -1], - [-1, 16, -1], - [-1, -1, -1]], scale = 8) -im = im.conv(mask) - -im.write_to_file(sys.argv[2]) - - - - - Reading this code, the first interesting line is: - - -from gi.repository import Vips - - - When Python executes the import line it performs the following steps: - - - - - - It searches for a file called Vips-x.y.typelib. This - is a binary file generated automatically during libvips build - by introspection of the libvips shared library plus scanning - of the C headers. It lists all the API entry points, all the - types the library uses, and has an extra set of hints for object - ownership and reference counting. The typelib is searched for - in /usr/lib/gi-repository-1.0 and along the path - in the environment variable GI_TYPELIB_PATH. - - - - - - It uses the typelib to make a basic binding for libvips. It's - just the C API with a little very light mangling, so for - example the enum member VIPS_FORMAT_UCHAR - of the enum VipsBandFormat becomes - Vips.BandFormat.UCHAR. - - - - - - The binding you get can be rather unfriendly, so it also - loads a set of overrides from Vips.py in - /usr/lib/python2.7/dist-packages/gi/overrides - (on my system at least). If you're using python3, it's - /usr/lib/python3/dist-packages/gi/overrides. - Unfortunately, as far as I know, there is no way to extend - this search using environment variables. You MUST have - Vips.py in exactly this directory. If you install - vips via a package manager this will happen automatically, - since vips and pygobject will have been built to the same - prefix, but if you are installing vips from source and the - prefix does not match, it will not be installed for you, - you will need to copy it. - - - - - - Finally, Vips.py makes the rest of the binding. In - fact, Vips.py makes almost all the binding: it - defines __getattr__ on Vips.Image - and binds at runtime by searching libvips for an operation of - that name. - - - - - - The next line is: - - -im = Vips.Image.new_from_file(sys.argv[1]) - - - This loads the input image. You can append - load options to the argument list as keyword arguments, for example: - - -im = Vips.Image.new_from_file(sys.argv[1], access = Vips.Access.SEQUENTIAL) - - - See the various loaders for a list of the available options - for each file format. The C equivalent to this function, - vips_image_new_from_file(), has more extensive documentation. Try - help(Vips.Image) to see a list of all the image - constructors --- you can load from memory, create from an array, - or create from a constant, for example. - - - - The next line is: - - -im = im.extract_area(100, 100, im.width - 200, im.height - 200) - - - The arguments are left, top, width, height, so this crops 100 pixels off - every edge. Try help(im.extract_area) and the C API docs - for vips_extract_area() for details. You can use .crop() - as a synonym, if you like. - - - - im.width gets the image width - in pixels, see help(Vips.Image) and vips_image_get_width() - and friends for a list of the other getters. - - - - The next line: - - -im = im.similarity(scale = 0.9) - - - shrinks by 10%. By default it uses - bilinear interpolation, use interpolate to pick another - interpolator, for example: - - -im = im.similarity(scale = 0.9, interpolate = Vips.Interpolate.new("bicubic")) - - - see vips_similarity() for full documentation. The similarity operator - will not give good results for large resizes (more than a factor of - two). See vips_resize() if you need to make a large change. - - - - Next: - - -mask = Vips.Image.new_from_array([[-1, -1, -1], - [-1, 16, -1], - [-1, -1, -1]], scale = 8) -im = im.conv(mask) - - - makes an image from a 2D array, then convolves with that. The - scale keyword argument lets you set a divisor for - convolution, handy for integer convolutions. You can set - offset as well. See vips_conv() for details on the vips - convolution operator. - - - - Finally, - - -im.write_to_file(sys.argv[2]) - - - sends the image back to the - filesystem. There's also .write_to_buffer() to make a - string containing the formatted image, and .write() to - write to another image. - - - - As with .new_from_file() you can append save options as - keyword arguments. For example: - - -im.write_to_file("test.jpg", Q = 90) - - - will write a JPEG image with quality set to 90. See the various save - operations for a list of all the save options, for example - vips_jpegsave(). - - - - - - Getting help - - Try help(Vips) for everything, - help(Vips.Image) for something slightly more digestible, or - something like help(Vips.Image.black) for help on a - specific class member. - - - - You can't get help on dynamically bound member functions like - .add() this way. Instead, make an image and get help - from that, for example: - - -image = Vips.Image.black(1, 1) -help(image.add) - - - And you'll get a summary of the operator's behaviour and how the - arguments are represented in Python. - - - - The API docs have a handy table of all vips - operations, if you want to find out how to do something, try - searching that. - - - - The vips command can be useful too. For example, in a - terminal you can type vips jpegsave to get a - summary of an operation: - - -$ vips jpegsave -save image to jpeg file -usage: - jpegsave in filename -where: - in - Image to save, input VipsImage - filename - Filename to save to, input gchararray -optional arguments: - Q - Q factor, input gint - default: 75 - min: 1, max: 100 - profile - ICC profile to embed, input gchararray - optimize-coding - Compute optimal Huffman coding tables, input gboolean - default: false - interlace - Generate an interlaced (progressive) jpeg, input gboolean - default: false - no-subsample - Disable chroma subsample, input gboolean - default: false - trellis-quant - Apply trellis quantisation to each 8x8 block, input gboolean - default: false - overshoot-deringing - Apply overshooting to samples with extreme values, input gboolean - default: false - optimize-scans - Split the spectrum of DCT coefficients into separate scans, input gboolean - default: false - strip - Strip all metadata from image, input gboolean - default: false - background - Background value, input VipsArrayDouble -operation flags: sequential-unbuffered nocache - - - - - - - <code>pyvips8</code> basics - - As noted above, the Python interface comes in two main parts, - an automatically generated binding based on the vips typelib, - plus a set of extra features provided by overrides. - The rest of this chapter runs through the features provided by the - overrides. - - - - - Automatic wrapping - - The overrides intercept member lookup - on the Vips.Image class and look for vips operations - with that name. So the vips operation "add", which appears in the - C API as vips_add(), appears in Python as - image.add(). - - - - The first input image argument becomes the self - argument. If there are no input image arguments, the operation - appears as a class member. Optional input arguments become - keyword arguments. The result is a list of all the output - arguments, or a single output if there is only one. - - - - Optional output arguments are enabled with a boolean keyword - argument of that name. For example, "min" (the operation which - appears in the C API as vips_min()), can be called like this: - - -min_value = im.min() - - - and min_value will be a floating point value giving - the minimum value in the image. "min" can also find the position - of the minimum value with the x and y - optional output arguments. Call it like this: - - -min_value, opts = im.min(x = True, y = True) -x = opts['x'] -y = opts['y'] - - - In other words, if optional output args are requested, an extra - dictionary is returned containing those objects. - Of course in this case, the .minpos() convenience - function would be simpler, see below. - - - - Because operations are member functions and return the result image, - you can chain them. For example, you can write: - - -result_image = image.sin().pow(2) - - - to calculate the square of the sine for each pixel. There is also a - full set of arithmetic operator overloads, see below. - - - - VIPS types are also automatically wrapped. The override looks - at the type of argument required by the operation and converts - the value you supply, when it can. For example, "linear" takes a - #VipsArrayDouble as an argument for the set of constants to use for - multiplication. You can supply this value as an integer, a float, - or some kind of compound object and it will be converted for you. - You can write: - - -result_image = image.linear(1, 3) -result_image = image.linear(12.4, 13.9) -result_image = image.linear([1, 2, 3], [4, 5, 6]) -result_image = image.linear(1, [4, 5, 6]) - - - And so on. A set of overloads are defined for .linear(), - see below. - - - - It does a couple of more ambitious conversions. It will - automatically convert to and from the various vips types, - like #VipsBlob and #VipsArrayImage. For example, you can read the - ICC profile out of an image like this: - - -profile = im.get_value("icc-profile-data") - - - and profile will be a string. - - - - You can use array constants instead of images. A 2D array is simply - changed into a one-band double image. This is handy for things like - .erode(), for example: - - -im = im.erode([[128, 255, 128], - [255, 255, 255], - [128, 255, 128]]) - - - will erode an image with a 4-connected structuring element. - - - - If an operation takes several input images, you can use a 1D array - constant or a number constant - for all but one of them and the wrapper will expand it - to an image for you. For example, .ifthenelse() uses - a condition image to pick pixels between a then and an else image: - - -result_image = condition_image.ifthenelse(then_image, else_image) - - - You can use a constant instead of either the then or the else - parts, and it will be expanded to an image for you. If you use a - constant for both then and else, it will be expanded to match the - condition image. For example: - - -result_image = condition_image.ifthenelse([0, 255, 0], [255, 0, 0]) - - - Will make an image where true pixels are green and false pixels - are red. - - - - This is also useful for .bandjoin(), the thing to join - two or more images up bandwise. You can write: - - -rgba = rgb.bandjoin(255) - - - to add a constant 255 band to an image, perhaps to add an alpha - channel. Of course you can also write: - - -result_image = image1.bandjoin(image2) -result_image = image1.bandjoin([image2, image3]) -result_image = image1.bandjoin([image2, 255]) - - - and so on. - - - - - - Exceptions - - The wrapper spots errors from vips operations and raises the - Vips.Error exception. You can catch it in the - usual way. The .detail member gives the detailed - error message. - - - - - Reading and writing areas of memory - - You can use the C API functions vips_image_new_from_memory(), - vips_image_new_from_memory_copy() and - vips_image_write_to_memory() directly from Python to read and write - areas of memory. This can be useful if you need to get images to and - from other other image processing libraries, like PIL or numpy. - - - - Use them from Python like this: - - -image = Vips.Image.new_from_file("/path/to/some/image/file.jpg") -memory_area = image.write_to_memory() - - - memory_area is now a string containing uncompressed binary - image data. For an RGB image, it will have bytes - RGBRGBRGB..., being - the first three pixels of the first scanline of the image. You can pass - this string to the numpy or PIL constructors and make an image there. - - - - Note that .write_to_memory() will make a copy of the image. - It would - be better to use a Python buffer to pass the data, but sadly this isn't - possible with gobject-introspection, as far as I know. - - - - Going the other way, you can construct a vips image from a string of - binary data. For example: - - -image = Vips.Image.new_from_file("/path/to/some/image/file.jpg") -memory_area = image.write_to_memory() -image2 = Vips.Image.new_from_memory(memory_area, - image.width, image.height, image.bands, - Vips.BandFormat.UCHAR) - - - Now image2 should be an identical copy of image. - - - - Be careful: in this direction, vips does not make a copy of the memory - area, so if memory_area is freed by the Python garbage - collector and - you later try to use image2, you'll get a crash. - Make sure you keep a reference to memory_area around - for as long as you need it. A simple solution is to use - new_from_memory_copy instead. This will take a copy of the - memory area for vips. Of course this will raise memory usage. - - - - - - Draw operations - - Paint operations like draw_circle and draw_line - modify their input image. This makes them hard to use with the rest of - libvips: you need to be very careful about the order in which operations - execute or you can get nasty crashes. - - - - The wrapper spots operations of this type and makes a private copy of - the image in memory before calling the operation. This stops crashes, - but it does make it inefficient. If you draw 100 lines on an image, - for example, you'll copy the image 100 times. The wrapper does make sure - that memory is recycled where possible, so you won't have 100 copies in - memory. At least you can execute these operations. - - - - If you want to avoid the copies, you'll need to call drawing - operations yourself. - - - - - Overloads - - The wrapper defines the usual set of arithmetic, boolean and - relational overloads on - image. You can mix images, constants and lists of - constants (almost) freely. For example, you can write: - - -result_image = ((image * [1, 2, 3]).abs() < 128) | 4 - - - - - The wrapper overloads [] to be vips_extract_band(). You - can write: - - -result_image = image[2] - - - to extract the third band of the image. It implements the usual - slicing and negative indexes, so you can write: - - -result_image = image[1:] -result_image = image[:3] -result_image = image[-2:] -result_image = [x.avg() for x in image] - - - and so on. - - - - The wrapper overloads () to be vips_getpoint(). You can - write: - - -r, g, b = image(10, 10) - - - to read out the value of the pixel at coordinates (10, 10) from an RGB - image. - - - - - - Expansions - - Some vips operators take an enum to select an action, for example - .math() can be used to calculate sine of every pixel - like this: - - -result_image = image.math(Vips.OperationMath.SIN) - - - This is annoying, so the wrapper expands all these enums into - separate members named after the enum. So you can write: - - -result_image = image.sin() - - - See help(Vips.Image) for a list. - - - - - Convenience functions - - The wrapper defines a few extra useful utility functions: - .get_value(), - .set_value(), - .bandsplit(), - .maxpos(), - .minpos(), - .median(). - Again, see help(Vips.Image) for a list. - - - - - Command-line option parsing - - GLib includes a command-line option parser, and Vips defines a set of - standard flags you can use with it. For example: - - -import sys -from gi.repository import GLib, Vips - -context = GLib.OptionContext(" - test stuff") -main_group = GLib.OptionGroup("main", - "Main options", "Main options for this program", - None) -context.set_main_group(main_group) -Vips.add_option_entries(main_group) -context.parse(sys.argv) - - - - - - diff --git a/libvips/arithmetic/abs.c b/libvips/arithmetic/abs.c index d4ec9eb9..829f653f 100644 --- a/libvips/arithmetic/abs.c +++ b/libvips/arithmetic/abs.c @@ -253,9 +253,9 @@ vips_abs_init( VipsAbs *abs ) } /** - * vips_abs: + * vips_abs: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * This operation finds the absolute value of an image. It does a copy for diff --git a/libvips/arithmetic/add.c b/libvips/arithmetic/add.c index 40839a63..a077e3af 100644 --- a/libvips/arithmetic/add.c +++ b/libvips/arithmetic/add.c @@ -185,7 +185,7 @@ vips_add_init( VipsAdd *add ) * vips_add: * @left: input image * @right: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * This operation calculates @in1 + @in2 and writes the result to @out. diff --git a/libvips/arithmetic/boolean.c b/libvips/arithmetic/boolean.c index 2ed8594e..1fc8aa3f 100644 --- a/libvips/arithmetic/boolean.c +++ b/libvips/arithmetic/boolean.c @@ -240,7 +240,7 @@ vips_booleanv( VipsImage *left, VipsImage *right, VipsImage **out, * vips_boolean: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @boolean: boolean operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -284,7 +284,7 @@ vips_boolean( VipsImage *left, VipsImage *right, VipsImage **out, * vips_andimage: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_AND on a pair of images. See @@ -310,7 +310,7 @@ vips_andimage( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_orimage: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_OR on a pair of images. See @@ -336,7 +336,7 @@ vips_orimage( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_eorimage: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_EOR on a pair of images. See @@ -362,7 +362,7 @@ vips_eorimage( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_lshift: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_LSHIFT on a pair of images. See @@ -388,7 +388,7 @@ vips_lshift( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_rshift: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_RSHIFT on a pair of images. See @@ -554,11 +554,11 @@ vips_boolean_constv( VipsImage *in, VipsImage **out, } /** - * vips_boolean_const: + * vips_boolean_const: (method) * @in: input image - * @out: output image + * @out: (out): output image * @boolean: boolean operation to perform - * @c: array of constants + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -593,10 +593,10 @@ vips_boolean_const( VipsImage *in, VipsImage **out, } /** - * vips_andimage_const: + * vips_andimage_const: (method) * @in: input image - * @out: output image - * @c: array of constants + * @out: (out): output image + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -622,10 +622,10 @@ vips_andimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_orimage_const: + * vips_orimage_const: (method) * @in: input image - * @out: output image - * @c: array of constants + * @out: (out): output image + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -651,10 +651,10 @@ vips_orimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_eorimage_const: + * vips_eorimage_const: (method) * @in: input image - * @out: output image - * @c: array of constants + * @out: (out): output image + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -680,10 +680,10 @@ vips_eorimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_lshift_const: + * vips_lshift_const: (method) * @in: input image - * @out: output image - * @c: array of constants + * @out: (out): output image + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -709,10 +709,10 @@ vips_lshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_rshift_const: + * vips_rshift_const: (method) * @in: input image - * @out: output image - * @c: array of constants + * @out: (out): output image + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -738,9 +738,9 @@ vips_rshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_boolean_const1: + * vips_boolean_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @boolean: boolean operation to perform * @c: constant * @...: %NULL-terminated list of optional named arguments @@ -767,9 +767,9 @@ vips_boolean_const1( VipsImage *in, VipsImage **out, } /** - * vips_andimage_const1: + * vips_andimage_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -795,9 +795,9 @@ vips_andimage_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_orimage_const1: + * vips_orimage_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -823,9 +823,9 @@ vips_orimage_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_eorimage_const1: + * vips_eorimage_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -851,9 +851,9 @@ vips_eorimage_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_lshift_const1: + * vips_lshift_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -879,9 +879,9 @@ vips_lshift_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_rshift_const1: + * vips_rshift_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/arithmetic/complex.c b/libvips/arithmetic/complex.c index a486355c..d598c3d7 100644 --- a/libvips/arithmetic/complex.c +++ b/libvips/arithmetic/complex.c @@ -272,9 +272,9 @@ vips_complexv( VipsImage *in, VipsImage **out, } /** - * vips_complex: + * vips_complex: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @cmplx: complex operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -299,9 +299,9 @@ vips_complex( VipsImage *in, VipsImage **out, VipsOperationComplex cmplx, ... ) } /** - * vips_polar: + * vips_polar: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_COMPLEX_POLAR on an image. See vips_complex(). @@ -322,9 +322,9 @@ vips_polar( VipsImage *in, VipsImage **out, ... ) } /** - * vips_rect: + * vips_rect: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_COMPLEX_RECT on an image. See vips_complex(). @@ -345,9 +345,9 @@ vips_rect( VipsImage *in, VipsImage **out, ... ) } /** - * vips_conj: + * vips_conj: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_COMPLEX_CONJ on an image. See vips_complex(). @@ -569,7 +569,7 @@ vips_complex2v( VipsImage *left, VipsImage *right, VipsImage **out, * vips_complex2: * @left: input #VipsImage * @right: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @cmplx: complex2 operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -598,7 +598,7 @@ vips_complex2( VipsImage *left, VipsImage *right, VipsImage **out, * vips_cross_phase: * @left: input #VipsImage * @right: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_COMPLEX2_CROSS_PHASE on an image. @@ -781,9 +781,9 @@ vips_complexgetv( VipsImage *in, VipsImage **out, } /** - * vips_complexget: + * vips_complexget: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @get: complex operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -810,9 +810,9 @@ vips_complexget( VipsImage *in, VipsImage **out, } /** - * vips_real: + * vips_real: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_COMPLEXGET_REAL on an image. See vips_complexget(). @@ -834,9 +834,9 @@ vips_real( VipsImage *in, VipsImage **out, ... ) } /** - * vips_imag: + * vips_imag: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_COMPLEXGET_IMAG on an image. See vips_complexget(). @@ -977,7 +977,7 @@ vips_complexform_init( VipsComplexform *complexform ) * vips_complexform: * @left: input image * @right: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Compose two real images to make a complex image. If either @left or @right diff --git a/libvips/arithmetic/deviate.c b/libvips/arithmetic/deviate.c index 3c62e3d8..14c11e9f 100644 --- a/libvips/arithmetic/deviate.c +++ b/libvips/arithmetic/deviate.c @@ -231,9 +231,9 @@ vips_deviate_init( VipsDeviate *deviate ) } /** - * vips_deviate: + * vips_deviate: (method) * @in: input #VipsImage - * @out: output pixel standard deviation + * @out: (out): output pixel standard deviation * @...: %NULL-terminated list of optional named arguments * * This operation finds the standard deviation of all pixels in @in. It diff --git a/libvips/arithmetic/divide.c b/libvips/arithmetic/divide.c index 000fbcf4..0cc3970c 100644 --- a/libvips/arithmetic/divide.c +++ b/libvips/arithmetic/divide.c @@ -238,7 +238,7 @@ vips_divide_init( VipsDivide *divide ) * vips_divide: * @left: input image * @right: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * This operation calculates @in1 / @in2 and writes the result to @out. If any diff --git a/libvips/arithmetic/find_trim.c b/libvips/arithmetic/find_trim.c index 1eada0b0..f3974c6a 100644 --- a/libvips/arithmetic/find_trim.c +++ b/libvips/arithmetic/find_trim.c @@ -237,12 +237,12 @@ vips_find_trim_init( VipsFindTrim *find_trim ) } /** - * vips_find_trim: + * vips_find_trim: (method) * @in: image to find_trim - * @left: output left edge - * @top: output top edge - * @width: output width - * @height: output height + * @left: (out): output left edge + * @top: (out): output top edge + * @width: (out): output width + * @height: (out): output height * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/getpoint.c b/libvips/arithmetic/getpoint.c index bc96a685..1a1ee6e1 100644 --- a/libvips/arithmetic/getpoint.c +++ b/libvips/arithmetic/getpoint.c @@ -166,9 +166,9 @@ vips_getpoint_init( VipsGetpoint *getpoint ) } /** - * vips_getpoint: + * vips_getpoint: (method) * @in: image to read from - * @vector: array length=n: output pixel value here + * @vector: (out)(array length=n): output pixel value here * @n: length of output vector * @x: position to read * @y: position to read diff --git a/libvips/arithmetic/hist_find.c b/libvips/arithmetic/hist_find.c index 35227c4a..0d357718 100644 --- a/libvips/arithmetic/hist_find.c +++ b/libvips/arithmetic/hist_find.c @@ -468,9 +468,9 @@ vips_hist_find_init( VipsHistFind *hist_find ) } /** - * vips_hist_find: + * vips_hist_find: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/hist_find_indexed.c b/libvips/arithmetic/hist_find_indexed.c index c89a28f6..13a908b2 100644 --- a/libvips/arithmetic/hist_find_indexed.c +++ b/libvips/arithmetic/hist_find_indexed.c @@ -401,10 +401,10 @@ vips_hist_find_indexed_init( VipsHistFindIndexed *hist_find ) } /** - * vips_hist_find_indexed: - * @in: input image - * @index: input index image - * @out: output image + * vips_hist_find_indexed: (method) + * @in: input #VipsImage + * @index: input index #VipsImage + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Make a histogram of @in, but use image @index to pick the bins. In other diff --git a/libvips/arithmetic/hist_find_ndim.c b/libvips/arithmetic/hist_find_ndim.c index b0b3ce5f..df689dd0 100644 --- a/libvips/arithmetic/hist_find_ndim.c +++ b/libvips/arithmetic/hist_find_ndim.c @@ -316,9 +316,9 @@ vips_hist_find_ndim_init( VipsHistFindNDim *ndim ) } /** - * vips_hist_find_ndim: + * vips_hist_find_ndim: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/hough_circle.c b/libvips/arithmetic/hough_circle.c index fd3fd248..0621f483 100644 --- a/libvips/arithmetic/hough_circle.c +++ b/libvips/arithmetic/hough_circle.c @@ -268,9 +268,9 @@ vips_hough_circle_init( VipsHoughCircle *hough_circle ) } /** - * vips_hough_circle: + * vips_hough_circle: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/hough_line.c b/libvips/arithmetic/hough_line.c index e32e4be4..0cdb6fd7 100644 --- a/libvips/arithmetic/hough_line.c +++ b/libvips/arithmetic/hough_line.c @@ -162,9 +162,9 @@ vips_hough_line_init( VipsHoughLine *hough_line ) } /** - * vips_hough_line: + * vips_hough_line: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/invert.c b/libvips/arithmetic/invert.c index 53e2b5d0..c4ad70b7 100644 --- a/libvips/arithmetic/invert.c +++ b/libvips/arithmetic/invert.c @@ -175,9 +175,9 @@ vips_invert_init( VipsInvert *invert ) } /** - * vips_invert: + * vips_invert: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * For unsigned formats, this operation calculates (max - @in), eg. (255 - diff --git a/libvips/arithmetic/linear.c b/libvips/arithmetic/linear.c index ffeb3b81..4a376a55 100644 --- a/libvips/arithmetic/linear.c +++ b/libvips/arithmetic/linear.c @@ -40,10 +40,11 @@ * - removed the 1-ary constant path, no faster * 30/11/13 * - 1ary is back, faster with gcc 4.8 - * 3/12/13 - * - try an ORC path with the band loop unrolled * 14/1/14 * - add uchar output option + * 30/9/17 + * - squash constants with all elements equal so we use 1ary path more + * often */ /* @@ -124,7 +125,7 @@ vips_linear_build( VipsObject *object ) int i; - /* If we have a three-element vector we need to bandup the image to + /* If we have a three-element vector, we need to bandup the image to * match. */ linear->n = 1; @@ -150,6 +151,38 @@ vips_linear_build( VipsObject *object ) return( -1 ); } + /* If all elements of the constants are equal, we can shrink them down + * to a single element. + */ + if( linear->a ) { + double *ary = (double *) linear->a->data; + gboolean all_equal; + + all_equal = TRUE; + for( i = 1; i < linear->a->n; i++ ) + if( ary[i] != ary[0] ) { + all_equal = FALSE; + break; + } + + if( all_equal ) + linear->a->n = 1; + } + if( linear->b ) { + double *ary = (double *) linear->b->data; + gboolean all_equal; + + all_equal = TRUE; + for( i = 1; i < linear->b->n; i++ ) + if( ary[i] != ary[0] ) { + all_equal = FALSE; + break; + } + + if( all_equal ) + linear->b->n = 1; + } + /* Make up-banded versions of our constants. */ linear->a_ready = VIPS_ARRAY( linear, linear->n, double ); @@ -438,9 +471,9 @@ vips_linearv( VipsImage *in, VipsImage **out, } /** - * vips_linear: + * vips_linear: (method) * @in: image to transform - * @out: output image + * @out: (out): output image * @a: (array length=n): array of constants for multiplication * @b: (array length=n): array of constants for addition * @n: length of constant arrays @@ -480,9 +513,9 @@ vips_linear( VipsImage *in, VipsImage **out, double *a, double *b, int n, ... ) } /** - * vips_linear1: + * vips_linear1: (method) * @in: image to transform - * @out: output image + * @out: (out): output image * @a: constant for multiplication * @b: constant for addition * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/arithmetic/math.c b/libvips/arithmetic/math.c index 9e696464..6d96a777 100644 --- a/libvips/arithmetic/math.c +++ b/libvips/arithmetic/math.c @@ -230,9 +230,9 @@ vips_mathv( VipsImage *in, VipsImage **out, VipsOperationMath math, va_list ap ) } /** - * vips_math: + * vips_math: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @math: math operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -261,9 +261,9 @@ vips_math( VipsImage *in, VipsImage **out, VipsOperationMath math, ... ) } /** - * vips_sin: + * vips_sin: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_SIN on an image. See vips_math(). @@ -284,9 +284,9 @@ vips_sin( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cos: + * vips_cos: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_COS on an image. See vips_math(). @@ -307,9 +307,9 @@ vips_cos( VipsImage *in, VipsImage **out, ... ) } /** - * vips_tan: + * vips_tan: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_TAN on an image. See vips_math(). @@ -330,9 +330,9 @@ vips_tan( VipsImage *in, VipsImage **out, ... ) } /** - * vips_asin: + * vips_asin: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_ASIN on an image. See vips_math(). @@ -353,9 +353,9 @@ vips_asin( VipsImage *in, VipsImage **out, ... ) } /** - * vips_acos: + * vips_acos: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_ACOS on an image. See vips_math(). @@ -376,9 +376,9 @@ vips_acos( VipsImage *in, VipsImage **out, ... ) } /** - * vips_atan: + * vips_atan: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_ATAN on an image. See vips_math(). @@ -399,9 +399,9 @@ vips_atan( VipsImage *in, VipsImage **out, ... ) } /** - * vips_log: + * vips_log: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_LOG on an image. See vips_math(). @@ -422,9 +422,9 @@ vips_log( VipsImage *in, VipsImage **out, ... ) } /** - * vips_log10: + * vips_log10: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_LOG10 on an image. See vips_math(). @@ -445,9 +445,9 @@ vips_log10( VipsImage *in, VipsImage **out, ... ) } /** - * vips_exp: + * vips_exp: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_EXP on an image. See vips_math(). @@ -468,9 +468,9 @@ vips_exp( VipsImage *in, VipsImage **out, ... ) } /** - * vips_exp10: + * vips_exp10: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH_EXP10 on an image. See vips_math(). diff --git a/libvips/arithmetic/math2.c b/libvips/arithmetic/math2.c index 90adecaf..c40ee148 100644 --- a/libvips/arithmetic/math2.c +++ b/libvips/arithmetic/math2.c @@ -225,7 +225,7 @@ vips_math2v( VipsImage *left, VipsImage *right, VipsImage **out, * vips_math2: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @math2: math operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -272,7 +272,7 @@ vips_math2( VipsImage *left, VipsImage *right, VipsImage **out, * vips_pow: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH2_POW on a pair of images. See @@ -297,7 +297,7 @@ vips_pow( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_wop: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_MATH2_WOP on a pair of images. See @@ -441,11 +441,11 @@ vips_math2_constv( VipsImage *in, VipsImage **out, } /** - * vips_math2_const: + * vips_math2_const: (method) * @in: input image - * @out: output image + * @out: (out): output image * @math2: math operation to perform - * @c: array of constants + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -484,10 +484,10 @@ vips_math2_const( VipsImage *in, VipsImage **out, } /** - * vips_pow_const: + * vips_pow_const: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -511,10 +511,10 @@ vips_pow_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_wop_const: + * vips_wop_const: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -538,9 +538,9 @@ vips_wop_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_math2_const1: + * vips_math2_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @math2: math operation to perform * @c: constant * @...: %NULL-terminated list of optional named arguments @@ -565,9 +565,9 @@ vips_math2_const1( VipsImage *in, VipsImage **out, } /** - * vips_pow_const1: + * vips_pow_const1: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -591,9 +591,9 @@ vips_pow_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_wop_const1: + * vips_wop_const1: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @c: constant * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/arithmetic/max.c b/libvips/arithmetic/max.c index f44955d9..b20eddb9 100644 --- a/libvips/arithmetic/max.c +++ b/libvips/arithmetic/max.c @@ -491,9 +491,9 @@ vips_max_init( VipsMax *max ) } /** - * vips_max: + * vips_max: (method) * @in: input #VipsImage - * @out: output pixel maximum + * @out: (out): output pixel maximum * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/measure.c b/libvips/arithmetic/measure.c index 1c255f96..6398ec23 100644 --- a/libvips/arithmetic/measure.c +++ b/libvips/arithmetic/measure.c @@ -253,9 +253,9 @@ vips_measure_init( VipsMeasure *measure ) } /** - * vips_measure: + * vips_measure: (method) * @in: image to measure - * @out: array of measurements + * @out: (out): array of measurements * @h: patches across chart * @v: patches down chart * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/arithmetic/min.c b/libvips/arithmetic/min.c index 57b0d348..92b2af43 100644 --- a/libvips/arithmetic/min.c +++ b/libvips/arithmetic/min.c @@ -492,9 +492,9 @@ vips_min_init( VipsMin *min ) } /** - * vips_min: + * vips_min: (method) * @in: input #VipsImage - * @out: output pixel minimum + * @out: (out): output pixel minimum * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/arithmetic/multiply.c b/libvips/arithmetic/multiply.c index b7acfe8a..424b9097 100644 --- a/libvips/arithmetic/multiply.c +++ b/libvips/arithmetic/multiply.c @@ -186,7 +186,7 @@ vips_multiply_init( VipsMultiply *multiply ) * vips_multiply: * @left: left-hand image * @right: right-hand image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * This operation calculates @left * @right and writes the result to @out. diff --git a/libvips/arithmetic/profile.c b/libvips/arithmetic/profile.c index 4cdddbad..b333fc43 100644 --- a/libvips/arithmetic/profile.c +++ b/libvips/arithmetic/profile.c @@ -316,10 +316,10 @@ vips_profile_init( VipsProfile *profile ) } /** - * vips_profile: + * vips_profile: (method) * @in: input image - * @columns: distances from top edge - * @rows: distances from left edge + * @columns: (out): distances from top edge + * @rows: (out): distances from left edge * @...: %NULL-terminated list of optional named arguments * * vips_profile() searches inward from the edge of @in and finds the diff --git a/libvips/arithmetic/project.c b/libvips/arithmetic/project.c index c5180c3f..4bf6d416 100644 --- a/libvips/arithmetic/project.c +++ b/libvips/arithmetic/project.c @@ -346,10 +346,10 @@ vips_project_init( VipsProject *project ) } /** - * vips_project: + * vips_project: (method) * @in: input image - * @columns: sums of columns - * @rows: sums of rows + * @columns: (out): sums of columns + * @rows: (out): sums of rows * @...: %NULL-terminated list of optional named arguments * * Find the horizontal and vertical projections of an image, ie. the sum diff --git a/libvips/arithmetic/relational.c b/libvips/arithmetic/relational.c index 96dda30d..c975f2af 100644 --- a/libvips/arithmetic/relational.c +++ b/libvips/arithmetic/relational.c @@ -246,7 +246,7 @@ vips_relationalv( VipsImage *left, VipsImage *right, VipsImage **out, * vips_relational: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @relational: relational operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -294,7 +294,7 @@ vips_relational( VipsImage *left, VipsImage *right, VipsImage **out, * vips_equal: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_RELATIONAL_EQUAL on a pair of images. See @@ -320,7 +320,7 @@ vips_equal( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_notequal: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_RELATIONAL_NOTEQ on a pair of images. See @@ -346,7 +346,7 @@ vips_notequal( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_more: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_RELATIONAL_MORE on a pair of images. See @@ -372,7 +372,7 @@ vips_more( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_moreeq: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_RELATIONAL_MOREEQ on a pair of images. See @@ -398,7 +398,7 @@ vips_moreeq( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_less: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_RELATIONAL_LESS on a pair of images. See @@ -424,7 +424,7 @@ vips_less( VipsImage *left, VipsImage *right, VipsImage **out, ... ) * vips_lesseq: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_RELATIONAL_LESSEQ on a pair of images. See @@ -595,11 +595,11 @@ vips_relational_constv( VipsImage *in, VipsImage **out, } /** - * vips_relational_const: + * vips_relational_const: (method) * @in: input image - * @out: output image + * @out: (out): output image * @relational: relational operation to perform - * @c: array of constants + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -634,10 +634,10 @@ vips_relational_const( VipsImage *in, VipsImage **out, } /** - * vips_equal_const: + * vips_equal_const: (method) * @in: input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -661,10 +661,10 @@ vips_equal_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_notequal_const: + * vips_notequal_const: (method) * @in: input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -688,10 +688,10 @@ vips_notequal_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_less_const: + * vips_less_const: (method) * @in: input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -715,10 +715,10 @@ vips_less_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_lesseq_const: + * vips_lesseq_const: (method) * @in: input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -742,10 +742,10 @@ vips_lesseq_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_more_const: + * vips_more_const: (method) * @in: input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -769,10 +769,10 @@ vips_more_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_moreeq_const: + * vips_moreeq_const: (method) * @in: input #VipsImage - * @out: output #VipsImage - * @c: array of constants + * @out: (out): output #VipsImage + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -796,9 +796,9 @@ vips_moreeq_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_relational_const1: + * vips_relational_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @relational: relational operation to perform * @c: constant * @...: %NULL-terminated list of optional named arguments @@ -825,9 +825,9 @@ vips_relational_const1( VipsImage *in, VipsImage **out, } /** - * vips_equal_const1: + * vips_equal_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -851,9 +851,9 @@ vips_equal_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_notequal_const1: + * vips_notequal_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -877,9 +877,9 @@ vips_notequal_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_less_const1: + * vips_less_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -903,9 +903,9 @@ vips_less_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_lesseq_const1: + * vips_lesseq_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -929,9 +929,9 @@ vips_lesseq_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_more_const1: + * vips_more_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * @@ -955,9 +955,9 @@ vips_more_const1( VipsImage *in, VipsImage **out, double c, ... ) } /** - * vips_moreeq_const1: + * vips_moreeq_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/arithmetic/remainder.c b/libvips/arithmetic/remainder.c index 71a6bb72..b845b37e 100644 --- a/libvips/arithmetic/remainder.c +++ b/libvips/arithmetic/remainder.c @@ -189,7 +189,7 @@ vips_remainder_init( VipsRemainder *remainder ) * vips_remainder: * @left: left-hand input #VipsImage * @right: right-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * This operation calculates @left % @right (remainder after integer division) @@ -357,10 +357,10 @@ vips_remainder_constv( VipsImage *in, VipsImage **out, } /** - * vips_remainder_const: + * vips_remainder_const: (method) * @in: input image - * @out: output image - * @c: array of constants + * @out: (out): output image + * @c: (array length=n): array of constants * @n: number of constants in @c * @...: %NULL-terminated list of optional named arguments * @@ -396,9 +396,9 @@ vips_remainder_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_remainder_const1: + * vips_remainder_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/arithmetic/round.c b/libvips/arithmetic/round.c index e066db49..04171dfe 100644 --- a/libvips/arithmetic/round.c +++ b/libvips/arithmetic/round.c @@ -186,9 +186,9 @@ vips_roundv( VipsImage *in, VipsImage **out, } /** - * vips_round: + * vips_round: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @round: #VipsOperationRound rounding operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -218,9 +218,9 @@ vips_round( VipsImage *in, VipsImage **out, VipsOperationRound round, ... ) } /** - * vips_floor: + * vips_floor: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Round to an integral value with #VIPS_OPERATION_ROUND_FLOOR. See @@ -242,9 +242,9 @@ vips_floor( VipsImage *in, VipsImage **out, ... ) } /** - * vips_ceil: + * vips_ceil: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Round to an integral value with #VIPS_OPERATION_ROUND_CEIL. See @@ -266,9 +266,9 @@ vips_ceil( VipsImage *in, VipsImage **out, ... ) } /** - * vips_rint: + * vips_rint: (method) * @in: input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Round to an integral value with #VIPS_OPERATION_ROUND_RINT. See diff --git a/libvips/arithmetic/sign.c b/libvips/arithmetic/sign.c index ba5ca359..2d1668cd 100644 --- a/libvips/arithmetic/sign.c +++ b/libvips/arithmetic/sign.c @@ -162,9 +162,9 @@ vips_sign_init( VipsSign *sign ) } /** - * vips_sign: + * vips_sign: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Finds the unit vector in the direction of the pixel value. For non-complex diff --git a/libvips/arithmetic/stats.c b/libvips/arithmetic/stats.c index 6d3502bd..81909b0d 100644 --- a/libvips/arithmetic/stats.c +++ b/libvips/arithmetic/stats.c @@ -429,9 +429,9 @@ vips_stats_init( VipsStats *stats ) } /** - * vips_stats: + * vips_stats: (method) * @in: image to scan - * @out: image of statistics + * @out: (out): image of statistics * @...: %NULL-terminated list of optional named arguments * * Find many image statistics in a single pass through the data. @out is a diff --git a/libvips/arithmetic/subtract.c b/libvips/arithmetic/subtract.c index 656acd11..768e35d1 100644 --- a/libvips/arithmetic/subtract.c +++ b/libvips/arithmetic/subtract.c @@ -175,7 +175,7 @@ vips_subtract_init( VipsSubtract *subtract ) * vips_subtract: * @in1: input image * @in2: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * This operation calculates @in1 - @in2 and writes the result to @out. diff --git a/libvips/arithmetic/sum.c b/libvips/arithmetic/sum.c index 79e9155f..241bdbf5 100644 --- a/libvips/arithmetic/sum.c +++ b/libvips/arithmetic/sum.c @@ -165,8 +165,8 @@ vips_sumv( VipsImage **in, VipsImage **out, int n, va_list ap ) /** * vips_sum: - * @in: array of input images - * @out: output image + * @in: (array length=n): array of input images + * @out: (out): output image * @n: number of input images * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/colour/HSV2sRGB.c b/libvips/colour/HSV2sRGB.c index e9835234..c11639e8 100644 --- a/libvips/colour/HSV2sRGB.c +++ b/libvips/colour/HSV2sRGB.c @@ -132,9 +132,9 @@ vips_HSV2sRGB_init( VipsHSV2sRGB *HSV2sRGB ) } /** - * vips_HSV2sRGB: + * vips_HSV2sRGB: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert HSV to sRGB. diff --git a/libvips/colour/LCh2Lab.c b/libvips/colour/LCh2Lab.c index 8e257b72..9f615cd3 100644 --- a/libvips/colour/LCh2Lab.c +++ b/libvips/colour/LCh2Lab.c @@ -136,9 +136,9 @@ vips_LCh2Lab_init( VipsLCh2Lab *LCh2Lab ) } /** - * vips_LCh2Lab: + * vips_LCh2Lab: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn LCh to Lab. diff --git a/libvips/colour/LCh2UCS.c b/libvips/colour/LCh2UCS.c index ffd11511..4fcc8245 100644 --- a/libvips/colour/LCh2UCS.c +++ b/libvips/colour/LCh2UCS.c @@ -217,9 +217,9 @@ vips_LCh2CMC_init( VipsLCh2CMC *LCh2CMC ) } /** - * vips_LCh2CMC: + * vips_LCh2CMC: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn LCh to CMC. diff --git a/libvips/colour/Lab2LCh.c b/libvips/colour/Lab2LCh.c index 7deeb621..9dccb587 100644 --- a/libvips/colour/Lab2LCh.c +++ b/libvips/colour/Lab2LCh.c @@ -160,9 +160,9 @@ vips_Lab2LCh_init( VipsLab2LCh *Lab2LCh ) } /** - * vips_Lab2LCh: + * vips_Lab2LCh: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn Lab to LCh. diff --git a/libvips/colour/Lab2LabQ.c b/libvips/colour/Lab2LabQ.c index f8d3df26..f152537e 100644 --- a/libvips/colour/Lab2LabQ.c +++ b/libvips/colour/Lab2LabQ.c @@ -156,9 +156,9 @@ vips_Lab2LabQ_init( VipsLab2LabQ *Lab2LabQ ) } /** - * vips_Lab2LabQ: + * vips_Lab2LabQ: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert a Lab three-band float image to LabQ (#VIPS_CODING_LABQ). diff --git a/libvips/colour/Lab2LabS.c b/libvips/colour/Lab2LabS.c index 08ea4096..939e9286 100644 --- a/libvips/colour/Lab2LabS.c +++ b/libvips/colour/Lab2LabS.c @@ -98,9 +98,9 @@ vips_Lab2LabS_init( VipsLab2LabS *Lab2LabS ) } /** - * vips_Lab2LabS: + * vips_Lab2LabS: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn Lab to LabS, signed 16-bit int fixed point. diff --git a/libvips/colour/Lab2XYZ.c b/libvips/colour/Lab2XYZ.c index 417983e7..5e229e41 100644 --- a/libvips/colour/Lab2XYZ.c +++ b/libvips/colour/Lab2XYZ.c @@ -192,9 +192,9 @@ vips_Lab2XYZ_init( VipsLab2XYZ *Lab2XYZ ) } /** - * vips_Lab2XYZ: + * vips_Lab2XYZ: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -224,9 +224,9 @@ vips_Lab2XYZ( VipsImage *in, VipsImage **out, ... ) * @L: Input CIE Lab value * @a: Input CIE Lab value * @b: Input CIE Lab value - * @X: Return CIE XYZ colour - * @Y: Return CIE XYZ colour - * @Z: Return CIE XYZ colour + * @X: (out): Return CIE XYZ colour + * @Y: (out): Return CIE XYZ colour + * @Z: (out): Return CIE XYZ colour * * Calculate XYZ from Lab, D65. * diff --git a/libvips/colour/LabQ2Lab.c b/libvips/colour/LabQ2Lab.c index 9cb0197f..b29b0c49 100644 --- a/libvips/colour/LabQ2Lab.c +++ b/libvips/colour/LabQ2Lab.c @@ -141,9 +141,9 @@ vips_LabQ2Lab_init( VipsLabQ2Lab *LabQ2Lab ) } /** - * vips_LabQ2Lab: + * vips_LabQ2Lab: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Unpack a LabQ (#VIPS_CODING_LABQ) image to a three-band float image. diff --git a/libvips/colour/LabQ2LabS.c b/libvips/colour/LabQ2LabS.c index 17d93c79..b6a2f635 100644 --- a/libvips/colour/LabQ2LabS.c +++ b/libvips/colour/LabQ2LabS.c @@ -121,9 +121,9 @@ vips_LabQ2LabS_init( VipsLabQ2LabS *LabQ2LabS ) } /** - * vips_LabQ2LabS: + * vips_LabQ2LabS: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Unpack a LabQ (#VIPS_CODING_LABQ) image to a three-band short image. diff --git a/libvips/colour/LabQ2sRGB.c b/libvips/colour/LabQ2sRGB.c index 28364b44..737b2712 100644 --- a/libvips/colour/LabQ2sRGB.c +++ b/libvips/colour/LabQ2sRGB.c @@ -531,9 +531,9 @@ vips_LabQ2sRGB_init( VipsLabQ2sRGB *LabQ2sRGB ) } /** - * vips_LabQ2sRGB: + * vips_LabQ2sRGB: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Unpack a LabQ (#VIPS_CODING_LABQ) image to a three-band short image. diff --git a/libvips/colour/LabS2Lab.c b/libvips/colour/LabS2Lab.c index a83113cc..d1cd1fbe 100644 --- a/libvips/colour/LabS2Lab.c +++ b/libvips/colour/LabS2Lab.c @@ -96,9 +96,9 @@ vips_LabS2Lab_init( VipsLabS2Lab *LabS2Lab ) } /** - * vips_LabS2Lab: + * vips_LabS2Lab: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert a LabS three-band signed short image to a three-band float image. diff --git a/libvips/colour/LabS2LabQ.c b/libvips/colour/LabS2LabQ.c index 368514a0..c3efef07 100644 --- a/libvips/colour/LabS2LabQ.c +++ b/libvips/colour/LabS2LabQ.c @@ -146,9 +146,9 @@ vips_LabS2LabQ_init( VipsLabS2LabQ *LabS2LabQ ) } /** - * vips_LabS2LabQ: + * vips_LabS2LabQ: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert a LabS three-band signed short image to LabQ diff --git a/libvips/colour/UCS2LCh.c b/libvips/colour/UCS2LCh.c index 26adccef..397861a8 100644 --- a/libvips/colour/UCS2LCh.c +++ b/libvips/colour/UCS2LCh.c @@ -284,9 +284,9 @@ vips_CMC2LCh_init( VipsCMC2LCh *CMC2LCh ) } /** - * vips_CMC2LCh: + * vips_CMC2LCh: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn LCh to CMC. diff --git a/libvips/colour/XYZ2Lab.c b/libvips/colour/XYZ2Lab.c index 6d96b46a..14a8b488 100644 --- a/libvips/colour/XYZ2Lab.c +++ b/libvips/colour/XYZ2Lab.c @@ -245,9 +245,9 @@ vips_XYZ2Lab_init( VipsXYZ2Lab *XYZ2Lab ) } /** - * vips_XYZ2Lab: + * vips_XYZ2Lab: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/colour/XYZ2Yxy.c b/libvips/colour/XYZ2Yxy.c index 49194515..c15c7c1b 100644 --- a/libvips/colour/XYZ2Yxy.c +++ b/libvips/colour/XYZ2Yxy.c @@ -103,9 +103,9 @@ vips_XYZ2Yxy_init( VipsXYZ2Yxy *XYZ2Yxy ) } /** - * vips_XYZ2Yxy: + * vips_XYZ2Yxy: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn XYZ to Yxy. diff --git a/libvips/colour/XYZ2scRGB.c b/libvips/colour/XYZ2scRGB.c index eccd4c09..671c599c 100644 --- a/libvips/colour/XYZ2scRGB.c +++ b/libvips/colour/XYZ2scRGB.c @@ -116,9 +116,9 @@ vips_XYZ2scRGB_init( VipsXYZ2scRGB *XYZ2scRGB ) } /** - * vips_XYZ2scRGB: + * vips_XYZ2scRGB: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn XYZ to scRGB. diff --git a/libvips/colour/Yxy2XYZ.c b/libvips/colour/Yxy2XYZ.c index 9289f349..b15e24e3 100644 --- a/libvips/colour/Yxy2XYZ.c +++ b/libvips/colour/Yxy2XYZ.c @@ -104,9 +104,9 @@ vips_Yxy2XYZ_init( VipsYxy2XYZ *Yxy2XYZ ) } /** - * vips_Yxy2XYZ: + * vips_Yxy2XYZ: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn XYZ to Yxy. diff --git a/libvips/colour/colourspace.c b/libvips/colour/colourspace.c index ef260a86..25d15033 100644 --- a/libvips/colour/colourspace.c +++ b/libvips/colour/colourspace.c @@ -601,7 +601,7 @@ vips_colourspace_class_init( VipsColourspaceClass *class ) G_STRUCT_OFFSET( VipsColourspace, space ), VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_sRGB ); - VIPS_ARG_ENUM( class, "source-space", 6, + VIPS_ARG_ENUM( class, "source_space", 6, _( "Source space" ), _( "Source color space" ), VIPS_ARGUMENT_OPTIONAL_INPUT, @@ -617,9 +617,9 @@ vips_colourspace_init( VipsColourspace *colourspace ) } /** - * vips_colourspace: + * vips_colourspace: (method) * @in: input image - * @out: output image + * @out: (out): output image * @space: convert to this colour space * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/colour/dE76.c b/libvips/colour/dE76.c index b32595ba..bb1b6edf 100644 --- a/libvips/colour/dE76.c +++ b/libvips/colour/dE76.c @@ -127,7 +127,7 @@ vips_dE76_init( VipsdE76 *dE76 ) * vips_dE76: * @left: first input image * @right: second input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Calculate dE 76. diff --git a/libvips/colour/dECMC.c b/libvips/colour/dECMC.c index 6aa8771f..726353e0 100644 --- a/libvips/colour/dECMC.c +++ b/libvips/colour/dECMC.c @@ -75,7 +75,7 @@ vips_dECMC_init( VipsdECMC *dECMC ) * vips_dECMC: * @left: first input image * @right: second input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Calculate dE CMC. The input images are transformed to CMC colour space and diff --git a/libvips/colour/float2rad.c b/libvips/colour/float2rad.c index 295f285a..11b069d8 100644 --- a/libvips/colour/float2rad.c +++ b/libvips/colour/float2rad.c @@ -220,9 +220,9 @@ vips_float2rad_init( VipsFloat2rad *float2rad ) } /** - * vips_float2rad: + * vips_float2rad: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert a three-band float image to Radiance 32-bit packed format. diff --git a/libvips/colour/icc_transform.c b/libvips/colour/icc_transform.c index 0a852d85..ca8a0c6c 100644 --- a/libvips/colour/icc_transform.c +++ b/libvips/colour/icc_transform.c @@ -1054,9 +1054,9 @@ vips_icc_transform_init( VipsIccTransform *transform ) } /** - * vips_icc_ac2rc: + * vips_icc_ac2rc: (method) * @in: input image - * @out: output image + * @out: (out): output image * @profile_filename: use this profile * * Transform an image from absolute to relative colorimetry using the @@ -1148,9 +1148,9 @@ vips_icc_ac2rc( VipsImage *in, VipsImage **out, const char *profile_filename ) #endif /*HAVE_LCMS*/ /** - * vips_icc_import: + * vips_icc_import: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -1191,9 +1191,9 @@ vips_icc_import( VipsImage *in, VipsImage **out, ... ) } /** - * vips_icc_export: + * vips_icc_export: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -1226,9 +1226,9 @@ vips_icc_export( VipsImage *in, VipsImage **out, ... ) } /** - * vips_icc_transform: + * vips_icc_transform: (method) * @in: input image - * @out: output image + * @out: (out): output image * @output_profile: get the output profile from here * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/colour/rad2float.c b/libvips/colour/rad2float.c index a02e94f2..cecbb38c 100644 --- a/libvips/colour/rad2float.c +++ b/libvips/colour/rad2float.c @@ -205,9 +205,9 @@ vips_rad2float_init( VipsRad2float *rad2float ) } /** - * vips_rad2float: + * vips_rad2float: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Unpack a RAD (#VIPS_CODING_RAD) image to a three-band float image. diff --git a/libvips/colour/sRGB2HSV.c b/libvips/colour/sRGB2HSV.c index 5dca321c..9368f41d 100644 --- a/libvips/colour/sRGB2HSV.c +++ b/libvips/colour/sRGB2HSV.c @@ -153,9 +153,9 @@ vips_sRGB2HSV_init( VipssRGB2HSV *sRGB2HSV ) } /** - * vips_sRGB2HSV: + * vips_sRGB2HSV: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert to HSV. diff --git a/libvips/colour/sRGB2scRGB.c b/libvips/colour/sRGB2scRGB.c index 24389506..0b0e877e 100644 --- a/libvips/colour/sRGB2scRGB.c +++ b/libvips/colour/sRGB2scRGB.c @@ -259,9 +259,9 @@ vips_sRGB2scRGB_init( VipssRGB2scRGB *sRGB2scRGB ) } /** - * vips_sRGB2scRGB: + * vips_sRGB2scRGB: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert an sRGB image to scRGB. The input image can be 8 or 16-bit. diff --git a/libvips/colour/scRGB2BW.c b/libvips/colour/scRGB2BW.c index a7f6fddd..d378ca06 100644 --- a/libvips/colour/scRGB2BW.c +++ b/libvips/colour/scRGB2BW.c @@ -261,9 +261,9 @@ vips_scRGB2BW_init( VipsscRGB2BW *scRGB2BW ) } /** - * vips_scRGB2BW: + * vips_scRGB2BW: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/colour/scRGB2XYZ.c b/libvips/colour/scRGB2XYZ.c index bf3750db..2596524a 100644 --- a/libvips/colour/scRGB2XYZ.c +++ b/libvips/colour/scRGB2XYZ.c @@ -101,9 +101,9 @@ vips_scRGB2XYZ_init( VipsscRGB2XYZ *scRGB2XYZ ) } /** - * vips_scRGB2XYZ: + * vips_scRGB2XYZ: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Turn XYZ to scRGB. diff --git a/libvips/colour/scRGB2sRGB.c b/libvips/colour/scRGB2sRGB.c index 6f8534f5..15149405 100644 --- a/libvips/colour/scRGB2sRGB.c +++ b/libvips/colour/scRGB2sRGB.c @@ -289,9 +289,9 @@ vips_scRGB2sRGB_init( VipsscRGB2sRGB *scRGB2sRGB ) } /** - * vips_scRGB2sRGB: + * vips_scRGB2sRGB: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/Makefile.am b/libvips/conversion/Makefile.am index 54e42b11..55b42c5f 100644 --- a/libvips/conversion/Makefile.am +++ b/libvips/conversion/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libconversion.la libconversion_la_SOURCES = \ + composite.cpp \ smartcrop.c \ conversion.c \ pconversion.h \ diff --git a/libvips/conversion/arrayjoin.c b/libvips/conversion/arrayjoin.c index 3b4e60d4..5f140408 100644 --- a/libvips/conversion/arrayjoin.c +++ b/libvips/conversion/arrayjoin.c @@ -384,7 +384,7 @@ vips_arrayjoinv( VipsImage **in, VipsImage **out, int n, va_list ap ) /** * vips_arrayjoin: * @in: (array length=n) (transfer none): array of input images - * @out: output image + * @out: (out): output image * @n: number of input images * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/conversion/autorot.c b/libvips/conversion/autorot.c index c693dbeb..44a37f00 100644 --- a/libvips/conversion/autorot.c +++ b/libvips/conversion/autorot.c @@ -125,7 +125,7 @@ vips_autorot_remove_angle_sub( VipsImage *image, } /** - * vips_autorot_remove_angle: + * vips_autorot_remove_angle: (method) * @image: image to remove orientation from * * Remove the orientation tag on @image. Also remove any exif orientation tags. @@ -195,9 +195,9 @@ vips_autorot_init( VipsAutorot *autorot ) } /** - * vips_autorot: + * vips_autorot: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/bandbool.c b/libvips/conversion/bandbool.c index d26c5d7d..25e2f440 100644 --- a/libvips/conversion/bandbool.c +++ b/libvips/conversion/bandbool.c @@ -239,9 +239,9 @@ vips_bandboolv( VipsImage *in, VipsImage **out, } /** - * vips_bandbool: + * vips_bandbool: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @boolean: boolean operation to perform * @...: %NULL-terminated list of optional named arguments * @@ -279,9 +279,9 @@ vips_bandbool( VipsImage *in, VipsImage **out, } /** - * vips_bandand: + * vips_bandand: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_AND on an image. See @@ -303,9 +303,9 @@ vips_bandand( VipsImage *in, VipsImage **out, ... ) } /** - * vips_bandor: + * vips_bandor: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_OR on an image. See @@ -327,9 +327,9 @@ vips_bandor( VipsImage *in, VipsImage **out, ... ) } /** - * vips_bandeor: + * vips_bandeor: (method) * @in: left-hand input #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Perform #VIPS_OPERATION_BOOLEAN_EOR on an image. See diff --git a/libvips/conversion/bandfold.c b/libvips/conversion/bandfold.c index 9ad72c5e..32e5ecff 100644 --- a/libvips/conversion/bandfold.c +++ b/libvips/conversion/bandfold.c @@ -179,9 +179,9 @@ vips_bandfold_init( VipsBandfold *bandfold ) } /** - * vips_bandfold: + * vips_bandfold: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/bandjoin.c b/libvips/conversion/bandjoin.c index ec397722..33275373 100644 --- a/libvips/conversion/bandjoin.c +++ b/libvips/conversion/bandjoin.c @@ -204,7 +204,7 @@ vips_bandjoinv( VipsImage **in, VipsImage **out, int n, va_list ap ) /** * vips_bandjoin: * @in: (array length=n) (transfer none): array of input images - * @out: output image + * @out: (out): output image * @n: number of input images * @...: %NULL-terminated list of optional named arguments * @@ -243,7 +243,7 @@ vips_bandjoin( VipsImage **in, VipsImage **out, int n, ... ) * vips_bandjoin2: * @in1: first input image * @in2: second input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Join a pair of images together, bandwise. See vips_bandjoin(). @@ -322,17 +322,35 @@ vips_bandjoin_const_buffer( VipsBandary *bandary, q1 = q; p1 = p[0]; - for( x = 0; x < width; x++ ) { - for( z = 0; z < ips; z++ ) - q1[z] = p1[z]; + /* Special path for 8-bit RGB -> RGBA ... it's a common case. + */ + if( ips == 3 && + ebs == 1 ) { + int c = bandjoin->c_ready[0]; - p1 += ips; - q1 += ips; + for( x = 0; x < width; x++ ) { + q1[0] = p1[0]; + q1[1] = p1[1]; + q1[2] = p1[2]; + q1[3] = c; - for( z = 0; z < ebs; z++ ) - q1[z] = bandjoin->c_ready[z]; + p1 += 3; + q1 += 4; + } + } + else { + for( x = 0; x < width; x++ ) { + for( z = 0; z < ips; z++ ) + q1[z] = p1[z]; - q1 += ebs; + p1 += ips; + q1 += ips; + + for( z = 0; z < ebs; z++ ) + q1[z] = bandjoin->c_ready[z]; + + q1 += ebs; + } } } @@ -428,9 +446,9 @@ vips_bandjoin_constv( VipsImage *in, VipsImage **out, } /** - * vips_bandjoin_const: - * @in: (array length=n) (transfer none): array of input images - * @out: output image + * vips_bandjoin_const: (method) + * @in: input image + * @out: (out): output image * @c: (array length=n): array of constants to append * @n: number of constants * @...: %NULL-terminated list of optional named arguments @@ -455,9 +473,9 @@ vips_bandjoin_const( VipsImage *in, VipsImage **out, double *c, int n, ... ) } /** - * vips_bandjoin_const1: + * vips_bandjoin_const1: (method) * @in: input image - * @out: output image + * @out: (out): output image * @c: constant to append * @...: %NULL-terminated list of optional named arguments * @@ -477,3 +495,30 @@ vips_bandjoin_const1( VipsImage *in, VipsImage **out, double c, ... ) return( result ); } + +/* vips_addalpha: + * @in: input image + * @out: output image + * @...: %NULL-terminated list of optional named arguments + * + * Append an alpha channel. + * + * See also: vips_image_hasalpha(). + * + * Returns: 0 on success, -1 on error + */ +int +vips_addalpha( VipsImage *in, VipsImage **out, ... ) +{ + double max_alpha; + + max_alpha = 255.0; + if( in->Type == VIPS_INTERPRETATION_GREY16 || + in->Type == VIPS_INTERPRETATION_RGB16 ) + max_alpha = 65535; + + if( vips_bandjoin_const1( in, out, max_alpha, NULL ) ) + return( -1 ); + + return( 0 ); +} diff --git a/libvips/conversion/bandmean.c b/libvips/conversion/bandmean.c index 2dd7d01a..f3f057fe 100644 --- a/libvips/conversion/bandmean.c +++ b/libvips/conversion/bandmean.c @@ -207,9 +207,9 @@ vips_bandmean_init( VipsBandmean *bandmean ) } /** - * vips_bandmean: + * vips_bandmean: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * This operation writes a one-band image where each pixel is the average of diff --git a/libvips/conversion/bandrank.c b/libvips/conversion/bandrank.c index 06ceb969..5256005a 100644 --- a/libvips/conversion/bandrank.c +++ b/libvips/conversion/bandrank.c @@ -279,8 +279,8 @@ vips_bandrankv( VipsImage **in, VipsImage **out, int n, va_list ap ) /** * vips_bandrank: - * @in: array of input images - * @out: output image + * @in: (array length=n): array of input images + * @out: (out): output image * @n: number of input images * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/conversion/bandunfold.c b/libvips/conversion/bandunfold.c index 0aa6064a..c5687f7a 100644 --- a/libvips/conversion/bandunfold.c +++ b/libvips/conversion/bandunfold.c @@ -182,9 +182,9 @@ vips_bandunfold_init( VipsBandunfold *bandunfold ) } /** - * vips_bandunfold: + * vips_bandunfold: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/byteswap.c b/libvips/conversion/byteswap.c index be6a834a..c5048fed 100644 --- a/libvips/conversion/byteswap.c +++ b/libvips/conversion/byteswap.c @@ -216,9 +216,9 @@ vips_byteswap_init( VipsByteswap *byteswap ) } /** - * vips_byteswap: + * vips_byteswap: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Swap the byte order in an image. diff --git a/libvips/conversion/cache.c b/libvips/conversion/cache.c index a7243030..24616cb2 100644 --- a/libvips/conversion/cache.c +++ b/libvips/conversion/cache.c @@ -137,9 +137,9 @@ vips_cache_init( VipsCache *cache ) } /** - * vips_cache: + * vips_cache: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/cast.c b/libvips/conversion/cast.c index f984af9e..9f7e9efc 100644 --- a/libvips/conversion/cast.c +++ b/libvips/conversion/cast.c @@ -577,9 +577,9 @@ vips_castv( VipsImage *in, VipsImage **out, VipsBandFormat format, va_list ap ) } /** - * vips_cast: + * vips_cast: (method) * @in: input image - * @out: output image + * @out: (out): output image * @format: format to convert to * @...: %NULL-terminated list of optional named arguments * @@ -616,9 +616,9 @@ vips_cast( VipsImage *in, VipsImage **out, VipsBandFormat format, ... ) } /** - * vips_cast_uchar: + * vips_cast_uchar: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_UCHAR. See vips_cast(). @@ -639,9 +639,9 @@ vips_cast_uchar( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_char: + * vips_cast_char: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_CHAR. See vips_cast(). @@ -662,9 +662,9 @@ vips_cast_char( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_ushort: + * vips_cast_ushort: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_USHORT. See vips_cast(). @@ -685,9 +685,9 @@ vips_cast_ushort( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_short: + * vips_cast_short: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_SHORT. See vips_cast(). @@ -708,9 +708,9 @@ vips_cast_short( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_uint: + * vips_cast_uint: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_UINT. See vips_cast(). @@ -731,9 +731,9 @@ vips_cast_uint( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_int: + * vips_cast_int: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_INT. See vips_cast(). @@ -754,9 +754,9 @@ vips_cast_int( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_float: + * vips_cast_float: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_FLOAT. See vips_cast(). @@ -777,9 +777,9 @@ vips_cast_float( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_double: + * vips_cast_double: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_DOUBLE. See vips_cast(). @@ -800,9 +800,9 @@ vips_cast_double( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_complex: + * vips_cast_complex: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_COMPLEX. See vips_cast(). @@ -823,9 +823,9 @@ vips_cast_complex( VipsImage *in, VipsImage **out, ... ) } /** - * vips_cast_dpcomplex: + * vips_cast_dpcomplex: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert @in to #VIPS_FORMAT_DPCOMPLEX. See vips_cast(). diff --git a/libvips/conversion/composite.cpp b/libvips/conversion/composite.cpp new file mode 100644 index 00000000..174a59ce --- /dev/null +++ b/libvips/conversion/composite.cpp @@ -0,0 +1,1265 @@ +/* composite an array of images with PDF operators + * + * 25/9/17 + * - from bandjoin.c + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +/* +#define VIPS_DEBUG + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "pconversion.h" + +/* Maximum number of input images -- why not? + */ +#define MAX_INPUT_IMAGES (64) + +/* Maximum number of image bands. + */ +#define MAX_BANDS (64) + +/* Uncomment to disable the vector path ... handy for debugging. +#undef HAVE_VECTOR_ARITH + */ + +/** + * VipsBlendMode: + * VIPS_BLEND_MODE_CLEAR: + * VIPS_BLEND_MODE_SOURCE: + * VIPS_BLEND_MODE_OVER: + * VIPS_BLEND_MODE_IN: + * VIPS_BLEND_MODE_OUT: + * VIPS_BLEND_MODE_ATOP: + * VIPS_BLEND_MODE_DEST: + * VIPS_BLEND_MODE_DEST_OVER: + * VIPS_BLEND_MODE_DEST_IN: + * VIPS_BLEND_MODE_DEST_OUT: + * VIPS_BLEND_MODE_DEST_ATOP: + * VIPS_BLEND_MODE_XOR: + * VIPS_BLEND_MODE_ADD: + * VIPS_BLEND_MODE_SATURATE: + * VIPS_BLEND_MODE_MULTIPLY: + * VIPS_BLEND_MODE_SCREEN: + * VIPS_BLEND_MODE_OVERLAY: + * VIPS_BLEND_MODE_DARKEN: + * VIPS_BLEND_MODE_LIGHTEN: + * VIPS_BLEND_MODE_COLOUR_DODGE: + * VIPS_BLEND_MODE_COLOUR_BURN: + * VIPS_BLEND_MODE_HARD_LIGHT: + * VIPS_BLEND_MODE_SOFT_LIGHT: + * VIPS_BLEND_MODE_DIFFERENCE: + * VIPS_BLEND_MODE_EXCLUSION: + * + * The various Porter-Duff and PDF blend modes. See vips_composite(), + * for example. + * + * The Cairo docs have a nice explanation of all the blend modes: + * + * https://www.cairographics.org/operators + */ + +/* We have a vector path with gcc's vector attr. + */ +#ifdef HAVE_VECTOR_ARITH +/* A vector of four floats. + */ +typedef float v4f __attribute__((vector_size(4 * sizeof(float)))); +#endif /*HAVE_VECTOR_ARITH*/ + +typedef struct _VipsComposite { + VipsConversion parent_instance; + + /* The input images. + */ + VipsArrayImage *in; + + /* For N input images, N - 1 blend modes. + */ + VipsArrayInt *mode; + + /* Compositing space. This defaults to RGB, or B_W if we only have + * G and GA inputs. + */ + VipsInterpretation compositing_space; + + /* Set if the input images have already been premultiplied. + */ + gboolean premultiplied; + + /* The number of inputs. This can be less than the number of images in + * @in. + */ + int n; + + /* The number of non-alpha bands we are blending. + */ + int bands; + + /* The maximum value for each band, set from the image interpretation. + * This is used to scale each band to 0 - 1. + */ + double max_band[MAX_BANDS + 1]; + +#ifdef HAVE_VECTOR_ARITH + /* max_band as a vector, for the RGBA case. + */ + v4f max_band_vec; +#endif /*HAVE_VECTOR_ARITH*/ + +} VipsComposite; + +typedef VipsConversionClass VipsCompositeClass; + +/* We need C linkage for this. + */ +extern "C" { +G_DEFINE_TYPE( VipsComposite, vips_composite, VIPS_TYPE_CONVERSION ); +} + +/* For each of the supported interpretations, the maximum value of each band. + */ +static int +vips_composite_max_band( VipsComposite *composite, double *max_band ) +{ + double max_alpha; + int b; + + max_alpha = 255.0; + if( composite->compositing_space == VIPS_INTERPRETATION_GREY16 || + composite->compositing_space == VIPS_INTERPRETATION_RGB16 ) + max_alpha = 65535.0; + + for( b = 0; b <= composite->bands; b++ ) + max_band[b] = max_alpha; + + switch( composite->compositing_space ) { + case VIPS_INTERPRETATION_XYZ: + max_band[0] = VIPS_D65_X0; + max_band[1] = VIPS_D65_Y0; + max_band[2] = VIPS_D65_Z0; + break; + + case VIPS_INTERPRETATION_LAB: + max_band[0] = 100; + max_band[1] = 128; + max_band[2] = 128; + break; + + case VIPS_INTERPRETATION_LCH: + max_band[0] = 100; + max_band[1] = 128; + max_band[2] = 360; + break; + + case VIPS_INTERPRETATION_CMC: + max_band[0] = 100; + max_band[1] = 128; + max_band[2] = 360; + break; + + case VIPS_INTERPRETATION_scRGB: + max_band[0] = 1; + max_band[1] = 1; + max_band[2] = 1; + break; + + case VIPS_INTERPRETATION_sRGB: + max_band[0] = 255; + max_band[1] = 255; + max_band[2] = 255; + break; + + case VIPS_INTERPRETATION_HSV: + max_band[0] = 255; + max_band[1] = 255; + max_band[2] = 255; + break; + + case VIPS_INTERPRETATION_RGB16: + max_band[0] = 65535; + max_band[1] = 65535; + max_band[2] = 65535; + break; + + case VIPS_INTERPRETATION_GREY16: + max_band[0] = 65535; + break; + + case VIPS_INTERPRETATION_YXY: + max_band[0] = 100; + max_band[1] = 1; + max_band[2] = 1; + break; + + case VIPS_INTERPRETATION_B_W: + max_band[0] = 256; + break; + + default: + return( -1 ); + } + + return( 0 ); +} + +/* Cairo naming conventions: + * + * aR alpha of result + * aA alpha of source A (the new pixel) + * aB alpha of source B (the thing we accumulate) + * xR colour band of result + * xA colour band of source A + * xB colour band of source B + */ + +/* A is the new pixel coming in, of any non-complex type T. + * + * We must scale incoming pixels to 0 - 1 by dividing by the scale[] vector. + * + * If premultipled is not set, we premultiply incoming pixels before blending. + * + * B is the double pixel we are accumulating. + */ +template +static void +vips_composite_blend( VipsComposite *composite, + VipsBlendMode mode, double * restrict B, T * restrict p ) +{ + const int bands = composite->bands; + + double A[MAX_BANDS + 1]; + double aA; + double aB; + double aR; + double t1; + double t2; + double t3; + double f[MAX_BANDS + 1]; + + /* Load and scale the pixel to 0 - 1. + */ + for( int b = 0; b <= bands; b++ ) + A[b] = p[b] / composite->max_band[b]; + + aA = A[bands]; + aB = B[bands]; + + /* We may need to premultiply A. + */ + if( !composite->premultiplied ) + for( int b = 0; b < bands; b++ ) + A[b] *= aA; + + switch( mode ) { + case VIPS_BLEND_MODE_CLEAR: + aR = 0; + for( int b = 0; b < bands; b++ ) + B[b] = 0; + break; + + case VIPS_BLEND_MODE_SOURCE: + aR = aA; + for( int b = 0; b < bands; b++ ) + B[b] = A[b]; + break; + + case VIPS_BLEND_MODE_OVER: + aR = aA + aB * (1 - aA); + t1 = 1 - aA; + for( int b = 0; b < bands; b++ ) + B[b] = A[b] + t1 * B[b]; + break; + + case VIPS_BLEND_MODE_IN: + aR = aA * aB; + for( int b = 0; b < bands; b++ ) + B[b] = A[b]; + break; + + case VIPS_BLEND_MODE_OUT: + aR = aA * (1 - aB); + for( int b = 0; b < bands; b++ ) + B[b] = A[b]; + break; + + case VIPS_BLEND_MODE_ATOP: + aR = aB; + t1 = 1 - aA; + for( int b = 0; b < bands; b++ ) + B[b] = A[b] + t1 * B[b]; + break; + + case VIPS_BLEND_MODE_DEST: + aR = aB; + // B = B + break; + + case VIPS_BLEND_MODE_DEST_OVER: + aR = aB + aA * (1 - aB); + t1 = 1 - aB; + for( int b = 0; b < bands; b++ ) + B[b] = B[b] + t1 * A[b]; + break; + + case VIPS_BLEND_MODE_DEST_IN: + aR = aA * aB; + // B = B + break; + + case VIPS_BLEND_MODE_DEST_OUT: + aR = (1 - aA) * aB; + // B = B + break; + + case VIPS_BLEND_MODE_DEST_ATOP: + aR = aA; + t1 = 1 - aA; + for( int b = 0; b < bands; b++ ) + B[b] = t1 * A[b] + B[b]; + break; + + case VIPS_BLEND_MODE_XOR: + aR = aA + aB - 2 * aA * aB; + t1 = 1 - aB; + t2 = 1 - aA; + for( int b = 0; b < bands; b++ ) + B[b] = t1 * A[b] + t2 * B[b]; + break; + + case VIPS_BLEND_MODE_ADD: + aR = VIPS_MIN( 1, aA + aB ); + for( int b = 0; b < bands; b++ ) + B[b] = A[b] + B[b]; + break; + + case VIPS_BLEND_MODE_SATURATE: + aR = VIPS_MIN( 1, aA + aB ); + t1 = VIPS_MIN( aA, 1 - aB ); + for( int b = 0; b < bands; b++ ) + B[b] = t1 * A[b] + B[b]; + break; + + default: + /* The PDF modes are a bit different. + */ + aR = aA + aB * (1 - aA); + + switch( mode ) { + case VIPS_BLEND_MODE_MULTIPLY: + for( int b = 0; b < bands; b++ ) + f[b] = A[b] * B[b]; + break; + + case VIPS_BLEND_MODE_SCREEN: + for( int b = 0; b < bands; b++ ) + f[b] = A[b] + B[b] - A[b] * B[b]; + break; + + case VIPS_BLEND_MODE_OVERLAY: + for( int b = 0; b < bands; b++ ) + if( B[b] <= 0.5 ) + f[b] = 2 * A[b] * B[b]; + else + f[b] = 1 - 2 * (1 - A[b]) * (1 - B[b]); + break; + + case VIPS_BLEND_MODE_DARKEN: + for( int b = 0; b < bands; b++ ) + f[b] = VIPS_MIN( A[b], B[b] ); + break; + + case VIPS_BLEND_MODE_LIGHTEN: + for( int b = 0; b < bands; b++ ) + f[b] = VIPS_MAX( A[b], B[b] ); + break; + + case VIPS_BLEND_MODE_COLOUR_DODGE: + for( int b = 0; b < bands; b++ ) + if( A[b] < 1 ) + f[b] = VIPS_MIN( 1, B[b] / (1 - A[b]) ); + else + f[b] = 1; + break; + + case VIPS_BLEND_MODE_COLOUR_BURN: + for( int b = 0; b < bands; b++ ) + if( A[b] > 0 ) + f[b] = 1 - VIPS_MIN( 1, + (1 - B[b]) / A[b] ); + else + f[b] = 0; + break; + + case VIPS_BLEND_MODE_HARD_LIGHT: + for( int b = 0; b < bands; b++ ) + if( A[b] < 0.5 ) + f[b] = 2 * A[b] * B[b]; + else + f[b] = 1 - 2 * (1 - A[b]) * (1 - B[b]); + break; + + case VIPS_BLEND_MODE_SOFT_LIGHT: + for( int b = 0; b < bands; b++ ) { + double g; + + if( B[b] <= 0.25 ) + g = ((16 * B[b] - 12) * B[b] + 4) * B[b]; + else + g = sqrt( B[b] ); + + if( A[b] <= 0.5 ) + f[b] = B[b] - (1 - 2 * A[b]) * + B[b] * (1 - B[b]); + else + f[b] = B[b] + (2 * A[b] - 1) * + (g - B[b]); + } + break; + + case VIPS_BLEND_MODE_DIFFERENCE: + for( int b = 0; b < bands; b++ ) + f[b] = abs( B[b] - A[b] ); + break; + + case VIPS_BLEND_MODE_EXCLUSION: + for( int b = 0; b < bands; b++ ) + f[b] = A[b] + B[b] - 2 * A[b] * B[b]; + break; + + default: + g_assert_not_reached(); + for( int b = 0; b < bands; b++ ) + B[b] = 0; + } + + t1 = 1 - aB; + t2 = 1 - aA; + t3 = aA * aB; + for( int b = 0; b < bands; b++ ) + B[b] = t1 * A[b] + t2 * B[b] + t3 * f[b]; + break; + } + + B[bands] = aR; +} + +/* We have a vector path with gcc's vector attr. + */ +#ifdef HAVE_VECTOR_ARITH +/* Special path for RGBA with non-double output. This is overwhelmingly the most + * common case, and vectorises easily. + * + * B is the float pixel we are accumulating, A is the new pixel coming + * in from memory. + */ +template +static void +vips_composite_blend3( VipsComposite *composite, + VipsBlendMode mode, v4f &B, T * restrict p ) +{ + v4f A; + float aA; + float aB; + float aR; + float t1; + float t2; + float t3; + v4f f; + v4f g; + + /* Load and scale the pixel to 0 - 1. + */ + A[0] = p[0]; + A[1] = p[1]; + A[2] = p[2]; + A[3] = p[3]; + + A /= composite->max_band_vec; + + aA = A[3]; + aB = B[3]; + + /* We may need to premultiply A. + */ + if( !composite->premultiplied ) + A *= aA; + + switch( mode ) { + case VIPS_BLEND_MODE_CLEAR: + aR = 0; + B[0] = 0; + B[1] = 0; + B[2] = 0; + break; + + case VIPS_BLEND_MODE_SOURCE: + aR = aA; + B = A; + break; + + case VIPS_BLEND_MODE_OVER: + aR = aA + aB * (1 - aA); + t1 = 1 - aA; + B = A + t1 * B; + break; + + case VIPS_BLEND_MODE_IN: + aR = aA * aB; + B = A; + break; + + case VIPS_BLEND_MODE_OUT: + aR = aA * (1 - aB); + B = A; + break; + + case VIPS_BLEND_MODE_ATOP: + aR = aB; + t1 = 1 - aA; + B = A + t1 * B; + break; + + case VIPS_BLEND_MODE_DEST: + aR = aB; + // B = B + break; + + case VIPS_BLEND_MODE_DEST_OVER: + aR = aB + aA * (1 - aB); + t1 = 1 - aB; + B = B + t1 * A; + break; + + case VIPS_BLEND_MODE_DEST_IN: + aR = aA * aB; + // B = B + break; + + case VIPS_BLEND_MODE_DEST_OUT: + aR = (1 - aA) * aB; + // B = B + break; + + case VIPS_BLEND_MODE_DEST_ATOP: + aR = aA; + t1 = 1 - aA; + B = t1 * A + B; + break; + + case VIPS_BLEND_MODE_XOR: + aR = aA + aB - 2 * aA * aB; + t1 = 1 - aB; + t2 = 1 - aA; + B = t1 * A + t2 * B; + break; + + case VIPS_BLEND_MODE_ADD: + aR = VIPS_MIN( 1, aA + aB ); + B = A + B; + break; + + case VIPS_BLEND_MODE_SATURATE: + aR = VIPS_MIN( 1, aA + aB ); + t1 = VIPS_MIN( aA, 1 - aB ); + B = t1 * A + B; + break; + + default: + /* The PDF modes are a bit different. + */ + aR = aA + aB * (1 - aA); + + switch( mode ) { + case VIPS_BLEND_MODE_MULTIPLY: + f = A * B; + break; + + case VIPS_BLEND_MODE_SCREEN: + f = A + B - A * B; + break; + + case VIPS_BLEND_MODE_OVERLAY: + f = B <= 0.5 ? + 2 * A * B : + 1 - 2 * (1 - A) * (1 - B); + break; + + case VIPS_BLEND_MODE_DARKEN: + f = VIPS_MIN( A, B ); + break; + + case VIPS_BLEND_MODE_LIGHTEN: + f = VIPS_MAX( A, B ); + break; + + case VIPS_BLEND_MODE_COLOUR_DODGE: + f = A < 1 ? + VIPS_MIN( 1, B / (1 - A) ) : + 1; + break; + + case VIPS_BLEND_MODE_COLOUR_BURN: + f = A > 0 ? + 1 - VIPS_MIN( 1, (1 - B) / A ) : + 0; + break; + + case VIPS_BLEND_MODE_HARD_LIGHT: + f = A < 0.5 ? + 2 * A * B : + 1 - 2 * (1 - A) * (1 - B); + break; + + case VIPS_BLEND_MODE_SOFT_LIGHT: + /* You can't sqrt a vector, so we must loop. + */ + for( int b = 0; b < 3; b++ ) { + double g; + + if( B[b] <= 0.25 ) + g = ((16 * B[b] - 12) * B[b] + 4) * B[b]; + else + g = sqrt( B[b] ); + + if( A[b] <= 0.5 ) + f[b] = B[b] - (1 - 2 * A[b]) * + B[b] * (1 - B[b]); + else + f[b] = B[b] + (2 * A[b] - 1) * + (g - B[b]); + } + break; + + case VIPS_BLEND_MODE_DIFFERENCE: + g = B - A; + f = g > 0 ? g : -1 * g; + break; + + case VIPS_BLEND_MODE_EXCLUSION: + f = A + B - 2 * A * B; + break; + + default: + g_assert_not_reached(); + for( int b = 0; b < 3; b++ ) + B[b] = 0; + } + + t1 = 1 - aB; + t2 = 1 - aA; + t3 = aA * aB; + B = t1 * A + t2 * B + t3 * f; + break; + } + + B[3] = aR; +} +#endif /*HAVE_VECTOR_ARITH*/ + +/* min_T and max_T are the numeric range for this type. 0, 0 means no limit, + * for example float. + */ +template +static void +vips_combine_pixels( VipsComposite *composite, VipsPel *q, VipsPel **p ) +{ + VipsBlendMode *m = (VipsBlendMode *) composite->mode->area.data; + int n = composite->n; + int bands = composite->bands; + T * restrict tq = (T * restrict) q; + T ** restrict tp = (T ** restrict) p; + + double B[MAX_BANDS + 1]; + double aB; + + /* Load and scale the base pixel to 0 - 1. + */ + for( int b = 0; b <= bands; b++ ) + B[b] = tp[0][b] / composite->max_band[b]; + + aB = B[bands]; + if( !composite->premultiplied ) + for( int b = 0; b < bands; b++ ) + B[b] *= aB; + + for( int i = 1; i < n; i++ ) + vips_composite_blend( composite, m[i - 1], B, tp[i] ); + + /* Unpremultiply, if necessary. + */ + if( !composite->premultiplied ) { + double aR = B[bands]; + + if( aR == 0 ) + for( int b = 0; b < bands; b++ ) + B[b] = 0; + else + for( int b = 0; b < bands; b++ ) + B[b] = B[b] / aR; + } + + /* Write back as a full range pixel, clipping to range. + */ + for( int b = 0; b <= bands; b++ ) { + double v; + + v = B[b] * composite->max_band[b]; + if( min_T != 0 || + max_T != 0 ) { + v = VIPS_CLIP( min_T, v, max_T ); + } + + tq[b] = v; + } +} + +#ifdef HAVE_VECTOR_ARITH +/* Three band (four with alpha) vecvtior case. Non-double output. min_T and + * max_T are the numeric range for this type. 0, 0 means no limit, + * for example float. + */ +template +static void +vips_combine_pixels3( VipsComposite *composite, VipsPel *q, VipsPel **p ) +{ + VipsBlendMode *m = (VipsBlendMode *) composite->mode->area.data; + int n = composite->n; + T * restrict tq = (T * restrict) q; + T ** restrict tp = (T ** restrict) p; + + v4f B; + float aB; + + B[0] = tp[0][0]; + B[1] = tp[0][1]; + B[2] = tp[0][2]; + B[3] = tp[0][3]; + + /* Scale the base pixel to 0 - 1. + */ + B /= composite->max_band_vec; + aB = B[3]; + + if( !composite->premultiplied ) { + B *= aB; + B[3] = aB; + } + + for( int i = 1; i < n; i++ ) + vips_composite_blend3( composite, m[i - 1], B, tp[i] ); + + /* Unpremultiply, if necessary. + */ + if( !composite->premultiplied ) { + float aR = B[3]; + + if( aR == 0 ) + for( int b = 0; b < 3; b++ ) + B[b] = 0; + else { + B /= aR; + B[3] = aR; + } + } + + /* Write back as a full range pixel, clipping to range. + */ + B *= composite->max_band_vec; + if( min_T != 0 || + max_T != 0 ) { + float low = min_T; + float high = max_T; + + B = VIPS_CLIP( low, B, high ); + } + + tq[0] = B[0]; + tq[1] = B[1]; + tq[2] = B[2]; + tq[3] = B[3]; +} +#endif /*HAVE_VECTOR_ARITH*/ + +static int +vips_composite_gen( VipsRegion *output_region, + void *seq, void *a, void *b, gboolean *stop ) +{ + VipsRegion **input_regions = (VipsRegion **) seq; + VipsComposite *composite = (VipsComposite *) b; + VipsRect *r = &output_region->valid; + int ps = VIPS_IMAGE_SIZEOF_PEL( output_region->im ); + + if( vips_reorder_prepare_many( output_region->im, input_regions, r ) ) + return( -1 ); + + VIPS_GATE_START( "vips_composite_gen: work" ); + + for( int y = 0; y < r->height; y++ ) { + VipsPel *p[MAX_INPUT_IMAGES]; + VipsPel *q; + + for( int i = 0; i < composite->n; i++ ) + p[i] = VIPS_REGION_ADDR( input_regions[i], + r->left, r->top + y ); + p[composite->n] = NULL; + q = VIPS_REGION_ADDR( output_region, r->left, r->top + y ); + + for( int x = 0; x < r->width; x++ ) { + switch( input_regions[0]->im->BandFmt ) { + case VIPS_FORMAT_UCHAR: +#ifdef HAVE_VECTOR_ARITH + if( composite->bands == 3 ) + vips_combine_pixels3 + + ( composite, q, p ); + else +#endif + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_CHAR: + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_USHORT: +#ifdef HAVE_VECTOR_ARITH + if( composite->bands == 3 ) + vips_combine_pixels3 + + ( composite, q, p ); + else +#endif + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_SHORT: + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_UINT: + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_INT: + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_FLOAT: +#ifdef HAVE_VECTOR_ARITH + if( composite->bands == 3 ) + vips_combine_pixels3 + + ( composite, q, p ); + else +#endif + vips_combine_pixels + + ( composite, q, p ); + break; + + case VIPS_FORMAT_DOUBLE: + vips_combine_pixels + + ( composite, q, p ); + break; + + default: + g_assert_not_reached(); + return( -1 ); + } + + for( int i = 0; i < composite->n; i++ ) + p[i] += ps; + q += ps; + } + } + + VIPS_GATE_STOP( "vips_composite_gen: work" ); + + return( 0 ); +} + +static int +vips_composite_build( VipsObject *object ) +{ + VipsObjectClass *klass = VIPS_OBJECT_GET_CLASS( object ); + VipsConversion *conversion = VIPS_CONVERSION( object ); + VipsComposite *composite = (VipsComposite *) object; + + VipsImage **in; + VipsImage **decode; + VipsImage **compositing; + VipsImage **format; + VipsImage **size; + VipsBlendMode *mode; + + if( VIPS_OBJECT_CLASS( vips_composite_parent_class )->build( object ) ) + return( -1 ); + + composite->n = composite->in->area.n; + + if( composite->n <= 0 ) { + vips_error( klass->nickname, "%s", _( "no input images" ) ); + return( -1 ); + } + if( composite->mode->area.n != composite->n - 1 ) { + vips_error( klass->nickname, + _( "for %d input images there must be %d blend modes" ), + composite->n, composite->n - 1 ); + return( -1 ); + } + mode = (VipsBlendMode *) composite->mode->area.data; + for( int i = 0; i < composite->n - 1; i++ ) { + if( mode[i] < 0 || + mode[i] >= VIPS_BLEND_MODE_LAST ) { + vips_error( klass->nickname, + _( "blend mode index %d (%d) invalid" ), + i, mode[i] ); + return( -1 ); + } + } + + in = (VipsImage **) composite->in->area.data; + + decode = (VipsImage **) vips_object_local_array( object, composite->n ); + for( int i = 0; i < composite->n; i++ ) + if( vips_image_decode( in[i], &decode[i] ) ) + return( -1 ); + in = decode; + + /* Are any of the images missing an alpha? The first missing alpha is + * given a solid 255 and becomes the background image, shortening n. + */ + for( int i = composite->n - 1; i >= 0; i-- ) + if( !vips_image_hasalpha( in[i] ) ) { + VipsImage *x; + + if( vips_addalpha( in[i], &x, NULL ) ) + return( -1 ); + g_object_unref( in[i] ); + in[i] = x; + + composite->n -= i; + in += i; + + break; + } + + if( composite->n > MAX_INPUT_IMAGES ) { + vips_error( klass->nickname, + "%s", _( "too many input images" ) ); + return( -1 ); + } + + /* Transform to compositing space. It defaults to sRGB or B_W, usually + * 8 bit, but 16 bit if any inputs are 16 bit. + */ + if( !vips_object_argument_isset( object, "compositing_space" ) ) { + gboolean all_grey; + gboolean any_16; + + all_grey = TRUE; + for( int i = 0; i < composite->n; i++ ) + if( in[i]->Bands > 2 ) { + all_grey = FALSE; + break; + } + + any_16 = FALSE; + for( int i = 0; i < composite->n; i++ ) + if( in[i]->Type == VIPS_INTERPRETATION_GREY16 || + in[i]->Type == VIPS_INTERPRETATION_RGB16 ) { + any_16 = TRUE; + break; + } + + composite->compositing_space = any_16 ? + (all_grey ? + VIPS_INTERPRETATION_GREY16 : + VIPS_INTERPRETATION_RGB16) : + (all_grey ? + VIPS_INTERPRETATION_B_W : + VIPS_INTERPRETATION_sRGB); + } + + compositing = (VipsImage **) + vips_object_local_array( object, composite->n ); + for( int i = 0; i < composite->n; i++ ) + if( vips_colourspace( in[i], &compositing[i], + composite->compositing_space, NULL ) ) + return( -1 ); + in = compositing; + + /* Check that they all now match in bands. This can fail for some + * input combinations. + */ + for( int i = 1; i < composite->n; i++ ) + if( in[i]->Bands != in[0]->Bands ) { + vips_error( klass->nickname, + "%s", _( "images do not have same " + "numbers of bands" ) ); + return( -1 ); + } + + if( in[0]->Bands > MAX_BANDS ) { + vips_error( klass->nickname, + "%s", _( "too many input bands" ) ); + return( -1 ); + } + + composite->bands = in[0]->Bands - 1; + + /* Set the max for each band now we know bands and compositing space. + */ + if( vips_composite_max_band( composite, composite->max_band ) ) { + vips_error( klass->nickname, + "%s", _( "unsupported compositing space" ) ); + return( -1 ); + } + +#ifdef HAVE_VECTOR_ARITH + /* We need a float version for the vector path. + */ + if( composite->bands == 3 ) + for( int b = 0; b <= 3; b++ ) + composite->max_band_vec[b] = composite->max_band[b]; +#endif /*HAVE_VECTOR_ARITH*/ + + /* Transform the input images to match in size and format. We may have + * mixed float and double, for example. + */ + format = (VipsImage **) vips_object_local_array( object, composite->n ); + size = (VipsImage **) vips_object_local_array( object, composite->n ); + if( vips__formatalike_vec( in, format, composite->n ) || + vips__sizealike_vec( format, size, composite->n ) ) + return( -1 ); + in = size; + + if( vips_image_pipeline_array( conversion->out, + VIPS_DEMAND_STYLE_THINSTRIP, in ) ) + return( -1 ); + + if( vips_image_generate( conversion->out, + vips_start_many, vips_composite_gen, vips_stop_many, + in, composite ) ) + return( -1 ); + + return( 0 ); +} + +static void +vips_composite_class_init( VipsCompositeClass *klass ) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS( klass ); + VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( klass ); + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( klass ); + + VIPS_DEBUG_MSG( "vips_composite_class_init\n" ); + + gobject_class->set_property = vips_object_set_property; + gobject_class->get_property = vips_object_get_property; + + vobject_class->nickname = "composite"; + vobject_class->description = + _( "blend an array of images with an array of blend modes" ); + vobject_class->build = vips_composite_build; + + operation_class->flags = VIPS_OPERATION_SEQUENTIAL; + + VIPS_ARG_BOXED( klass, "in", 0, + _( "Inputs" ), + _( "Array of input images" ), + VIPS_ARGUMENT_REQUIRED_INPUT, + G_STRUCT_OFFSET( VipsComposite, in ), + VIPS_TYPE_ARRAY_IMAGE ); + + VIPS_ARG_BOXED( klass, "mode", 3, + _( "Blend modes" ), + _( "Array of VipsBlendMode to join with" ), + VIPS_ARGUMENT_REQUIRED_INPUT, + G_STRUCT_OFFSET( VipsComposite, mode ), + VIPS_TYPE_ARRAY_INT ); + + VIPS_ARG_ENUM( klass, "compositing_space", 10, + _( "Compositing space" ), + _( "Composite images in this colour space" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsComposite, compositing_space ), + VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_sRGB ); + + VIPS_ARG_BOOL( klass, "premultiplied", 11, + _( "Premultiplied" ), + _( "Images have premultiplied alpha" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsComposite, premultiplied ), + FALSE ); + +} + +static void +vips_composite_init( VipsComposite *composite ) +{ + composite->compositing_space = VIPS_INTERPRETATION_sRGB; +} + +static int +vips_compositev( VipsImage **in, VipsImage **out, int n, int *mode, va_list ap ) +{ + VipsArrayImage *image_array; + VipsArrayInt *mode_array; + int result; + + image_array = vips_array_image_new( in, n ); + mode_array = vips_array_int_new( mode, n - 1 ); + result = vips_call_split( "composite", ap, + image_array, out, mode_array ); + vips_area_unref( VIPS_AREA( image_array ) ); + vips_area_unref( VIPS_AREA( mode_array ) ); + + return( result ); +} + +/** + * vips_composite: (method) + * @in: (array length=n) (transfer none): array of input images + * @out: (out): output image + * @n: number of input images + * @mode: array of (@n - 1) #VipsBlendMode + * @...: %NULL-terminated list of optional named arguments + * + * Optional arguments: + * + * * @compositing_space: #VipsInterpretation to composite in + * * @premultiplied: %gboolean, images are already premultiplied + * + * Composite an array of images together. + * + * Images are placed in a stack, with @in[0] at the bottom and @in[@n - 1] at + * the top. Pixels are blended together working from the bottom upwards, with + * the blend mode at each step being set by the corresponding #VipsBlendMode + * in @mode. + * + * Images are transformed to a compositing space before processing. This is + * #VIPS_INTERPRETATION_sRGB, #VIPS_INTERPRETATION_B_W, + * #VIPS_INTERPRETATION_RGB16, or #VIPS_INTERPRETATION_GREY16 + * by default, depending on + * how many bands and bits the input images have. You can select any other + * space, such as #VIPS_INTERPRETATION_LAB or #VIPS_INTERPRETATION_scRGB. + * + * The output image is in the compositing space. It will always be + * #VIPS_FORMAT_FLOAT unless one of the inputs is #VIPS_FORMAT_DOUBLE, in + * which case the output will be double as well. + * + * Complex images are not supported. + * + * The output image will always have an alpha band. A solid alpha is + * added to any input missing an alpha. + * + * The images do not need to match in size or format. They will be expanded to + * the smallest common size and format in the usual way. + * + * Image are normally treated as unpremultiplied, so this operation can be used + * directly on PNG images. If your images have been through vips_premultiply(), + * set @premultiplied. + * + * See also: vips_insert(). + * + * Returns: 0 on success, -1 on error + */ +int +vips_composite( VipsImage **in, VipsImage **out, int n, int *mode, ... ) +{ + va_list ap; + int result; + + va_start( ap, mode ); + result = vips_compositev( in, out, n, mode, ap ); + va_end( ap ); + + return( result ); +} + +/** + * vips_composite2: (method) + * @base: first input image + * @overlay: second input image + * @out: (out): output image + * @mode: composite with this blend mode + * @...: %NULL-terminated list of optional named arguments + * + * Composite @overlay on top of @base with @mode. See vips_composite(). + * + * Returns: 0 on success, -1 on error + */ +int +vips_composite2( VipsImage *base, VipsImage *overlay, VipsImage **out, + VipsBlendMode mode, ... ) +{ + va_list ap; + int result; + VipsImage *imagev[2]; + int modev[1]; + + imagev[0] = base; + imagev[1] = overlay; + modev[0] = mode; + + va_start( ap, mode ); + result = vips_compositev( imagev, out, 2, modev, ap ); + va_end( ap ); + + return( result ); +} diff --git a/libvips/conversion/conversion.c b/libvips/conversion/conversion.c index 43a7abf4..893b4088 100644 --- a/libvips/conversion/conversion.c +++ b/libvips/conversion/conversion.c @@ -290,6 +290,7 @@ vips_conversion_operation_init( void ) extern GType vips_xyz_get_type( void ); extern GType vips_falsecolour_get_type( void ); extern GType vips_gamma_get_type( void ); + extern GType vips_composite_get_type( void ); vips_copy_get_type(); vips_tile_cache_get_type(); @@ -338,4 +339,5 @@ vips_conversion_operation_init( void ) vips_xyz_get_type(); vips_falsecolour_get_type(); vips_gamma_get_type(); + vips_composite_get_type(); } diff --git a/libvips/conversion/copy.c b/libvips/conversion/copy.c index 5e94a4bf..be621b40 100644 --- a/libvips/conversion/copy.c +++ b/libvips/conversion/copy.c @@ -359,9 +359,9 @@ vips_copy_init( VipsCopy *copy ) } /** - * vips_copy: + * vips_copy: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -403,9 +403,9 @@ vips_copy( VipsImage *in, VipsImage **out, ... ) } /** - * vips_copy_file: + * vips_copy_file: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * A simple convenience function to copy an image to a file, then copy diff --git a/libvips/conversion/embed.c b/libvips/conversion/embed.c index c9daf807..9f096e99 100644 --- a/libvips/conversion/embed.c +++ b/libvips/conversion/embed.c @@ -676,9 +676,9 @@ vips_embed_init( VipsEmbed *embed ) } /** - * vips_embed: + * vips_embed: (method) * @in: input image - * @out: output image + * @out: (out): output image * @x: place @in at this x position in @out * @y: place @in at this y position in @out * @width: @out should be this many pixels across diff --git a/libvips/conversion/extract.c b/libvips/conversion/extract.c index cee157bf..7448fdd4 100644 --- a/libvips/conversion/extract.c +++ b/libvips/conversion/extract.c @@ -232,9 +232,9 @@ vips_extract_area_init( VipsExtractArea *extract ) } /** - * vips_extract_area: + * vips_extract_area: (method) * @in: input image - * @out: output image + * @out: (out): output image * @left: left edge of area to extract * @top: top edge of area to extract * @width: width of area to extract @@ -291,9 +291,9 @@ vips_crop_get_type( void ) } /** - * vips_crop: + * vips_crop: (method) * @in: input image - * @out: output image + * @out: (out): output image * @left: left edge of area to extract * @top: top edge of area to extract * @width: width of area to extract @@ -442,9 +442,9 @@ vips_extract_band_init( VipsExtractBand *extract ) } /** - * vips_extract_band: + * vips_extract_band: (method) * @in: input image - * @out: output image + * @out: (out): output image * @band: band to extract * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/conversion/falsecolour.c b/libvips/conversion/falsecolour.c index 862799ba..117dad9e 100644 --- a/libvips/conversion/falsecolour.c +++ b/libvips/conversion/falsecolour.c @@ -391,9 +391,9 @@ vips_falsecolour_init( VipsFalsecolour *falsecolour ) } /** - * vips_falsecolour: + * vips_falsecolour: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Force @in to 1 band, 8-bit, then transform to diff --git a/libvips/conversion/flatten.c b/libvips/conversion/flatten.c index cfe5fe28..a1825e26 100644 --- a/libvips/conversion/flatten.c +++ b/libvips/conversion/flatten.c @@ -112,8 +112,7 @@ G_DEFINE_TYPE( VipsFlatten, vips_flatten, VIPS_TYPE_CONVERSION ); int b; \ \ for( b = 0; b < bands - 1; b++ ) \ - q[b] = (p[b] * alpha) / max_alpha + \ - (bg[b] * nalpha) / max_alpha; \ + q[b] = (p[b] * alpha + bg[b] * nalpha) / max_alpha; \ \ p += bands; \ q += bands - 1; \ @@ -150,8 +149,8 @@ G_DEFINE_TYPE( VipsFlatten, vips_flatten, VIPS_TYPE_CONVERSION ); int b; \ \ for( b = 0; b < bands - 1; b++ ) \ - q[b] = ((double) p[b] * alpha) / max_alpha + \ - ((double) bg[b] * nalpha) / max_alpha; \ + q[b] = ((double) p[b] * alpha + \ + (double) bg[b] * nalpha) / max_alpha; \ \ p += bands; \ q += bands - 1; \ @@ -412,9 +411,9 @@ vips_flatten_init( VipsFlatten *flatten ) } /** - * vips_flatten: + * vips_flatten: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/flip.c b/libvips/conversion/flip.c index ed70a3c6..550442df 100644 --- a/libvips/conversion/flip.c +++ b/libvips/conversion/flip.c @@ -256,9 +256,9 @@ vips_flip_init( VipsFlip *flip ) } /** - * vips_flip: + * vips_flip: (method) * @in: input image - * @out: output image + * @out: (out): output image * @direction: flip horizontally or vertically * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/conversion/gamma.c b/libvips/conversion/gamma.c index 24c07d45..6465b9ae 100644 --- a/libvips/conversion/gamma.c +++ b/libvips/conversion/gamma.c @@ -161,9 +161,9 @@ vips_gamma_init( VipsGamma *gamma ) } /** - * vips_gamma: + * vips_gamma: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/grid.c b/libvips/conversion/grid.c index fd0a2c95..95baf47e 100644 --- a/libvips/conversion/grid.c +++ b/libvips/conversion/grid.c @@ -233,9 +233,9 @@ vips_grid_init( VipsGrid *grid ) } /** - * vips_grid: + * vips_grid: (method) * @in: input image - * @out: output image + * @out: (out): output image * @tile_height: chop into tiles this high * @across: tiles across * @down: tiles down diff --git a/libvips/conversion/ifthenelse.c b/libvips/conversion/ifthenelse.c index 38a76bfd..b607da35 100644 --- a/libvips/conversion/ifthenelse.c +++ b/libvips/conversion/ifthenelse.c @@ -515,7 +515,7 @@ vips_ifthenelse_init( VipsIfthenelse *ifthenelse ) * @cond: condition #VipsImage * @in1: then #VipsImage * @in2: else #VipsImage - * @out: output #VipsImage + * @out: (out): output #VipsImage * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/insert.c b/libvips/conversion/insert.c index 5f07aff0..01636c51 100644 --- a/libvips/conversion/insert.c +++ b/libvips/conversion/insert.c @@ -556,10 +556,10 @@ vips_insert_init( VipsInsert *insert ) } /** - * vips_insert: + * vips_insert: (method) * @main: big image * @sub: small image - * @out: output image + * @out: (out): output image * @x: left position of @sub * @y: top position of @sub * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/conversion/join.c b/libvips/conversion/join.c index fc541b46..2219ce5a 100644 --- a/libvips/conversion/join.c +++ b/libvips/conversion/join.c @@ -295,7 +295,7 @@ vips_join_init( VipsJoin *join ) * vips_join: * @in1: first input image * @in2: second input image - * @out: output image + * @out: (out): output image * @direction: join horizontally or vertically * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/conversion/msb.c b/libvips/conversion/msb.c index 01e89c9b..a4ced8c7 100644 --- a/libvips/conversion/msb.c +++ b/libvips/conversion/msb.c @@ -262,9 +262,9 @@ vips_msb_init( VipsMsb *msb ) } /** - * vips_msb: + * vips_msb: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/premultiply.c b/libvips/conversion/premultiply.c index 24c61522..897c97c3 100644 --- a/libvips/conversion/premultiply.c +++ b/libvips/conversion/premultiply.c @@ -276,9 +276,9 @@ vips_premultiply_init( VipsPremultiply *premultiply ) } /** - * vips_premultiply: + * vips_premultiply: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/recomb.c b/libvips/conversion/recomb.c index b6ce8eaf..b24d74d3 100644 --- a/libvips/conversion/recomb.c +++ b/libvips/conversion/recomb.c @@ -222,9 +222,9 @@ vips_recomb_init( VipsRecomb *recomb ) } /** - * vips_recomb: + * vips_recomb: (method) * @in: input image - * @out: output image + * @out: (out): output image * @m: recombination matrix * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/conversion/replicate.c b/libvips/conversion/replicate.c index a600a0bd..60592fc9 100644 --- a/libvips/conversion/replicate.c +++ b/libvips/conversion/replicate.c @@ -220,9 +220,9 @@ vips_replicate_init( VipsReplicate *replicate ) } /** - * vips_replicate: + * vips_replicate: (method) * @in: input image - * @out: output image + * @out: (out): output image * @across: repeat input this many times across * @down: repeat input this many times down * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/conversion/rot.c b/libvips/conversion/rot.c index d07f9e15..2292240c 100644 --- a/libvips/conversion/rot.c +++ b/libvips/conversion/rot.c @@ -383,9 +383,9 @@ vips_rotv( VipsImage *in, VipsImage **out, VipsAngle angle, va_list ap ) } /** - * vips_rot: + * vips_rot: (method) * @in: input image - * @out: output image + * @out: (out): output image * @angle: rotation angle * @...: %NULL-terminated list of optional named arguments * @@ -437,9 +437,9 @@ vips_rot90( VipsImage *in, VipsImage **out, ... ) } /** - * vips_rot180: + * vips_rot180: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Rotate @in by 180 degress. A convenience function over vips_rot(). @@ -462,9 +462,9 @@ vips_rot180( VipsImage *in, VipsImage **out, ... ) } /** - * vips_rot270: + * vips_rot270: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Rotate @in by 270 degress clockwise. A convenience function over vips_rot(). diff --git a/libvips/conversion/rot45.c b/libvips/conversion/rot45.c index 28bc35a9..c406c429 100644 --- a/libvips/conversion/rot45.c +++ b/libvips/conversion/rot45.c @@ -284,9 +284,9 @@ vips_rot45_init( VipsRot45 *rot45 ) } /** - * vips_rot45: + * vips_rot45: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/scale.c b/libvips/conversion/scale.c index 492e80a7..5499eb78 100644 --- a/libvips/conversion/scale.c +++ b/libvips/conversion/scale.c @@ -176,9 +176,9 @@ vips_scale_init( VipsScale *scale ) } /** - * vips_scale: + * vips_scale: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/sequential.c b/libvips/conversion/sequential.c index 508269c5..a35d388c 100644 --- a/libvips/conversion/sequential.c +++ b/libvips/conversion/sequential.c @@ -265,9 +265,9 @@ vips_sequential_init( VipsSequential *sequential ) } /** - * vips_sequential: + * vips_sequential: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/smartcrop.c b/libvips/conversion/smartcrop.c index f7208519..dd8aa56b 100644 --- a/libvips/conversion/smartcrop.c +++ b/libvips/conversion/smartcrop.c @@ -417,9 +417,9 @@ vips_smartcrop_init( VipsSmartcrop *smartcrop ) } /** - * vips_smartcrop: + * vips_smartcrop: (method) * @in: input image - * @out: output image + * @out: (out): output image * @width: width of area to extract * @height: height of area to extract * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/conversion/subsample.c b/libvips/conversion/subsample.c index 9c3d78fa..8a7187eb 100644 --- a/libvips/conversion/subsample.c +++ b/libvips/conversion/subsample.c @@ -300,9 +300,9 @@ vips_subsample_init( VipsSubsample *subsample ) } /** - * vips_subsample: + * vips_subsample: (method) * @in: input image - * @out: output image + * @out: (out): output image * @xfac: horizontal shrink factor * @yfac: vertical shrink factor * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/conversion/tilecache.c b/libvips/conversion/tilecache.c index 9d78a726..c1e3722e 100644 --- a/libvips/conversion/tilecache.c +++ b/libvips/conversion/tilecache.c @@ -819,9 +819,9 @@ vips_tile_cache_init( VipsTileCache *cache ) } /** - * vips_tilecache: + * vips_tilecache: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -988,9 +988,9 @@ vips_line_cache_init( VipsLineCache *cache ) } /** - * vips_linecache: + * vips_linecache: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/unpremultiply.c b/libvips/conversion/unpremultiply.c index d10c7a40..db118c1a 100644 --- a/libvips/conversion/unpremultiply.c +++ b/libvips/conversion/unpremultiply.c @@ -286,9 +286,9 @@ vips_unpremultiply_init( VipsUnpremultiply *unpremultiply ) } /** - * vips_unpremultiply: + * vips_unpremultiply: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/wrap.c b/libvips/conversion/wrap.c index e97ef491..d7e58596 100644 --- a/libvips/conversion/wrap.c +++ b/libvips/conversion/wrap.c @@ -143,9 +143,9 @@ vips_wrap_init( VipsWrap *wrap ) } /** - * vips_wrap: + * vips_wrap: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/conversion/zoom.c b/libvips/conversion/zoom.c index 4429b111..e5576f04 100644 --- a/libvips/conversion/zoom.c +++ b/libvips/conversion/zoom.c @@ -402,9 +402,9 @@ vips_zoom_init( VipsZoom *zoom ) } /** - * vips_zoom: + * vips_zoom: (method) * @in: input image - * @out: output image + * @out: (out): output image * @xfac: horizontal scale factor * @yfac: vertical scale factor * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/convolution/compass.c b/libvips/convolution/compass.c index 2b9d3861..7e25a3a2 100644 --- a/libvips/convolution/compass.c +++ b/libvips/convolution/compass.c @@ -205,9 +205,9 @@ vips_compass_init( VipsCompass *compass ) } /** - * vips_compass: + * vips_compass: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolve with this mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/conv.c b/libvips/convolution/conv.c index 1be0d46f..067ae9f3 100644 --- a/libvips/convolution/conv.c +++ b/libvips/convolution/conv.c @@ -167,9 +167,9 @@ vips_conv_init( VipsConv *conv ) } /** - * vips_conv: + * vips_conv: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolve with this mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/conva.c b/libvips/convolution/conva.c index 49aed0aa..e6fd8981 100644 --- a/libvips/convolution/conva.c +++ b/libvips/convolution/conva.c @@ -1312,9 +1312,9 @@ vips_conva_init( VipsConva *conva ) } /** - * vips_conva: + * vips_conva: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolution mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/convasep.c b/libvips/convolution/convasep.c index 5534bf52..08e7b468 100644 --- a/libvips/convolution/convasep.c +++ b/libvips/convolution/convasep.c @@ -914,9 +914,9 @@ vips_convasep_init( VipsConvasep *convasep ) } /** - * vips_convasep: + * vips_convasep: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolve with this mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/convf.c b/libvips/convolution/convf.c index b420fe21..d6217906 100644 --- a/libvips/convolution/convf.c +++ b/libvips/convolution/convf.c @@ -371,9 +371,9 @@ vips_convf_init( VipsConvf *convf ) } /** - * vips_convf: + * vips_convf: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolve with this mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/convi.c b/libvips/convolution/convi.c index 44659f46..893c894b 100644 --- a/libvips/convolution/convi.c +++ b/libvips/convolution/convi.c @@ -938,7 +938,7 @@ vips_convi_build( VipsObject *object ) !intize_to_fixed_point( M, convi->fixed ) && !vips_convi_compile( convi, in ) ) { generate = vips_convi_gen_vector; - g_info( "using vector path" ); + g_info( "convi: using vector path" ); } else vips_convi_compile_free( convi ); @@ -947,7 +947,7 @@ vips_convi_build( VipsObject *object ) /* Make the data for the C path. */ if( generate == vips_convi_gen ) { - g_info( "using C path" ); + g_info( "convi: using C path" ); /* Make an int version of our mask. */ @@ -1019,9 +1019,9 @@ vips_convi_init( VipsConvi *convi ) } /** - * vips_convi: + * vips_convi: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolve with this mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/convsep.c b/libvips/convolution/convsep.c index 33f95008..cb1cc178 100644 --- a/libvips/convolution/convsep.c +++ b/libvips/convolution/convsep.c @@ -158,9 +158,9 @@ vips_convsep_init( VipsConvsep *convsep ) } /** - * vips_convsep: + * vips_convsep: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: convolution mask * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/fastcor.c b/libvips/convolution/fastcor.c index c9b8dc52..73a557c7 100644 --- a/libvips/convolution/fastcor.c +++ b/libvips/convolution/fastcor.c @@ -224,10 +224,10 @@ vips_fastcor_init( VipsFastcor *fastcor ) } /** - * vips_fastcor: + * vips_fastcor: (method) * @in: input image * @ref: reference image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Calculate a fast correlation surface. diff --git a/libvips/convolution/gaussblur.c b/libvips/convolution/gaussblur.c index c64833a4..215eefd9 100644 --- a/libvips/convolution/gaussblur.c +++ b/libvips/convolution/gaussblur.c @@ -159,9 +159,9 @@ vips_gaussblur_init( VipsGaussblur *gaussblur ) } /** - * vips_gaussblur: + * vips_gaussblur: (method) * @in: input image - * @out: output image + * @out: (out): output image * @sigma: how large a mask to use * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/convolution/sharpen.c b/libvips/convolution/sharpen.c index 3595852e..f7f91e97 100644 --- a/libvips/convolution/sharpen.c +++ b/libvips/convolution/sharpen.c @@ -388,9 +388,9 @@ vips_sharpen_init( VipsSharpen *sharpen ) } /** - * vips_sharpen: + * vips_sharpen: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/convolution/spcor.c b/libvips/convolution/spcor.c index a5134b7f..2d707a99 100644 --- a/libvips/convolution/spcor.c +++ b/libvips/convolution/spcor.c @@ -325,10 +325,10 @@ vips_spcor_init( VipsSpcor *spcor ) } /** - * vips_spcor: + * vips_spcor: (method) * @in: input image * @ref: reference image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Calculate a correlation surface. diff --git a/libvips/create/black.c b/libvips/create/black.c index 65b567ac..c613a154 100644 --- a/libvips/create/black.c +++ b/libvips/create/black.c @@ -155,7 +155,7 @@ vips_black_init( VipsBlack *black ) /** * vips_black: - * @out: output image + * @out: (out): output image * @width: output width * @height: output height * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/buildlut.c b/libvips/create/buildlut.c index e6e41b17..5af1a93d 100644 --- a/libvips/create/buildlut.c +++ b/libvips/create/buildlut.c @@ -271,9 +271,9 @@ vips_buildlut_init( VipsBuildlut *lut ) } /** - * vips_buildlut: + * vips_buildlut: (method) * @in: input matrix - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * This operation builds a lookup table from a set of points. Intermediate diff --git a/libvips/create/eye.c b/libvips/create/eye.c index edac0d3a..c348f180 100644 --- a/libvips/create/eye.c +++ b/libvips/create/eye.c @@ -116,7 +116,7 @@ vips_eye_init( VipsEye *eye ) /** * vips_eye: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/fractsurf.c b/libvips/create/fractsurf.c index e6c07ef8..aa87709f 100644 --- a/libvips/create/fractsurf.c +++ b/libvips/create/fractsurf.c @@ -131,7 +131,7 @@ vips_fractsurf_init( VipsFractsurf *fractsurf ) /** * vips_fractsurf: - * @out: output image + * @out: (out): output image * @width: output width * @height: output height * @fractal_dimension: fractal dimension diff --git a/libvips/create/gaussmat.c b/libvips/create/gaussmat.c index ba41013b..73a26410 100644 --- a/libvips/create/gaussmat.c +++ b/libvips/create/gaussmat.c @@ -227,7 +227,7 @@ vips_gaussmat_init( VipsGaussmat *gaussmat ) /** * vips_gaussmat: - * @out: output image + * @out: (out): output image * @sigma: standard deviation of mask * @min_ampl: minimum amplitude * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/gaussnoise.c b/libvips/create/gaussnoise.c index d8a2e7f4..1566e39a 100644 --- a/libvips/create/gaussnoise.c +++ b/libvips/create/gaussnoise.c @@ -207,7 +207,7 @@ vips_gaussnoise_init( VipsGaussnoise *gaussnoise ) /** * vips_gaussnoise: - * @out: output image + * @out: (out): output image * @width: output width * @height: output height * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/grey.c b/libvips/create/grey.c index 1ec5c58c..b729a253 100644 --- a/libvips/create/grey.c +++ b/libvips/create/grey.c @@ -100,7 +100,7 @@ vips_grey_init( VipsGrey *grey ) /** * vips_grey: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/identity.c b/libvips/create/identity.c index 90241667..6a2bdd34 100644 --- a/libvips/create/identity.c +++ b/libvips/create/identity.c @@ -173,7 +173,7 @@ vips_identity_init( VipsIdentity *identity ) /** * vips_identity: - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/create/invertlut.c b/libvips/create/invertlut.c index d2e99795..c9fa2809 100644 --- a/libvips/create/invertlut.c +++ b/libvips/create/invertlut.c @@ -1,7 +1,7 @@ /* invert a lut * * Written on: 5/6/01 - * Modified on : + * Modified on : * * 7/7/03 JC * - generate image rather than doublemask (arrg) @@ -17,7 +17,7 @@ /* This file is part of VIPS. - + VIPS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -65,7 +65,7 @@ typedef struct _VipsInvertlut { /* Input image. */ - VipsImage *in; + VipsImage *in; /* .. and cast to a matrix. */ @@ -119,31 +119,31 @@ vips_invertlut_build_init( VipsInvertlut *lut ) int x, y; if( !lut->mat || - lut->mat->Xsize < 2 || + lut->mat->Xsize < 2 || lut->mat->Ysize < 1 ) { vips_error( class->nickname, "%s", _( "bad input matrix" ) ); return( -1 ); } - if( lut->size < 1 || + if( lut->size < 1 || lut->size > 65536 ) { vips_error( class->nickname, "%s", _( "bad size" ) ); return( -1 ); } - if( !(lut->buf = + if( !(lut->buf = VIPS_ARRAY( NULL, lut->size * (lut->mat->Xsize - 1), double )) ) return( -1 ); if( !(lut->data = VIPS_ARRAY( NULL, lut->mat->Ysize, double * )) ) return( -1 ); - for( y = 0; y < lut->mat->Ysize; y++ ) + for( y = 0; y < lut->mat->Ysize; y++ ) lut->data[y] = VIPS_MATRIX( lut->mat, 0, y ); /* Sanity check for data range. */ - for( y = 0; y < lut->mat->Ysize; y++ ) - for( x = 0; x < lut->mat->Xsize; x++ ) - if( lut->data[y][x] > 1.0 || + for( y = 0; y < lut->mat->Ysize; y++ ) + for( x = 0; x < lut->mat->Xsize; x++ ) + if( lut->data[y][x] > 1.0 || lut->data[y][x] < 0.0 ) { vips_error( class->nickname, _( "element (%d, %d) is %g, " @@ -204,10 +204,10 @@ vips_invertlut_build_create( VipsInvertlut *lut ) /* Inside the loop to avoid /0 errors for last == * (size - 1). */ - double fac = (1 - lut->data[height - 1][0]) / + double fac = (1 - lut->data[height - 1][0]) / ((lut->size - 1) - last); - lut->buf[b + k * bands] = + lut->buf[b + k * bands] = lut->data[height - 1][0] + (k - last) * fac; } @@ -255,17 +255,17 @@ vips_invertlut_build( VipsObject *object ) return( -1 ); if( vips_check_matrix( class->nickname, lut->in, &lut->mat ) ) - return( -1 ); + return( -1 ); if( vips_invertlut_build_init( lut ) || vips_invertlut_build_create( lut ) ) - return( -1 ); + return( -1 ); vips_image_init_fields( create->out, - lut->size, 1, lut->mat->Xsize - 1, - VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, + lut->size, 1, lut->mat->Xsize - 1, + VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, VIPS_INTERPRETATION_HISTOGRAM, 1.0, 1.0 ); - if( vips_image_write_line( create->out, 0, (VipsPel *) lut->buf ) ) + if( vips_image_write_line( create->out, 0, (VipsPel *) lut->buf ) ) return( -1 ); return( 0 ); @@ -285,14 +285,14 @@ vips_invertlut_class_init( VipsInvertlutClass *class ) vobject_class->description = _( "build an inverted look-up table" ); vobject_class->build = vips_invertlut_build; - VIPS_ARG_IMAGE( class, "in", 0, - _( "Input" ), + VIPS_ARG_IMAGE( class, "in", 0, + _( "Input" ), _( "Matrix of XY coordinates" ), VIPS_ARGUMENT_REQUIRED_INPUT, - G_STRUCT_OFFSET( VipsInvertlut, in ) ); + G_STRUCT_OFFSET( VipsInvertlut, in ) ); - VIPS_ARG_INT( class, "size", 5, - _( "Size" ), + VIPS_ARG_INT( class, "size", 5, + _( "Size" ), _( "LUT size to generate" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsInvertlut, size ), @@ -303,13 +303,13 @@ vips_invertlut_class_init( VipsInvertlutClass *class ) static void vips_invertlut_init( VipsInvertlut *lut ) { - lut->size = 256; + lut->size = 256; } /** - * vips_invertlut: + * vips_invertlut: (method) * @in: input mask - * @out: output LUT + * @out: (out): output LUT * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -320,9 +320,9 @@ vips_invertlut_init( VipsInvertlut *lut ) * will map reals to targets. Handy for linearising images from * measurements of a colour chart. All values in [0,1]. Piecewise linear * interpolation, extrapolate head and tail to 0 and 1. - * + * * Eg. input like this: - * + * * * * @@ -352,12 +352,12 @@ vips_invertlut_init( VipsInvertlut *lut ) * * Means a patch with 10% reflectance produces an image with 20% in * channel 1, 30% in channel 2, and 10% in channel 3, and so on. - * + * * Inputs don't need to be sorted (we do that). Generate any precision * LUT, default to 256 elements. * - * It won't work too well for non-monotonic camera responses - * (we should fix this). Interpolation is simple piecewise linear; we ought to + * It won't work too well for non-monotonic camera responses + * (we should fix this). Interpolation is simple piecewise linear; we ought to * do something better really. * * See also: vips_buildlut(). diff --git a/libvips/create/logmat.c b/libvips/create/logmat.c index db4384eb..5f15b3ea 100644 --- a/libvips/create/logmat.c +++ b/libvips/create/logmat.c @@ -244,7 +244,7 @@ vips_logmat_init( VipsLogmat *logmat ) /** * vips_logmat: - * @out: output image + * @out: (out): output image * @sigma: standard deviation of mask * @min_ampl: minimum amplitude * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/mask_butterworth.c b/libvips/create/mask_butterworth.c index 35a75316..4e9d9cac 100644 --- a/libvips/create/mask_butterworth.c +++ b/libvips/create/mask_butterworth.c @@ -117,7 +117,7 @@ vips_mask_butterworth_init( VipsMaskButterworth *butterworth ) /** * vips_mask_butterworth: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @order: filter order diff --git a/libvips/create/mask_butterworth_band.c b/libvips/create/mask_butterworth_band.c index dd3e8865..a25cbb4b 100644 --- a/libvips/create/mask_butterworth_band.c +++ b/libvips/create/mask_butterworth_band.c @@ -159,7 +159,7 @@ vips_mask_butterworth_band_init( /** * vips_mask_butterworth_band: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @order: filter order diff --git a/libvips/create/mask_butterworth_ring.c b/libvips/create/mask_butterworth_ring.c index b5b252de..f73bcb28 100644 --- a/libvips/create/mask_butterworth_ring.c +++ b/libvips/create/mask_butterworth_ring.c @@ -120,7 +120,7 @@ vips_mask_butterworth_ring_init( /** * vips_mask_butterworth_ring: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @order: filter order diff --git a/libvips/create/mask_fractal.c b/libvips/create/mask_fractal.c index 9031a415..e9e4e93b 100644 --- a/libvips/create/mask_fractal.c +++ b/libvips/create/mask_fractal.c @@ -106,7 +106,7 @@ vips_mask_fractal_init( VipsMaskFractal *fractal ) /** * vips_mask_fractal: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @fractal_dimension: fractal dimension diff --git a/libvips/create/mask_gaussian.c b/libvips/create/mask_gaussian.c index 6dcf7372..21b6f2d0 100644 --- a/libvips/create/mask_gaussian.c +++ b/libvips/create/mask_gaussian.c @@ -107,7 +107,7 @@ vips_mask_gaussian_init( VipsMaskGaussian *gaussian ) /** * vips_mask_gaussian: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @frequency_cutoff: frequency threshold diff --git a/libvips/create/mask_gaussian_band.c b/libvips/create/mask_gaussian_band.c index 7218affd..f19b0b19 100644 --- a/libvips/create/mask_gaussian_band.c +++ b/libvips/create/mask_gaussian_band.c @@ -144,7 +144,7 @@ vips_mask_gaussian_band_init( VipsMaskGaussianBand *gaussian_band ) /** * vips_mask_gaussian_band: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @frequency_cutoff_x: band position diff --git a/libvips/create/mask_gaussian_ring.c b/libvips/create/mask_gaussian_ring.c index 8afcf5d2..a37c0c85 100644 --- a/libvips/create/mask_gaussian_ring.c +++ b/libvips/create/mask_gaussian_ring.c @@ -114,7 +114,7 @@ vips_mask_gaussian_ring_init( VipsMaskGaussianRing *gaussian_ring ) /** * vips_mask_gaussian_ring: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @frequency_cutoff: frequency threshold diff --git a/libvips/create/mask_ideal.c b/libvips/create/mask_ideal.c index cce19192..cba3caaa 100644 --- a/libvips/create/mask_ideal.c +++ b/libvips/create/mask_ideal.c @@ -97,7 +97,7 @@ vips_mask_ideal_init( VipsMaskIdeal *ideal ) /** * vips_mask_ideal: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @frequency_cutoff: threshold at which filter ends diff --git a/libvips/create/mask_ideal_band.c b/libvips/create/mask_ideal_band.c index 6675b44e..083fba8a 100644 --- a/libvips/create/mask_ideal_band.c +++ b/libvips/create/mask_ideal_band.c @@ -127,7 +127,7 @@ vips_mask_ideal_band_init( VipsMaskIdealBand *ideal_band ) /** * vips_mask_ideal_band: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @frequency_cutoff_x: position of band diff --git a/libvips/create/mask_ideal_ring.c b/libvips/create/mask_ideal_ring.c index 20e3831b..9da608bf 100644 --- a/libvips/create/mask_ideal_ring.c +++ b/libvips/create/mask_ideal_ring.c @@ -111,7 +111,7 @@ vips_mask_ideal_ring_init( VipsMaskIdealRing *ideal_ring ) /** * vips_mask_ideal_ring: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @frequency_cutoff: threshold at which filter ends diff --git a/libvips/create/perlin.c b/libvips/create/perlin.c index c727347a..24d0cf1c 100644 --- a/libvips/create/perlin.c +++ b/libvips/create/perlin.c @@ -331,7 +331,7 @@ vips_perlin_init( VipsPerlin *perlin ) /** * vips_perlin: - * @out: output image + * @out: (out): output image * @width: horizontal size * @height: vertical size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/sines.c b/libvips/create/sines.c index 8a60cfb8..779e0b34 100644 --- a/libvips/create/sines.c +++ b/libvips/create/sines.c @@ -147,7 +147,7 @@ vips_sines_init( VipsSines *sines ) /** * vips_sines: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/text.c b/libvips/create/text.c index 94bbce9e..41893003 100644 --- a/libvips/create/text.c +++ b/libvips/create/text.c @@ -489,7 +489,7 @@ vips_text_init( VipsText *text ) /** * vips_text: - * @out: output image + * @out: (out): output image * @text: utf-8 text string to render * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/create/tonelut.c b/libvips/create/tonelut.c index b0e724c2..9e1ea79c 100644 --- a/libvips/create/tonelut.c +++ b/libvips/create/tonelut.c @@ -310,7 +310,7 @@ vips_tonelut_init( VipsTonelut *lut ) /** * vips_tonelut: - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/create/worley.c b/libvips/create/worley.c index 0f057fba..520fdd47 100644 --- a/libvips/create/worley.c +++ b/libvips/create/worley.c @@ -337,7 +337,7 @@ vips_worley_init( VipsWorley *worley ) /** * vips_worley: - * @out: output image + * @out: (out): output image * @width: horizontal size * @height: vertical size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/xyz.c b/libvips/create/xyz.c index e00b5b22..aaf35331 100644 --- a/libvips/create/xyz.c +++ b/libvips/create/xyz.c @@ -239,7 +239,7 @@ vips_xyz_init( VipsXyz *xyz ) /** * vips_xyz: - * @out: output image + * @out: (out): output image * @width: horizontal size * @height: vertical size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/create/zone.c b/libvips/create/zone.c index 1f44afdb..c2c96a06 100644 --- a/libvips/create/zone.c +++ b/libvips/create/zone.c @@ -99,7 +99,7 @@ vips_zone_init( VipsZone *zone ) /** * vips_zone: - * @out: output image + * @out: (out): output image * @width: image size * @height: image size * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/draw/draw_circle.c b/libvips/draw/draw_circle.c index 29a45d94..e0acb69e 100644 --- a/libvips/draw/draw_circle.c +++ b/libvips/draw/draw_circle.c @@ -283,7 +283,7 @@ vips_draw_circlev( VipsImage *image, } /** - * vips_draw_circle: + * vips_draw_circle: (method) * @image: image to draw on * @ink: (array length=n): value to draw * @n: length of ink array @@ -320,7 +320,7 @@ vips_draw_circle( VipsImage *image, } /** - * vips_draw_circle1: + * vips_draw_circle1: (method) * @image: image to draw on * @ink: value to draw * @cx: centre of draw_circle diff --git a/libvips/draw/draw_flood.c b/libvips/draw/draw_flood.c index 23f0f2a0..2d2367a1 100644 --- a/libvips/draw/draw_flood.c +++ b/libvips/draw/draw_flood.c @@ -678,7 +678,7 @@ vips_draw_floodv( VipsImage *image, } /** - * vips_draw_flood: + * vips_draw_flood: (method) * @image: image to draw on * @ink: (array length=n): value to draw * @n: length of ink array @@ -730,7 +730,7 @@ vips_draw_flood( VipsImage *image, } /** - * vips_draw_flood1: + * vips_draw_flood1: (method) * @image: image to draw on * @ink: value to draw * @x: centre of circle diff --git a/libvips/draw/draw_image.c b/libvips/draw/draw_image.c index 3f9aa053..da0a2c11 100644 --- a/libvips/draw/draw_image.c +++ b/libvips/draw/draw_image.c @@ -291,7 +291,7 @@ vips_draw_image_init( VipsDrawImage *draw_image ) } /** - * vips_draw_image: + * vips_draw_image: (method) * @image: image to draw on * @sub: image to paint * @x: draw @sub here diff --git a/libvips/draw/draw_line.c b/libvips/draw/draw_line.c index a39969cb..30f5ab43 100644 --- a/libvips/draw/draw_line.c +++ b/libvips/draw/draw_line.c @@ -331,7 +331,7 @@ vips_draw_linev( VipsImage *image, } /** - * vips_draw_line: + * vips_draw_line: (method) * @image: image to draw on * @ink: (array length=n): value to draw * @n: length of ink array @@ -364,7 +364,7 @@ vips_draw_line( VipsImage *image, } /** - * vips_draw_line1: + * vips_draw_line1: (method) * @image: image to draw on * @ink: value to draw * @x1: start of draw_line diff --git a/libvips/draw/draw_mask.c b/libvips/draw/draw_mask.c index 92228631..24ccf632 100644 --- a/libvips/draw/draw_mask.c +++ b/libvips/draw/draw_mask.c @@ -362,7 +362,7 @@ vips_draw_maskv( VipsImage *image, } /** - * vips_draw_mask: + * vips_draw_mask: (method) * @image: image to draw on * @ink: (array length=n): value to draw * @n: size of ink array @@ -397,7 +397,7 @@ vips_draw_mask( VipsImage *image, } /** - * vips_draw_mask1: + * vips_draw_mask1: (method) * @image: image to draw on * @ink: value to draw * @mask: mask of 0/255 values showing where to plot diff --git a/libvips/draw/draw_rect.c b/libvips/draw/draw_rect.c index ac7f33b1..e1599145 100644 --- a/libvips/draw/draw_rect.c +++ b/libvips/draw/draw_rect.c @@ -228,7 +228,7 @@ vips_draw_rectv( VipsImage *image, } /** - * vips_draw_rect: + * vips_draw_rect: (method) * @image: image to draw on * @ink: (array length=n): value to draw * @n: length of ink array @@ -265,7 +265,7 @@ vips_draw_rect( VipsImage *image, } /** - * vips_draw_rect1: + * vips_draw_rect1: (method) * @image: image to draw on * @ink: value to draw * @left: area to paint @@ -303,7 +303,7 @@ vips_draw_rect1( VipsImage *image, } /** - * vips_draw_point: + * vips_draw_point: (method) * @image: image to draw on * @ink: (array length=n): value to draw * @n: length of ink array @@ -331,7 +331,7 @@ vips_draw_point( VipsImage *image, double *ink, int n, int x, int y, ... ) } /** - * vips_draw_point1: + * vips_draw_point1: (method) * @image: image to draw on * @ink: value to draw * @x: point to draw diff --git a/libvips/draw/draw_smudge.c b/libvips/draw/draw_smudge.c index 17f4951e..da4e885f 100644 --- a/libvips/draw/draw_smudge.c +++ b/libvips/draw/draw_smudge.c @@ -229,7 +229,7 @@ vips_draw_smudge_init( VipsDrawSmudge *draw_smudge ) } /** - * vips_draw_smudge: + * vips_draw_smudge: (method) * @image: image to draw on * @left: point to paint * @top: point to paint diff --git a/libvips/foreign/analyzeload.c b/libvips/foreign/analyzeload.c index eeb2fbe7..e0f8cd71 100644 --- a/libvips/foreign/analyzeload.c +++ b/libvips/foreign/analyzeload.c @@ -149,7 +149,7 @@ vips_foreign_load_analyze_init( VipsForeignLoadAnalyze *analyze ) /** * vips_analyzeload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Load an Analyze 6.0 file. If @filename is "fred.img", this will look for diff --git a/libvips/foreign/csvload.c b/libvips/foreign/csvload.c index 4b3620a3..a417ab49 100644 --- a/libvips/foreign/csvload.c +++ b/libvips/foreign/csvload.c @@ -184,7 +184,7 @@ vips_foreign_load_csv_init( VipsForeignLoadCsv *csv ) /** * vips_csvload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/csvsave.c b/libvips/foreign/csvsave.c index 5dfd21dd..633f9ac9 100644 --- a/libvips/foreign/csvsave.c +++ b/libvips/foreign/csvsave.c @@ -121,7 +121,7 @@ vips_foreign_save_csv_init( VipsForeignSaveCsv *csv ) } /** - * vips_csvsave: + * vips_csvsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index 6a129102..9cfde18a 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -2279,7 +2279,7 @@ vips_foreign_save_dz_buffer_init( VipsForeignSaveDzBuffer *buffer ) #endif /*HAVE_GSF*/ /** - * vips_dzsave: + * vips_dzsave: (method) * @in: image to save * @name: name to save to * @...: %NULL-terminated list of optional named arguments @@ -2353,10 +2353,10 @@ vips_dzsave( VipsImage *in, const char *name, ... ) } /** - * vips_dzsave_buffer: + * vips_dzsave_buffer: (method) * @in: image to save - * @buf: return output buffer here - * @len: return output length here + * @buf: (array length=len) (element-type guint8): return output buffer here + * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/fitsload.c b/libvips/foreign/fitsload.c index 07454651..25765827 100644 --- a/libvips/foreign/fitsload.c +++ b/libvips/foreign/fitsload.c @@ -137,7 +137,7 @@ vips_foreign_load_fits_init( VipsForeignLoadFits *fits ) /** * vips_fitsload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Read a FITS image file into a VIPS image. diff --git a/libvips/foreign/fitssave.c b/libvips/foreign/fitssave.c index e9887f4a..b035c20c 100644 --- a/libvips/foreign/fitssave.c +++ b/libvips/foreign/fitssave.c @@ -150,7 +150,7 @@ vips_foreign_save_fits_init( VipsForeignSaveFits *fits ) #endif /*HAVE_CFITSIO*/ /** - * vips_fitssave: + * vips_fitssave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 7d51ded2..0c310f9b 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -584,7 +584,7 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class, * vips_foreign_find_load_buffer: * @data: (array length=size) (element-type guint8) (transfer none): start of * memory buffer - * @size: number of bytes in @data + * @size: (type gsize): number of bytes in @data * * Searches for an operation you could use to load a memory buffer. To see the * range of buffer loaders supported by your vips, try something like: @@ -642,8 +642,8 @@ vips_foreign_is_a( const char *loader, const char *filename ) /** * vips_foreign_is_a_buffer: * @loader: name of loader to use for test - * @data: pointer to the buffer to test - * @size: size of the buffer to test + * @data: (array length=size) (element-type guint8): pointer to the buffer to test + * @size: (type gsize): size of the buffer to test * * Return %TRUE if @data can be loaded by @loader. @loader is something * like "tiffload_buffer" or "VipsForeignLoadTiffBuffer". @@ -1047,12 +1047,12 @@ vips_foreign_load_init( VipsForeignLoad *load ) load->access = VIPS_ACCESS_RANDOM; } -/** +/* * Loaders can call this */ /** - * vips_foreign_load_invalidate: + * vips_foreign_load_invalidate: (method) * @image: image to invalidate * * Loaders can call this on the image they are making if they see a read error diff --git a/libvips/foreign/gifload.c b/libvips/foreign/gifload.c index 6406a8fe..bc335c5d 100644 --- a/libvips/foreign/gifload.c +++ b/libvips/foreign/gifload.c @@ -1004,7 +1004,7 @@ vips_foreign_load_gif_buffer_init( VipsForeignLoadGifBuffer *buffer ) /** * vips_gifload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -1043,9 +1043,9 @@ vips_gifload( const char *filename, VipsImage **out, ... ) /** * vips_gifload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/jpegload.c b/libvips/foreign/jpegload.c index 894540c2..dfe5b868 100644 --- a/libvips/foreign/jpegload.c +++ b/libvips/foreign/jpegload.c @@ -322,7 +322,7 @@ vips_foreign_load_jpeg_buffer_init( VipsForeignLoadJpegBuffer *buffer ) /** * vips_jpegload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -398,9 +398,9 @@ vips_jpegload( const char *filename, VipsImage **out, ... ) /** * vips_jpegload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/jpegsave.c b/libvips/foreign/jpegsave.c index 2c5dc321..17732f07 100644 --- a/libvips/foreign/jpegsave.c +++ b/libvips/foreign/jpegsave.c @@ -412,7 +412,7 @@ vips_foreign_save_jpeg_mime_init( VipsForeignSaveJpegMime *mime ) #endif /*HAVE_JPEG*/ /** - * vips_jpegsave: + * vips_jpegsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -526,10 +526,10 @@ vips_jpegsave( VipsImage *in, const char *filename, ... ) } /** - * vips_jpegsave_buffer: + * vips_jpegsave_buffer: (method) * @in: image to save - * @buf: return output buffer here - * @len: return output length here + * @buf: (array length=len) (element-type guint8): return output buffer here + * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -584,7 +584,7 @@ vips_jpegsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) } /** - * vips_jpegsave_mime: + * vips_jpegsave_mime: (method) * @in: image to save * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/foreign/magickload.c b/libvips/foreign/magickload.c index 96f72e36..9844b2c9 100644 --- a/libvips/foreign/magickload.c +++ b/libvips/foreign/magickload.c @@ -329,7 +329,7 @@ vips_foreign_load_magick_buffer_init( VipsForeignLoadMagickBuffer *buffer ) /** * vips_magickload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -376,9 +376,9 @@ vips_magickload( const char *filename, VipsImage **out, ... ) /** * vips_magickload_buffer: - * @buf: memory area to load + * @buf: (array length=len) (element-type guint8): memory area to load * @len: size of memory area - * @out: image to write + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/matload.c b/libvips/foreign/matload.c index 1d749ed8..bf33ea78 100644 --- a/libvips/foreign/matload.c +++ b/libvips/foreign/matload.c @@ -147,7 +147,7 @@ vips_foreign_load_mat_init( VipsForeignLoadMat *mat ) /** * vips_matload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Read a Matlab save file into a VIPS image. diff --git a/libvips/foreign/matrixload.c b/libvips/foreign/matrixload.c index 30b3632e..4f7c0b4b 100644 --- a/libvips/foreign/matrixload.c +++ b/libvips/foreign/matrixload.c @@ -165,7 +165,7 @@ vips_foreign_load_matrix_init( VipsForeignLoadMatrix *matrix ) /** * vips_matrixload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Reads a matrix from a file. diff --git a/libvips/foreign/matrixsave.c b/libvips/foreign/matrixsave.c index fc851fbd..55289b9c 100644 --- a/libvips/foreign/matrixsave.c +++ b/libvips/foreign/matrixsave.c @@ -131,7 +131,7 @@ vips_foreign_save_matrix_init( VipsForeignSaveMatrix *matrix ) } /** - * vips_matrixsave: + * vips_matrixsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -204,7 +204,7 @@ vips_foreign_print_matrix_init( VipsForeignPrintMatrix *matrix ) } /** - * vips_matrixprint: + * vips_matrixprint: (method) * @in: image to print * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/foreign/openexrload.c b/libvips/foreign/openexrload.c index a03f051e..700095ae 100644 --- a/libvips/foreign/openexrload.c +++ b/libvips/foreign/openexrload.c @@ -158,7 +158,7 @@ vips_foreign_load_openexr_init( VipsForeignLoadOpenexr *openexr ) /** * vips_openexrload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Read a OpenEXR file into a VIPS image. diff --git a/libvips/foreign/openslideload.c b/libvips/foreign/openslideload.c index 769373ca..b9380db2 100644 --- a/libvips/foreign/openslideload.c +++ b/libvips/foreign/openslideload.c @@ -222,7 +222,7 @@ vips_foreign_load_openslide_init( VipsForeignLoadOpenslide *openslide ) /** * vips_openslideload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/pdfload.c b/libvips/foreign/pdfload.c index ba1ed4c0..289c937d 100644 --- a/libvips/foreign/pdfload.c +++ b/libvips/foreign/pdfload.c @@ -661,7 +661,7 @@ vips_foreign_load_pdf_buffer_init( VipsForeignLoadPdfBuffer *buffer ) /** * vips_pdfload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -726,9 +726,9 @@ vips_pdfload( const char *filename, VipsImage **out, ... ) /** * vips_pdfload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/pngload.c b/libvips/foreign/pngload.c index ce805830..0d32996c 100644 --- a/libvips/foreign/pngload.c +++ b/libvips/foreign/pngload.c @@ -244,7 +244,7 @@ vips_foreign_load_png_buffer_init( VipsForeignLoadPngBuffer *buffer ) /** * vips_pngload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Read a PNG file into a VIPS image. It can read all png images, including 8- @@ -271,9 +271,9 @@ vips_pngload( const char *filename, VipsImage **out, ... ) /** * vips_pngload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Read a PNG-formatted memory block into a VIPS image. It can read all png diff --git a/libvips/foreign/pngsave.c b/libvips/foreign/pngsave.c index ff1d63e6..a6e2cf13 100644 --- a/libvips/foreign/pngsave.c +++ b/libvips/foreign/pngsave.c @@ -267,7 +267,7 @@ vips_foreign_save_png_buffer_init( VipsForeignSavePngBuffer *buffer ) #endif /*HAVE_PNG*/ /** - * vips_pngsave: + * vips_pngsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -322,10 +322,10 @@ vips_pngsave( VipsImage *in, const char *filename, ... ) } /** - * vips_pngsave_buffer: + * vips_pngsave_buffer: (method) * @in: image to save - * @buf: return output buffer here - * @len: return output length here + * @buf: (array length=len) (element-type guint8): return output buffer here + * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/ppmload.c b/libvips/foreign/ppmload.c index 81d41686..da92b0e7 100644 --- a/libvips/foreign/ppmload.c +++ b/libvips/foreign/ppmload.c @@ -149,7 +149,7 @@ vips_foreign_load_ppm_init( VipsForeignLoadPpm *ppm ) /** * vips_ppmload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Read a PPM/PBM/PGM/PFM file into a VIPS image. diff --git a/libvips/foreign/ppmsave.c b/libvips/foreign/ppmsave.c index 102d6297..33f0cc4b 100644 --- a/libvips/foreign/ppmsave.c +++ b/libvips/foreign/ppmsave.c @@ -149,7 +149,7 @@ vips_foreign_save_ppm_init( VipsForeignSavePpm *ppm ) #endif /*HAVE_PPM*/ /** - * vips_ppmsave: + * vips_ppmsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/foreign/radload.c b/libvips/foreign/radload.c index e35a322b..d2ab6503 100644 --- a/libvips/foreign/radload.c +++ b/libvips/foreign/radload.c @@ -151,7 +151,7 @@ vips_foreign_load_rad_init( VipsForeignLoadRad *rad ) /** * vips_radload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Read a Radiance (HDR) file into a VIPS image. diff --git a/libvips/foreign/radsave.c b/libvips/foreign/radsave.c index 6d4e2481..4571a9c6 100644 --- a/libvips/foreign/radsave.c +++ b/libvips/foreign/radsave.c @@ -229,7 +229,7 @@ vips_foreign_save_rad_buffer_init( VipsForeignSaveRadBuffer *buffer ) #endif /*HAVE_RADIANCE*/ /** - * vips_radsave: + * vips_radsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -256,10 +256,10 @@ vips_radsave( VipsImage *in, const char *filename, ... ) } /** - * vips_radsave_buffer: + * vips_radsave_buffer: (method) * @in: image to save - * @buf: return output buffer here - * @len: return output length here + * @buf: (array length=len) (element-type guint8): return output buffer here + * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments * * As vips_radsave(), but save to a memory buffer. diff --git a/libvips/foreign/rawload.c b/libvips/foreign/rawload.c index 118d0dda..2871089d 100644 --- a/libvips/foreign/rawload.c +++ b/libvips/foreign/rawload.c @@ -157,7 +157,7 @@ vips_foreign_load_raw_init( VipsForeignLoadRaw *raw ) /** * vips_rawload: * @filename: file to load - * @out: output image + * @out: (out): output image * @width: width of image in pixels * @height: height of image in pixels * @bands: number of image bands diff --git a/libvips/foreign/rawsave.c b/libvips/foreign/rawsave.c index 66537ad4..63f4ded2 100644 --- a/libvips/foreign/rawsave.c +++ b/libvips/foreign/rawsave.c @@ -155,7 +155,7 @@ vips_foreign_save_raw_init( VipsForeignSaveRaw *raw ) } /** - * vips_rawsave: + * vips_rawsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -261,7 +261,7 @@ vips_foreign_save_raw_fd_init( VipsForeignSaveRawFd *fd ) } /** - * vips_rawsave_fd: + * vips_rawsave_fd: (method) * @in: image to save * @fd: file to write to * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index a19298fd..2d6f7306 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -579,7 +579,7 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer ) /** * vips_svgload: * @filename: file to load - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -615,9 +615,9 @@ vips_svgload( const char *filename, VipsImage **out, ... ) /** * vips_svgload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/tiffload.c b/libvips/foreign/tiffload.c index 76d2a365..081a4cc3 100644 --- a/libvips/foreign/tiffload.c +++ b/libvips/foreign/tiffload.c @@ -326,7 +326,7 @@ vips_foreign_load_tiff_buffer_init( VipsForeignLoadTiffBuffer *buffer ) /** * vips_tiffload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -385,9 +385,9 @@ vips_tiffload( const char *filename, VipsImage **out, ... ) /** * vips_tiffload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/tiffsave.c b/libvips/foreign/tiffsave.c index c5b92074..6f7935e9 100644 --- a/libvips/foreign/tiffsave.c +++ b/libvips/foreign/tiffsave.c @@ -449,7 +449,7 @@ vips_foreign_save_tiff_buffer_init( VipsForeignSaveTiffBuffer *buffer ) #endif /*HAVE_TIFF*/ /** - * vips_tiffsave: + * vips_tiffsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -564,10 +564,10 @@ vips_tiffsave( VipsImage *in, const char *filename, ... ) } /** - * vips_tiffsave_buffer: + * vips_tiffsave_buffer: (method) * @in: image to save - * @buf: return output buffer here - * @len: return output length here + * @buf: (array length=len) (element-type guint8): return output buffer here + * @len: (type gsize): return output length here * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/vipsload.c b/libvips/foreign/vipsload.c index 165520df..c283adc0 100644 --- a/libvips/foreign/vipsload.c +++ b/libvips/foreign/vipsload.c @@ -150,7 +150,7 @@ vips_foreign_load_vips_init( VipsForeignLoadVips *vips ) /** * vips_vipsload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Read in a vips image. diff --git a/libvips/foreign/vipssave.c b/libvips/foreign/vipssave.c index ade2b152..5a1e2040 100644 --- a/libvips/foreign/vipssave.c +++ b/libvips/foreign/vipssave.c @@ -124,7 +124,7 @@ vips_foreign_save_vips_init( VipsForeignSaveVips *vips ) } /** - * vips_vipssave: + * vips_vipssave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/foreign/webpload.c b/libvips/foreign/webpload.c index c27a01ba..a95b9558 100644 --- a/libvips/foreign/webpload.c +++ b/libvips/foreign/webpload.c @@ -282,7 +282,7 @@ vips_foreign_load_webp_buffer_init( VipsForeignLoadWebpBuffer *buffer ) /** * vips_webpload: * @filename: file to load - * @out: decompressed image + * @out: (out): decompressed image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: @@ -315,9 +315,9 @@ vips_webpload( const char *filename, VipsImage **out, ... ) /** * vips_webpload_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: image to write + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): image to write * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/foreign/webpsave.c b/libvips/foreign/webpsave.c index be370f49..0baa2e24 100644 --- a/libvips/foreign/webpsave.c +++ b/libvips/foreign/webpsave.c @@ -356,7 +356,7 @@ vips_foreign_save_webp_mime_init( VipsForeignSaveWebpMime *mime ) #endif /*HAVE_LIBWEBP*/ /** - * vips_webpsave: + * vips_webpsave: (method) * @in: image to save * @filename: file to write to * @...: %NULL-terminated list of optional named arguments @@ -408,9 +408,9 @@ vips_webpsave( VipsImage *in, const char *filename, ... ) } /** - * vips_webpsave_buffer: + * vips_webpsave_buffer: (method) * @in: image to save - * @buf: return output buffer here + * @buf: (out) (array length=len) (element-type guint8): return output buffer here * @len: return output length here * @...: %NULL-terminated list of optional named arguments * @@ -463,7 +463,7 @@ vips_webpsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) } /** - * vips_webpsave_mime: + * vips_webpsave_mime: (method) * @in: image to save * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/freqfilt/freqmult.c b/libvips/freqfilt/freqmult.c index 9e35d882..7775cad2 100644 --- a/libvips/freqfilt/freqmult.c +++ b/libvips/freqfilt/freqmult.c @@ -141,10 +141,10 @@ vips_freqmult_init( VipsFreqmult *freqmult ) } /** - * vips_freqmult: + * vips_freqmult: (method) * @in: input image * @mask: mask image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Multiply @in by @mask in Fourier space. diff --git a/libvips/freqfilt/fwfft.c b/libvips/freqfilt/fwfft.c index 4d346358..7217ed5f 100644 --- a/libvips/freqfilt/fwfft.c +++ b/libvips/freqfilt/fwfft.c @@ -345,9 +345,9 @@ vips_fwfft_init( VipsFwfft *fwfft ) #endif /*HAVE_FFTW*/ /** - * vips_fwfft: + * vips_fwfft: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Transform an image to Fourier space. diff --git a/libvips/freqfilt/invfft.c b/libvips/freqfilt/invfft.c index 80ebfa30..16a318fa 100644 --- a/libvips/freqfilt/invfft.c +++ b/libvips/freqfilt/invfft.c @@ -269,9 +269,9 @@ vips_invfft_init( VipsInvfft *invfft ) #endif /*HAVE_FFTW*/ /** - * vips_invfft: + * vips_invfft: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/freqfilt/phasecor.c b/libvips/freqfilt/phasecor.c index dad98928..41b36766 100644 --- a/libvips/freqfilt/phasecor.c +++ b/libvips/freqfilt/phasecor.c @@ -125,7 +125,7 @@ vips_phasecor_init( VipsPhasecor *phasecor ) * vips_phasecor: * @in1: first input image * @in2: second input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Convert the two input images to Fourier space, calculate phase-correlation, diff --git a/libvips/freqfilt/spectrum.c b/libvips/freqfilt/spectrum.c index 685c4109..4729e353 100644 --- a/libvips/freqfilt/spectrum.c +++ b/libvips/freqfilt/spectrum.c @@ -109,9 +109,9 @@ vips_spectrum_init( VipsSpectrum *spectrum ) } /** - * vips_spectrum: + * vips_spectrum: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Make a displayable (ie. 8-bit unsigned int) power spectrum. diff --git a/libvips/histogram/hist_cum.c b/libvips/histogram/hist_cum.c index 57a6cfd2..4f6d7dbe 100644 --- a/libvips/histogram/hist_cum.c +++ b/libvips/histogram/hist_cum.c @@ -157,9 +157,9 @@ vips_hist_cum_init( VipsHistCum *hist_cum ) } /** - * vips_hist_cum: + * vips_hist_cum: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Form cumulative histogram. diff --git a/libvips/histogram/hist_entropy.c b/libvips/histogram/hist_entropy.c index 582f20a4..373975a2 100644 --- a/libvips/histogram/hist_entropy.c +++ b/libvips/histogram/hist_entropy.c @@ -130,9 +130,9 @@ vips_hist_entropy_init( VipsHistEntropy *entropy ) } /** - * vips_hist_entropy: + * vips_hist_entropy: (method) * @in: input histogram - * @out: image entropy + * @out: (out): image entropy * @...: %NULL-terminated list of optional named arguments * * Estimate image entropy from a histogram. Entropy is calculated as: diff --git a/libvips/histogram/hist_equal.c b/libvips/histogram/hist_equal.c index 159ec543..8cb6dd17 100644 --- a/libvips/histogram/hist_equal.c +++ b/libvips/histogram/hist_equal.c @@ -137,9 +137,9 @@ vips_hist_equal_init( VipsHistEqual *equal ) } /** - * vips_hist_equal: + * vips_hist_equal: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/histogram/hist_ismonotonic.c b/libvips/histogram/hist_ismonotonic.c index 9a4b6986..24d85c4c 100644 --- a/libvips/histogram/hist_ismonotonic.c +++ b/libvips/histogram/hist_ismonotonic.c @@ -136,9 +136,9 @@ vips_hist_ismonotonic_init( VipsHistIsmonotonic *ismonotonic ) } /** - * vips_hist_ismonotonic: + * vips_hist_ismonotonic: (method) * @in: lookup-table to test - * @out: set non-zero if @in is monotonic + * @out: (out): set non-zero if @in is monotonic * @...: %NULL-terminated list of optional named arguments * * Test @in for monotonicity. @out is set non-zero if @in is monotonic. diff --git a/libvips/histogram/hist_local.c b/libvips/histogram/hist_local.c index 9d0d36b6..9022ef4e 100644 --- a/libvips/histogram/hist_local.c +++ b/libvips/histogram/hist_local.c @@ -395,9 +395,9 @@ vips_hist_local_init( VipsHistLocal *local ) } /** - * vips_hist_local: + * vips_hist_local: (method) * @in: input image - * @out: output image + * @out: (out): output image * @width: width of region * @height: height of region * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/histogram/hist_match.c b/libvips/histogram/hist_match.c index 8f196385..b952d101 100644 --- a/libvips/histogram/hist_match.c +++ b/libvips/histogram/hist_match.c @@ -177,10 +177,10 @@ vips_hist_match_init( VipsHistMatch *match ) } /** - * vips_hist_match: + * vips_hist_match: (method) * @in: input histogram * @ref: reference histogram - * @out: output histogram + * @out: (out): output histogram * @...: %NULL-terminated list of optional named arguments * * Adjust @in to match @ref. If @in and @ref are normalised diff --git a/libvips/histogram/hist_norm.c b/libvips/histogram/hist_norm.c index 3baf5c64..b4de016d 100644 --- a/libvips/histogram/hist_norm.c +++ b/libvips/histogram/hist_norm.c @@ -156,9 +156,9 @@ vips_hist_norm_init( VipsHistNorm *hist_norm ) } /** - * vips_hist_norm: + * vips_hist_norm: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Normalise histogram ... normalise range to make it square (ie. max == diff --git a/libvips/histogram/hist_plot.c b/libvips/histogram/hist_plot.c index 41af74bb..033379b5 100644 --- a/libvips/histogram/hist_plot.c +++ b/libvips/histogram/hist_plot.c @@ -357,9 +357,9 @@ vips_hist_plot_init( VipsHistPlot *hist_plot ) } /** - * vips_hist_plot: + * vips_hist_plot: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Plot a 1 by any or any by 1 image file as a max by any or diff --git a/libvips/histogram/maplut.c b/libvips/histogram/maplut.c index f1dce435..3d691f21 100644 --- a/libvips/histogram/maplut.c +++ b/libvips/histogram/maplut.c @@ -724,9 +724,9 @@ vips_maplut_init( VipsMaplut *maplut ) } /** - * vips_maplut: + * vips_maplut: (method) * @in: input image - * @out: output image + * @out: (out): output image * @lut: look-up table * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/histogram/percent.c b/libvips/histogram/percent.c index b952904a..7aa32c2d 100644 --- a/libvips/histogram/percent.c +++ b/libvips/histogram/percent.c @@ -134,10 +134,10 @@ vips_percent_init( VipsPercent *percent ) } /** - * vips_percent: + * vips_percent: (method) * @in: input image * @percent: threshold percentage - * @threshold: output threshold value + * @threshold: (out): output threshold value * @...: %NULL-terminated list of optional named arguments * * vips_percent() returns (through the @threshold parameter) the threshold diff --git a/libvips/histogram/stdif.c b/libvips/histogram/stdif.c index 92d3bdc2..f745e6a0 100644 --- a/libvips/histogram/stdif.c +++ b/libvips/histogram/stdif.c @@ -360,9 +360,9 @@ vips_stdif_init( VipsStdif *stdif ) } /** - * vips_stdif: + * vips_stdif: (method) * @in: input image - * @out: output image + * @out: (out): output image * @width: width of region * @height: height of region * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h index 6d230119..edd3a81e 100644 --- a/libvips/include/vips/conversion.h +++ b/libvips/include/vips/conversion.h @@ -102,6 +102,35 @@ typedef enum { VIPS_INTERESTING_LAST } VipsInteresting; +typedef enum { + VIPS_BLEND_MODE_CLEAR, + VIPS_BLEND_MODE_SOURCE, + VIPS_BLEND_MODE_OVER, + VIPS_BLEND_MODE_IN, + VIPS_BLEND_MODE_OUT, + VIPS_BLEND_MODE_ATOP, + VIPS_BLEND_MODE_DEST, + VIPS_BLEND_MODE_DEST_OVER, + VIPS_BLEND_MODE_DEST_IN, + VIPS_BLEND_MODE_DEST_OUT, + VIPS_BLEND_MODE_DEST_ATOP, + VIPS_BLEND_MODE_XOR, + VIPS_BLEND_MODE_ADD, + VIPS_BLEND_MODE_SATURATE, + VIPS_BLEND_MODE_MULTIPLY, + VIPS_BLEND_MODE_SCREEN, + VIPS_BLEND_MODE_OVERLAY, + VIPS_BLEND_MODE_DARKEN, + VIPS_BLEND_MODE_LIGHTEN, + VIPS_BLEND_MODE_COLOUR_DODGE, + VIPS_BLEND_MODE_COLOUR_BURN, + VIPS_BLEND_MODE_HARD_LIGHT, + VIPS_BLEND_MODE_SOFT_LIGHT, + VIPS_BLEND_MODE_DIFFERENCE, + VIPS_BLEND_MODE_EXCLUSION, + VIPS_BLEND_MODE_LAST +} VipsBlendMode; + int vips_copy( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); int vips_tilecache( VipsImage *in, VipsImage **out, ... ) @@ -232,10 +261,17 @@ int vips_ifthenelse( VipsImage *cond, VipsImage *in1, VipsImage *in2, int vips_flatten( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); +int vips_addalpha( VipsImage *in, VipsImage **out, ... ) + __attribute__((sentinel)); int vips_premultiply( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); int vips_unpremultiply( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); +int vips_composite( VipsImage **in, VipsImage **out, int n, int *mode, ... ) + __attribute__((sentinel)); +int vips_composite2( VipsImage *in1, VipsImage *in2, VipsImage **out, + VipsBlendMode mode1, ... ) + __attribute__((sentinel)); int vips_falsecolour( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); diff --git a/libvips/include/vips/enumtypes.h b/libvips/include/vips/enumtypes.h index d864930c..463b2b64 100644 --- a/libvips/include/vips/enumtypes.h +++ b/libvips/include/vips/enumtypes.h @@ -46,6 +46,8 @@ 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()) diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 08c90c3e..6e83c5fa 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -373,6 +373,47 @@ vips_interesting_get_type( void ) 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 ) diff --git a/libvips/iofuncs/error.c b/libvips/iofuncs/error.c index 3ca63d29..8f12013e 100644 --- a/libvips/iofuncs/error.c +++ b/libvips/iofuncs/error.c @@ -324,7 +324,7 @@ vips_error_system( int err, const char *domain, const char *fmt, ... ) /** * vips_error_g: - * @error: glib error pointer + * @error: (out): glib error pointer * * This function sets the glib error pointer from the vips error buffer and * clears it. It's handy for returning errors to glib functions from vips. @@ -1188,7 +1188,7 @@ vips_check_hist( const char *domain, VipsImage *im ) * vips_check_matrix: * @domain: the originating domain for the error message * @im: image to check - * @out: put image as in-memory doubles here + * @out: (out): put image as in-memory doubles here * * Matrix images must have width and height less than 100000 and have 1 band. * diff --git a/libvips/iofuncs/generate.c b/libvips/iofuncs/generate.c index de025d64..ca8c8123 100644 --- a/libvips/iofuncs/generate.c +++ b/libvips/iofuncs/generate.c @@ -345,9 +345,9 @@ vips__demand_hint_array( VipsImage *image, /** * vips_image_pipeline_array: - * @image: output image + * @image: (out): output image * @hint: demand hint for @image - * @in: %NULL-terminated array of input images + * @in: (array zero-terminated=1): %NULL-terminated array of input images * * Add an image to a pipeline. @image depends on all of the images in @in, * @image prefers to supply pixels according to @hint. diff --git a/libvips/iofuncs/header.c b/libvips/iofuncs/header.c index ab58e9d8..7c3b2184 100644 --- a/libvips/iofuncs/header.c +++ b/libvips/iofuncs/header.c @@ -351,7 +351,7 @@ meta_init( VipsImage *im ) } /** - * vips_image_get_width: + * vips_image_get_width: (method) * @image: image to get from * * Returns: the number of pixels across the image. @@ -363,7 +363,7 @@ vips_image_get_width( const VipsImage *image ) } /** - * vips_image_get_height: + * vips_image_get_height: (method) * @image: image to get from * * Returns: the number of pixels down the image. @@ -375,7 +375,7 @@ vips_image_get_height( const VipsImage *image ) } /** - * vips_image_get_bands: + * vips_image_get_bands: (method) * @image: image to get from * * Returns: the number of bands (channels) in the image. @@ -387,7 +387,7 @@ vips_image_get_bands( const VipsImage *image ) } /** - * vips_image_get_format: + * vips_image_get_format: (method) * @image: image to get from * * Returns: the format of each band element. @@ -399,7 +399,7 @@ vips_image_get_format( const VipsImage *image ) } /** - * vips_image_guess_format: + * vips_image_guess_format: (method) * @image: image to guess for * * Return the #VipsBandFormat for an image, guessing a sane value if @@ -484,7 +484,7 @@ vips_image_guess_format( const VipsImage *image ) } /** - * vips_image_get_coding: + * vips_image_get_coding: (method) * @image: image to get from * * Returns: the image coding @@ -496,7 +496,7 @@ vips_image_get_coding( const VipsImage *image ) } /** - * vips_image_get_interpretation: + * vips_image_get_interpretation: (method) * @image: image to get from * * Return the #VipsInterpretation set in the image header. @@ -525,14 +525,27 @@ vips_image_default_interpretation( const VipsImage *image ) break; } - if( image->Bands == 1 ) - return( VIPS_INTERPRETATION_B_W ); - else - return( VIPS_INTERPRETATION_MULTIBAND ); + /* 1 and 2 bands -> greyscale. The extra band could be alpha. + */ + if( image->Bands < 3 ) { + if( image->BandFmt == VIPS_FORMAT_USHORT ) + return( VIPS_INTERPRETATION_GREY16 ); + else + return( VIPS_INTERPRETATION_B_W ); + } + else { + /* 3 or more -> some sort of RGB. You'll need to set CMYK + * explicitly if you want that. + */ + if( image->BandFmt == VIPS_FORMAT_USHORT ) + return( VIPS_INTERPRETATION_RGB16 ); + else + return( VIPS_INTERPRETATION_sRGB ); + } } /** - * vips_image_guess_interpretation: + * vips_image_guess_interpretation: (method) * @image: image to guess for * * Return the #VipsInterpretation for an image, guessing a sane value if @@ -566,8 +579,9 @@ vips_image_guess_interpretation( const VipsImage *image ) switch( image->Type ) { case VIPS_INTERPRETATION_MULTIBAND: - if( image->Bands == 1 ) - sane = FALSE; + /* This is a pretty useless generic tag. Always reset it. + */ + sane = FALSE; break; case VIPS_INTERPRETATION_B_W: @@ -643,7 +657,7 @@ vips_image_guess_interpretation( const VipsImage *image ) } /** - * vips_image_get_xres: + * vips_image_get_xres: (method) * @image: image to get from * * Returns: the horizontal image resolution in pixels per millimeter. @@ -655,7 +669,7 @@ vips_image_get_xres( const VipsImage *image ) } /** - * vips_image_get_yres: + * vips_image_get_yres: (method) * @image: image to get from * * Returns: the vertical image resolution in pixels per millimeter. @@ -667,7 +681,7 @@ vips_image_get_yres( const VipsImage *image ) } /** - * vips_image_get_xoffset: + * vips_image_get_xoffset: (method) * @image: image to get from * * Returns: the horizontal position of the image origin, in pixels. @@ -679,7 +693,7 @@ vips_image_get_xoffset( const VipsImage *image ) } /** - * vips_image_get_yoffset: + * vips_image_get_yoffset: (method) * @image: image to get from * * Returns: the vertical position of the image origin, in pixels. @@ -691,7 +705,7 @@ vips_image_get_yoffset( const VipsImage *image ) } /** - * vips_image_get_filename: + * vips_image_get_filename: (method) * @image: image to get from * * Returns: the name of the file the image was loaded from. @@ -703,7 +717,7 @@ vips_image_get_filename( const VipsImage *image ) } /** - * vips_image_get_mode: + * vips_image_get_mode: (method) * @image: image to get from * * Image modes are things like `"t"`, meaning a memory buffer, and `"p"` @@ -718,7 +732,7 @@ vips_image_get_mode( const VipsImage *image ) } /** - * vips_image_get_scale: + * vips_image_get_scale: (method) * @image: image to get from * * Matrix images can have an optional `scale` field for use by integer @@ -739,7 +753,7 @@ vips_image_get_scale( const VipsImage *image ) } /** - * vips_image_get_offset: + * vips_image_get_offset: (method) * @image: image to get from * * Matrix images can have an optional `offset` field for use by integer @@ -760,7 +774,7 @@ vips_image_get_offset( const VipsImage *image ) } /** - * vips_image_get_data: + * vips_image_get_data: (method) * @image: image to get data for * * Return a pointer to the image's pixel data, if possible. This can involve @@ -784,7 +798,7 @@ vips_image_get_data( VipsImage *image ) } /** - * vips_image_init_fields: + * vips_image_init_fields: (method) * @image: image to init * @xsize: image width * @ysize: image height @@ -916,7 +930,7 @@ vips__image_copy_fields_array( VipsImage *out, VipsImage *in[] ) } /** - * vips_image_set: + * vips_image_set: (method) * @image: image to set the metadata on * @name: the name to give the metadata * @value: the %GValue to copy into the image @@ -982,7 +996,7 @@ vips_set_value_from_pointer( GValue *value, void *data ) } /** - * vips_image_get: + * vips_image_get: (method) * @image: image to get the field from from * @name: the name to fetch * @value_copy: (transfer full) (out caller-allocates): the %GValue is copied into this @@ -1070,7 +1084,7 @@ vips_image_get( const VipsImage *image, const char *name, GValue *value_copy ) } /** - * vips_image_get_typeof: + * vips_image_get_typeof: (method) * @image: image to test * @name: the name to search for * @@ -1114,7 +1128,7 @@ vips_image_get_typeof( const VipsImage *image, const char *name ) } /** - * vips_image_remove: + * vips_image_remove: (method) * @image: image to test * @name: the name to search for * @@ -1142,10 +1156,10 @@ vips_image_map_fn( VipsMeta *meta, VipsImageMapFn fn, void *a ) } /** - * vips_image_map: + * vips_image_map: (method) * @image: image to map over * @fn: (scope call): function to call for each header field - * @a: user data for function + * @a: (closure fn): user data for function * * This function calls @fn for every header field, including every item of * metadata. @@ -1205,7 +1219,7 @@ add_fields( VipsImage *image, const char *field, GValue *value, void *a ) } /** - * vips_image_get_fields: + * vips_image_get_fields: (method) * @image: image to get fields from * * Get a %NULL-terminated array listing all the metadata field names on @image. @@ -1234,7 +1248,7 @@ vips_image_get_fields( VipsImage *image ) } /** - * vips_image_set_area: + * vips_image_set_area: (method) * @image: image to attach the metadata to * @name: metadata name * @free_fn: (scope async): free function for @data @@ -1281,10 +1295,10 @@ meta_get_value( const VipsImage *image, } /** - * vips_image_get_area: + * vips_image_get_area: (method) * @image: image to get the metadata from * @name: metadata name - * @data: return metadata value + * @data: (out): return metadata value * * Gets @data from @image under the name @name. A convenience * function over vips_image_get(). Use vips_image_get_typeof() to test for @@ -1310,7 +1324,7 @@ vips_image_get_area( const VipsImage *image, const char *name, void **data ) } /** - * vips_image_set_blob: + * vips_image_set_blob: (method) * @image: image to attach the metadata to * @name: metadata name * @free_fn: (scope async): free function for @data @@ -1336,7 +1350,7 @@ vips_image_set_blob( VipsImage *image, const char *name, } /** - * vips_image_get_blob: + * vips_image_get_blob: (method) * @image: image to get the metadata from * @name: metadata name * @data: pointer to area of memory @@ -1368,10 +1382,10 @@ vips_image_get_blob( const VipsImage *image, const char *name, } /** - * vips_image_get_int: + * vips_image_get_int: (method) * @image: image to get the header field from * @name: field name - * @out: return field value + * @out: (out): return field value * * Gets @out from @im under the name @name. * The value will be transformed into @@ -1395,7 +1409,7 @@ vips_image_get_int( const VipsImage *image, const char *name, int *out ) } /** - * vips_image_set_int: + * vips_image_set_int: (method) * @image: image to attach the metadata to * @field: metadata name * @i: metadata value @@ -1418,7 +1432,7 @@ vips_image_set_int( VipsImage *image, const char *field, int i ) } /** - * vips_image_get_double: + * vips_image_get_double: (method) * @image: image to get the header field from * @name: field name * @out: return field value @@ -1445,7 +1459,7 @@ vips_image_get_double( const VipsImage *image, const char *name, double *out ) } /** - * vips_image_set_double: + * vips_image_set_double: (method) * @image: image to attach the metadata to * @field: metadata name * @d: metadata value @@ -1468,7 +1482,7 @@ vips_image_set_double( VipsImage *image, const char *field, double d ) } /** - * vips_image_get_string: + * vips_image_get_string: (method) * @image: image to get the header field from * @name: field name * @out: (transfer none): return field value @@ -1511,7 +1525,7 @@ vips_image_get_string( const VipsImage *image, const char *name, } /** - * vips_image_set_string: + * vips_image_set_string: (method) * @image: image to attach the metadata to * @field: metadata name * @str: metadata value @@ -1534,7 +1548,7 @@ vips_image_set_string( VipsImage *image, const char *field, const char *str ) } /** - * vips_image_get_as_string: + * vips_image_get_as_string: (method) * @image: image to get the header field from * @field: field name * @out: (transfer full): return field value as string @@ -1582,7 +1596,7 @@ vips_image_get_as_string( const VipsImage *image, } /** - * vips_image_print_field: + * vips_image_print_field: (method) * @image: image to get the header field from * @field: field name * @@ -1604,7 +1618,7 @@ vips_image_print_field( const VipsImage *image, const char *field ) } /** - * vips_image_history_printf: + * vips_image_history_printf: (method) * @image: add history line to this image * @format: printf() format string * @...: arguments to format string @@ -1664,11 +1678,11 @@ vips_image_history_printf( VipsImage *image, const char *fmt, ... ) } /** - * vips_image_history_args: + * vips_image_history_args: (method) * @image: image to attach history line to * @name: program name * @argc: number of program arguments - * @argv: program arguments + * @argv: (array length=argc) (element-type char*): program arguments * * Formats the name/argv as a single string and calls * vips_image_history_printf(). A @@ -1700,7 +1714,7 @@ vips_image_history_args( VipsImage *image, } /** - * vips_image_get_history: + * vips_image_get_history: (method) * @image: get history from here * * This function reads the image history as a C string. The string is owned diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 66a7feee..9efe22a1 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -1413,7 +1413,7 @@ vips_image_invalidate_all_cb( VipsImage *image ) } /** - * vips_image_invalidate_all: + * vips_image_invalidate_all: (method) * @image: #VipsImage to invalidate * * Invalidate all pixel caches on @image and any downstream images, that @@ -1453,7 +1453,7 @@ vips_image_minimise_all_cb( VipsImage *image ) } /** - * vips_image_minimise_all: + * vips_image_minimise_all: (method) * @image: #VipsImage to minimise * * Minimise memory use on this image and any upstream images, that is, images @@ -1591,7 +1591,7 @@ vips_image_posteval( VipsImage *image ) } /** - * vips_image_set_progress: + * vips_image_set_progress: (method) * @image: image to signal progress on * @progress: turn progress reporting on or off * @@ -1615,7 +1615,7 @@ vips_image_set_progress( VipsImage *image, gboolean progress ) /** - * vips_image_iskilled: + * vips_image_iskilled: (method) * @image: image to test * * If @image has been killed (see vips_image_set_kill()), set an error message, @@ -1652,7 +1652,7 @@ vips_image_iskilled( VipsImage *image ) } /** - * vips_image_set_kill: + * vips_image_set_kill: (method) * @image: image to test * @kill: the kill state * @@ -1688,7 +1688,7 @@ vips_image_temp_name( void ) } /** - * vips_image_new: + * vips_image_new: (constructor) * * vips_image_new() creates a new, empty #VipsImage. * If you write to one of these images, vips will just attach some callbacks, @@ -1744,7 +1744,7 @@ vips_image_new_mode( const char *filename, const char *mode ) } /** - * vips_image_new_memory: + * vips_image_new_memory: (constructor) * * vips_image_new_memory() creates a new #VipsImage which, when written to, will * create a memory image. @@ -1760,7 +1760,7 @@ vips_image_new_memory( void ) } /** - * vips_image_memory: + * vips_image_memory: (constructor) * * A renamed vips_image_new_memory() ... Some gobject binding systems do not * like more than one _new() method. @@ -1824,7 +1824,7 @@ vips_filename_get_options( const char *vips_filename ) } /** - * vips_image_new_from_file: + * vips_image_new_from_file: (constructor) * @name: file to open * @...: %NULL-terminated list of optional named arguments * @@ -1924,7 +1924,7 @@ vips_image_new_from_file( const char *name, ... ) } /** - * vips_image_new_from_file_RW: + * vips_image_new_from_file_RW: (constructor) * @filename: filename to open * * Opens the named file for simultaneous reading and writing. This will only @@ -1942,7 +1942,7 @@ vips_image_new_from_file_RW( const char *filename ) } /** - * vips_image_new_from_file_raw: + * vips_image_new_from_file_raw: (constructor) * @filename: filename to open * @xsize: image width * @ysize: image height @@ -1985,9 +1985,9 @@ vips_image_new_from_file_raw( const char *filename, } /** - * vips_image_new_from_memory: + * vips_image_new_from_memory: (constructor) * @data: (array length=size) (element-type guint8) (transfer none): start of memory area - * @size: length of memory area + * @size: (type gsize): length of memory area * @width: image width * @height: image height * @bands: image bands (or bytes per pixel) @@ -2060,9 +2060,9 @@ vips_image_new_from_memory_copy_cb( VipsImage *image, void *data_copy ) } /** - * vips_image_new_from_memory_copy: + * vips_image_new_from_memory_copy: (constructor) * @data: (array length=size) (element-type guint8) (transfer none): start of memory area - * @size: length of memory area + * @size: (type gsize): length of memory area * @width: image width * @height: image height * @bands: image bands (or bytes per pixel) @@ -2102,9 +2102,9 @@ vips_image_new_from_memory_copy( const void *data, size_t size, } /** - * vips_image_new_from_buffer: + * vips_image_new_from_buffer: (constructor) * @buf: (array length=len) (element-type guint8) (transfer none): image data - * @len: length of memory buffer + * @len: (type gsize): length of memory buffer * @option_string: set of extra options as a string * @...: %NULL-terminated list of optional named arguments * @@ -2158,7 +2158,7 @@ vips_image_new_from_buffer( const void *buf, size_t len, } /** - * vips_image_new_matrix: + * vips_image_new_matrix: (constructor) * @width: image width * @height: image height * @@ -2204,7 +2204,7 @@ vips_image_new_matrix( int width, int height ) } /** - * vips_image_new_matrixv: + * vips_image_new_matrixv: (constructor) * @width: image width * @height: image height * @...: matrix coefficients @@ -2238,11 +2238,11 @@ vips_image_new_matrixv( int width, int height, ... ) } /** - * vips_image_new_matrix_from_array: + * vips_image_new_matrix_from_array: (constructor) * @width: image width * @height: image height * @array: (array length=size) (transfer none): array of elements - * @size: number of elements + * @size: (type gsize): number of elements * * A binding-friendly version of vips_image_new_matrixv(). * @@ -2276,11 +2276,11 @@ vips_image_new_matrix_from_array( int width, int height, } /** - * vips_image_matrix_from_array: + * vips_image_matrix_from_array: (constructor) * @width: image width * @height: image height * @array: (array length=size) (transfer none): array of elements - * @size: number of elements + * @size: (type gsize): number of elements * * A renamed vips_image_new_matrix_from_array(). Some gobject bindings do not * like more than one _new method. @@ -2296,7 +2296,7 @@ vips_image_matrix_from_array( int width, int height, } /** - * vips_image_new_from_image: + * vips_image_new_from_image: (constructor) * @image: image to copy * @c: (array length=n) (transfer none): array of constants * @n: number of constants @@ -2351,7 +2351,7 @@ vips_image_new_from_image( VipsImage *image, const double *c, int n ) } /** - * vips_image_new_from_image1: + * vips_image_new_from_image1: (constructor) * @image: image to copy * @c: constants * @@ -2370,7 +2370,7 @@ vips_image_new_from_image1( VipsImage *image, double c ) } /** - * vips_image_set_delete_on_close: + * vips_image_set_delete_on_close: (method) * @image: image to set * @delete_on_close: format of file * @@ -2435,7 +2435,7 @@ vips_get_disc_threshold( void ) } /** - * vips_image_new_temp_file: + * vips_image_new_temp_file: (constructor) * @format: format of file * * Make a #VipsImage which, when written to, will create a temporary file on @@ -2501,9 +2501,9 @@ vips_image_write_gen( VipsRegion *or, } /** - * vips_image_write: + * vips_image_write: (method) * @image: image to write - * @out: write to this image + * @out: (out): write to this image * * Write @image to @out. Use vips_image_new() and friends to create the * #VipsImage you want to write to. @@ -2535,12 +2535,14 @@ vips_image_write( VipsImage *image, VipsImage *out ) g_object_ref( image ); vips_object_local( out, image ); } + else { + } return( 0 ); } /** - * vips_image_write_to_file: + * vips_image_write_to_file: (method) * @image: image to write * @name: write to this file * @...: %NULL-terminated list of optional named arguments @@ -2578,11 +2580,11 @@ vips_image_write_to_file( VipsImage *image, const char *name, ... ) } /** - * vips_image_write_to_buffer: + * vips_image_write_to_buffer: (method) * @in: image to write * @suffix: format to write * @buf: (array length=size) (element-type guint8) (transfer full): return buffer start here - * @size: return buffer length here + * @size: (type gsize): return buffer length here * @...: %NULL-terminated list of optional named arguments * * Writes @in to a memory buffer in a format specified by @suffix. @@ -2636,7 +2638,7 @@ vips_image_write_to_buffer( VipsImage *in, } /** - * vips_image_write_to_memory: + * vips_image_write_to_memory: (method) * @in: image to write * @size: return buffer length here * @@ -2681,9 +2683,9 @@ vips_image_write_to_memory( VipsImage *in, size_t *size_out ) } /** - * vips_image_decode: + * vips_image_decode: (method) * @in: image to decode - * @out: write to this image + * @out: (out): write to this image * * A convenience function to unpack to a format that we can compute with. * @out.coding is always #VIPS_CODING_NONE. @@ -2717,10 +2719,10 @@ vips_image_decode( VipsImage *in, VipsImage **out ) } /** - * vips_image_decode_predict: + * vips_image_decode_predict: (method) * @in: image to decode - * @bands: predict bands here - * @format: predict format here + * @bands: (out): predict bands here + * @format: (out): predict format here * * We often need to know what an image will decode to without actually * decoding it, for example, in arg checking. @@ -2756,9 +2758,9 @@ vips_image_decode_predict( VipsImage *in, } /** - * vips_image_encode: + * vips_image_encode: (method) * @in: image to encode - * @out: write to this image + * @out: (out): write to this image * @coding: coding to apply * * A convenience function to pack to a coding. The inverse of @@ -2788,7 +2790,7 @@ vips_image_encode( VipsImage *in, VipsImage **out, VipsCoding coding ) } /** - * vips_image_isMSBfirst: + * vips_image_isMSBfirst: (method) * @image: image to test * * Return %TRUE if @image is in most-significant- @@ -2805,7 +2807,7 @@ vips_image_isMSBfirst( VipsImage *image ) } /** - * vips_image_isfile: + * vips_image_isfile: (method) * @image: image to test * * Return %TRUE if @image represents a file on disc in some way. @@ -2832,7 +2834,7 @@ gboolean vips_image_isfile( VipsImage *image ) } /** - * vips_image_ispartial: + * vips_image_ispartial: (method) * @image: image to test * * Return %TRUE if @im represents a partial image (a delayed calculation). @@ -2847,7 +2849,7 @@ vips_image_ispartial( VipsImage *image ) } /** - * vips_image_hasalpha: + * vips_image_hasalpha: (method) * @image: image to check * * libvips assumes an image has an alpha if it has two bands (ie. it is a @@ -2865,7 +2867,7 @@ vips_image_hasalpha( VipsImage *image ) } /** - * vips_image_write_prepare: + * vips_image_write_prepare: (method) * @image: image to prepare * * Call this after setting header fields (width, height, and so on) to @@ -2930,7 +2932,7 @@ vips_image_write_prepare( VipsImage *image ) } /** - * vips_image_write_line: + * vips_image_write_line: (method) * @image: image to write to * @ypos: vertical position of scan-line to write * @linebuffer: scanline of pixels @@ -3066,7 +3068,7 @@ vips_image_rewind_output( VipsImage *image ) } /** - * vips_image_copy_memory: + * vips_image_copy_memory: (method) * @image: image to copy to a memory buffer * * Allocate a memory buffer and copy @image to it. This is a thread-safe @@ -3087,6 +3089,9 @@ VipsImage * vips_image_copy_memory( VipsImage *image ) { VipsImage *new; + VipsImage *image_array[2]; + size_t length; + void *data; switch( image->dtype ) { case VIPS_IMAGE_SETBUF: @@ -3102,13 +3107,36 @@ vips_image_copy_memory( VipsImage *image ) case VIPS_IMAGE_OPENOUT: case VIPS_IMAGE_OPENIN: case VIPS_IMAGE_PARTIAL: - /* Copy to a new memory image. + /* We don't use vips_image_new_memory() and vips_image_write() + * since we want to make a break in the pipeline and we want + * to avoid all the machinery around reordering and dependancy + * links. + * + * We especially want to be able to unref input and have output + * survive. Things like the progress signal must be cleared, + * for example. */ - new = vips_image_new_memory(); - if( vips_image_write( image, new ) ) { - g_object_unref( new ); + + /* Write to a new memory image. + */ + if( !(data = vips_image_write_to_memory( image, &length )) ) + return( NULL ); + if( !(new = vips_image_new_from_memory( data, length, + image->Xsize, image->Ysize, image->Bands, + image->BandFmt )) ) { + g_free( data ); return( NULL ); } + + /* Copy over other fields and the metadata. + */ + image_array[0] = image; + image_array[1] = NULL; + if( vips__image_copy_fields_array( new, image_array ) ) { + VIPS_UNREF( new ); + return( NULL ); + } + break; default: @@ -3121,7 +3149,7 @@ vips_image_copy_memory( VipsImage *image ) } /** - * vips_image_wio_input: + * vips_image_wio_input: (method) * @image: image to transform * * Check that an image is readable via the VIPS_IMAGE_ADDR() macro, that is, @@ -3296,7 +3324,7 @@ vips__image_wio_output( VipsImage *image ) } /** - * vips_image_inplace: + * vips_image_inplace: (method) * @image: image to make read-write * * Gets @image ready for an in-place operation, such as vips_draw_circle(). @@ -3353,7 +3381,7 @@ vips_image_inplace( VipsImage *image ) } /** - * vips_image_pio_input: + * vips_image_pio_input: (method) * @image: image to check * * Check that an image is readable with vips_region_prepare() and friends. @@ -3430,7 +3458,7 @@ vips_image_pio_input( VipsImage *image ) } /** - * vips_image_pio_output: + * vips_image_pio_output: (method) * @image: image to check * * Check that an image is writeable with vips_image_generate(). If it isn't, diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index ce66d620..2e7584f5 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -130,6 +130,9 @@ vips_get_argv0( void ) * VIPS_INIT: * @ARGV0: name of application * + * gtk-doc mistakenly tags this macro as deprecated for unknown reasons. It is + * *NOT* deprecated, please ignore the warning above. + * * VIPS_INIT() starts up the world of VIPS. You should call this on * program startup before using any other VIPS operations. If you do not call * VIPS_INIT(), VIPS will call it for you when you use your first VIPS diff --git a/libvips/iofuncs/memory.c b/libvips/iofuncs/memory.c index f70a726d..5d0d92d0 100644 --- a/libvips/iofuncs/memory.c +++ b/libvips/iofuncs/memory.c @@ -145,7 +145,7 @@ vips_malloc_cb( VipsObject *object, char *buf ) /** * vips_malloc: - * @object: allocate memory local to this #VipsObject, or %NULL + * @object: (nullable): allocate memory local to this #VipsObject, or %NULL * @size: number of bytes to allocate * * g_malloc() local to @object, that is, the memory will be automatically @@ -177,7 +177,7 @@ vips_malloc( VipsObject *object, size_t size ) /** * vips_strdup: - * @object: allocate memory local to this #VipsObject, or %NULL + * @object: (nullable): allocate memory local to this #VipsObject, or %NULL * @str: string to copy * * g_strdup() a string. When @object is freed, the string will be freed for diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 40e1d3b7..34c13dbb 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -770,7 +770,7 @@ vips_object_get_argument( VipsObject *object, const char *name, } /** - * vips_object_argument_isset: + * vips_object_argument_isset: * @object: the object to fetch the args from * @name: arg to fetch * @@ -793,7 +793,7 @@ vips_object_argument_isset( VipsObject *object, const char *name ) } /** - * vips_object_get_argument_flags: + * vips_object_get_argument_flags: * @object: the object to fetch the args from * @name: arg to fetch * @@ -816,7 +816,7 @@ vips_object_get_argument_flags( VipsObject *object, const char *name ) } /** - * vips_object_get_argument_priority: + * vips_object_get_argument_priority: * @object: the object to fetch the args from * @name: arg to fetch * diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 95dcefa4..0582808f 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -630,7 +630,7 @@ vips_operation_invalidate( VipsOperation *operation ) } /** - * vips_operation_new: + * vips_operation_new: (constructor) * @name: nickname of operation to create * * Return a new #VipsOperation with the specified nickname. Useful for diff --git a/libvips/iofuncs/rect.c b/libvips/iofuncs/rect.c index a2f4ec15..d77e024d 100644 --- a/libvips/iofuncs/rect.c +++ b/libvips/iofuncs/rect.c @@ -85,7 +85,7 @@ vips_rect_includespoint( const VipsRect *r, int x, int y ) } /** - * vips_rect_isempty: + * vips_rect_isempty: (method) * @r: rectangle to test * * Is @r empty? ie. zero width or height. @@ -99,7 +99,7 @@ vips_rect_isempty( const VipsRect *r ) } /** - * vips_rect_includesrect: + * vips_rect_includesrect: (method) * @r1: outer rectangle * @r2: inner rectangle * @@ -117,7 +117,7 @@ vips_rect_includesrect( const VipsRect *r1, const VipsRect *r2 ) } /** - * vips_rect_equalsrect: + * vips_rect_equalsrect: (method) * @r1: first rectangle * @r2: second rectangle * @@ -133,7 +133,7 @@ vips_rect_equalsrect( const VipsRect *r1, const VipsRect *r2 ) } /** - * vips_rect_marginadjust: + * vips_rect_marginadjust: (method) * @r: rectangle to adjust * @n: enlarge by * @@ -152,7 +152,7 @@ vips_rect_marginadjust( VipsRect *r, int n ) * vips_rect_intersectrect: * @r1: input rectangle 1 * @r2: input rectangle 2 - * @out: output rectangle + * @out: (out): output rectangle * * Fill @out with the intersection of @r1 and @r2. @out can equal @r1 or @r2. */ @@ -176,7 +176,7 @@ vips_rect_intersectrect( const VipsRect *r1, const VipsRect *r2, VipsRect *out ) * vips_rect_unionrect: * @r1: input rectangle 1 * @r2: input rectangle 2 - * @out: output rectangle + * @out: (out): output rectangle * * Fill @out with the bounding box of @r1 and @r2. @out can equal @r1 or @r2. */ @@ -223,7 +223,7 @@ vips_rect_dup( const VipsRect *r ) } /** - * vips_rect_normalise: + * vips_rect_normalise: (method) * @r: rect to normalise * * Make sure width and height are >0 by moving the origin and flipping the diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index 39b4626e..715da41a 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -508,7 +508,7 @@ vips_region_init( VipsRegion *region ) } /** - * vips_region_new: + * vips_region_new: (constructor) * @image: image to create this region on * * Create a region. #VipsRegion s start out empty, you need to call @@ -553,7 +553,7 @@ vips_region_new( VipsImage *image ) */ /** - * vips_region_buffer: + * vips_region_buffer: (method) * @reg: region to operate upon * @r: #VipsRect of pixels you need to be able to address * @@ -622,7 +622,7 @@ vips_region_buffer( VipsRegion *reg, VipsRect *r ) } /** - * vips_region_image: + * vips_region_image: (method) * @reg: region to operate upon * @r: #VipsRect of pixels you need to be able to address * @@ -709,7 +709,7 @@ vips_region_image( VipsRegion *reg, VipsRect *r ) } /** - * vips_region_region: + * vips_region_region: (method) * @reg: region to operate upon * @dest: region to connect to * @r: #VipsRect of pixels you need to be able to address @@ -845,7 +845,7 @@ vips_region_equalsregion( VipsRegion *reg1, VipsRegion *reg2 ) } /** - * vips_region_position: + * vips_region_position: (method) * @reg: region to operate upon * @x: position to move to * @y: position to move to @@ -928,7 +928,7 @@ vips_region_fill( VipsRegion *reg, VipsRect *r, VipsRegionFillFn fn, void *a ) } /** - * vips_region_paint: + * vips_region_paint: (method) * @reg: region to operate upon * @r: area to paint * @value: value to paint @@ -997,7 +997,7 @@ vips_region_paint( VipsRegion *reg, VipsRect *r, int value ) } /** - * vips_region_paint_pel: + * vips_region_paint_pel: (method) * @reg: region to operate upon * @r: area to paint * @ink: value to paint @@ -1048,7 +1048,7 @@ vips_region_paint_pel( VipsRegion *reg, VipsRect *r, VipsPel *ink ) } /** - * vips_region_black: + * vips_region_black: (method) * @reg: region to operate upon * * Paints 0 into the valid part of @reg. @@ -1064,7 +1064,7 @@ vips_region_black( VipsRegion *reg ) /** * vips_region_copy: * @reg: source region - * @dest: destination region + * @dest: (inout): destination region * @r: #VipsRect of pixels you need to copy * @x: postion of @r in @dest * @y: postion of @r in @dest @@ -1326,7 +1326,7 @@ vips_region_shrink_alpha( VipsRegion *from, VipsRegion *to, VipsRect *target ) /** * vips_region_shrink: * @from: source region - * @to: destination region + * @to: (inout): destination region * @target: #VipsRect of pixels you need to copy * * Write the pixels @target in @to from the x2 larger area in @from. @@ -1387,7 +1387,7 @@ vips_region_generate( VipsRegion *reg ) } /** - * vips_region_prepare: + * vips_region_prepare: (method) * @reg: region to prepare * @r: #VipsRect of pixels you need to be able to address * @@ -1515,9 +1515,9 @@ vips_region_prepare_to_generate( VipsRegion *reg, } /** - * vips_region_prepare_to: + * vips_region_prepare_to: (method) * @reg: region to prepare - * @dest: region to write to + * @dest: (inout): region to write to * @r: #VipsRect of pixels you need to be able to address * @x: postion of @r in @dest * @y: postion of @r in @dest @@ -1685,7 +1685,7 @@ vips_region_prepare_many( VipsRegion **reg, VipsRect *r ) } /** - * vips_region_invalidate: + * vips_region_invalidate: (method) * @reg: region to invalidate * * Mark a region as containing invalid pixels. Calling this function means diff --git a/libvips/iofuncs/reorder.c b/libvips/iofuncs/reorder.c index 1c1c3096..47759053 100644 --- a/libvips/iofuncs/reorder.c +++ b/libvips/iofuncs/reorder.c @@ -313,9 +313,9 @@ vips__reorder_set_input( VipsImage *image, VipsImage **in ) } /** - * vips_reorder_prepare_many: + * vips_reorder_prepare_many: (method) * @image: the image that's being written - * @regions: the set of regions to prepare + * @regions: (array) (element-type VipsRegion): the set of regions to prepare * @r: the #VipsRect to prepare on each region * * vips_reorder_prepare_many() runs vips_region_prepare() on each region in @@ -346,7 +346,7 @@ vips_reorder_prepare_many( VipsImage *image, VipsRegion **regions, VipsRect *r ) } /** - * vips_reorder_margin_hint: + * vips_reorder_margin_hint: (method) * @image: the image to hint on * @margin: the size of the margin this operation has added * diff --git a/libvips/iofuncs/sink.c b/libvips/iofuncs/sink.c index fbff303c..f8e44a46 100644 --- a/libvips/iofuncs/sink.c +++ b/libvips/iofuncs/sink.c @@ -325,7 +325,7 @@ vips_sink_base_progress( void *a ) } /** - * vips_sink_tile: + * vips_sink_tile: (method) * @im: scan over this image * @tile_width: tile width * @tile_height: tile height @@ -391,7 +391,7 @@ vips_sink_tile( VipsImage *im, } /** - * vips_sink: + * vips_sink: (method) * @im: scan over this image * @start_fn: start sequences with this function * @generate_fn: generate pixels with this function diff --git a/libvips/iofuncs/sinkdisc.c b/libvips/iofuncs/sinkdisc.c index 8ee93272..acf3ff5e 100644 --- a/libvips/iofuncs/sinkdisc.c +++ b/libvips/iofuncs/sinkdisc.c @@ -469,10 +469,10 @@ write_free( Write *write ) */ /** - * vips_sink_disc: + * vips_sink_disc: (method) * @im: image to process - * @write_fn: called for every batch of pixels - * @a: client data + * @write_fn: (scope call): called for every batch of pixels + * @a: (closure write_fn): client data * * vips_sink_disc() loops over @im, top-to-bottom, generating it in sections. * As each section is produced, @write_fn is called. diff --git a/libvips/iofuncs/sinkscreen.c b/libvips/iofuncs/sinkscreen.c index 35556dbf..82447667 100644 --- a/libvips/iofuncs/sinkscreen.c +++ b/libvips/iofuncs/sinkscreen.c @@ -1021,16 +1021,16 @@ vips_sink_screen_init( void ) } /** - * vips_sink_screen: + * vips_sink_screen: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: mask image indicating valid pixels * @tile_width: tile width * @tile_height: tile height * @max_tiles: maximum tiles to cache * @priority: rendering priority - * @notify_fn: pixels are ready notification callback - * @a: client data for callback + * @notify_fn: (scope call) (nullable): pixels are ready notification callback + * @a: (closure notify_fn) (nullable): client data for callback * * This operation renders @in in the background, making pixels available on * @out as they are calculated. The @notify_fn callback is run every time a new diff --git a/libvips/iofuncs/threadpool.c b/libvips/iofuncs/threadpool.c index 149c0de3..8fcaa8b3 100644 --- a/libvips/iofuncs/threadpool.c +++ b/libvips/iofuncs/threadpool.c @@ -1024,11 +1024,11 @@ vips__threadpool_init( void ) } /** - * vips_get_tile_size: + * vips_get_tile_size: (method) * @im: image to guess for - * @tile_width: return selected tile width - * @tile_height: return selected tile height - * @n_lines: return buffer height in scanlines + * @tile_width: (out): return selected tile width + * @tile_height: (out): return selected tile height + * @n_lines: (out): return buffer height in scanlines * * Pick a tile size and a buffer height for this image and the current * value of vips_concurrency_get(). The buffer height diff --git a/libvips/iofuncs/type.c b/libvips/iofuncs/type.c index 53c2ebae..76343984 100644 --- a/libvips/iofuncs/type.c +++ b/libvips/iofuncs/type.c @@ -221,7 +221,7 @@ vips_area_unref( VipsArea *area ) } /** - * vips_area_new: + * vips_area_new: (constructor) * @free_fn: (scope async): @data will be freed with this function * @data: data will be freed with this function * @@ -287,7 +287,7 @@ vips__type_leak( void ) } /** - * vips_area_new_array: + * vips_area_new_array: * @type: %GType of elements to store * @sizeof_type: sizeof() an element in the array * @n: number of elements in the array @@ -328,7 +328,7 @@ vips_area_free_array_object( GObject **array, VipsArea *area ) } /** - * vips_area_new_array_object: + * vips_area_new_array_object: (constructor) * @n: number of elements in the array * * An area which holds an array of %GObject s. See vips_area_new_array(). When @@ -359,12 +359,12 @@ vips_area_new_array_object( int n ) } /** - * vips_area_get_data: + * vips_area_get_data: (method) * @area: #VipsArea to fetch from - * @length: (allow-none): optionally return length in bytes here - * @n: (allow-none): optionally return number of elements here - * @type: (allow-none): optionally return element type here - * @sizeof_type: (allow-none): optionally return sizeof() element type here + * @length: (optional): optionally return length in bytes here + * @n: (optional): optionally return number of elements here + * @type: (optional): optionally return element type here + * @sizeof_type: (optional): optionally return sizeof() element type here * * Return the data pointer plus optionally the length in bytes of an area, * the number of elements, the %GType of each element and the sizeof() each @@ -893,6 +893,20 @@ transform_double_array_int( const GValue *src_value, GValue *dest_value ) array[0] = g_value_get_double( src_value ); } +static void +transform_array_double_array_int( const GValue *src_value, GValue *dest_value ) +{ + int n; + double *array_double = vips_value_get_array_double( src_value, &n ); + int *array_int; + int i; + + vips_value_set_array_int( dest_value, NULL, n ); + array_int = vips_value_get_array_int( dest_value, NULL ); + for( i = 0; i < n; i++ ) + array_int[i] = array_double[i]; +} + GType vips_array_int_get_type( void ) { @@ -910,6 +924,8 @@ vips_array_int_get_type( void ) transform_int_array_int ); g_value_register_transform_func( G_TYPE_DOUBLE, type, transform_double_array_int ); + g_value_register_transform_func( VIPS_TYPE_ARRAY_DOUBLE, type, + transform_array_double_array_int ); } return( type ); @@ -1084,6 +1100,28 @@ transform_int_array_double( const GValue *src_value, GValue *dest_value ) array[0] = g_value_get_int( src_value ); } +static void +transform_array_int_array_double( const GValue *src_value, GValue *dest_value ) +{ + int n; + int *array_int = vips_value_get_array_int( src_value, &n ); + double *array_double; + int i; + + vips_value_set_array_double( dest_value, NULL, n ); + array_double = vips_value_get_array_double( dest_value, NULL ); + for( i = 0; i < n; i++ ) + array_double[i] = array_int[i]; +} + +/* You can set enums from ints, but not doubles. Add a double converter too. + */ +static void +transform_double_enum( const GValue *src_value, GValue *dest_value ) +{ + g_value_set_enum( dest_value, g_value_get_double( src_value ) ); +} + GType vips_array_double_get_type( void ) { @@ -1101,13 +1139,17 @@ vips_array_double_get_type( void ) transform_double_array_double ); g_value_register_transform_func( G_TYPE_INT, type, transform_int_array_double ); + g_value_register_transform_func( VIPS_TYPE_ARRAY_INT, type, + transform_array_int_array_double ); + g_value_register_transform_func( G_TYPE_DOUBLE, G_TYPE_ENUM, + transform_double_enum ); } return( type ); } /** - * vips_array_image_new: + * vips_array_image_new: (constructor) * @array: (array length=n): array of #VipsImage * @n: number of images * @@ -1145,7 +1187,7 @@ vips_array_image_new( VipsImage **array, int n ) } /** - * vips_array_image_newv: + * vips_array_image_newv: (constructor) * @n: number of images * @...: list of #VipsImage arguments * @@ -1232,7 +1274,7 @@ vips_array_image_new_from_string( const char *string, VipsAccess access ) } /** - * vips_array_image_empty: + * vips_array_image_empty: (constructor) * * Make an empty image array. * Handy with vips_array_image_add() for bindings @@ -1249,7 +1291,7 @@ vips_array_image_empty( void ) } /** - * vips_array_image_append: + * vips_array_image_append: (method) * @array: (transfer none): append to this * @image: add this * @@ -1289,7 +1331,7 @@ vips_array_image_append( VipsArrayImage *array, VipsImage *image ) } /** - * vips_array_image_get: + * vips_array_image_get: (method) * @array: the #VipsArrayImage to fetch from * @n: length of array * diff --git a/libvips/morphology/countlines.c b/libvips/morphology/countlines.c index 7fbdc85b..0812dee1 100644 --- a/libvips/morphology/countlines.c +++ b/libvips/morphology/countlines.c @@ -157,9 +157,9 @@ vips_countlines_init( VipsCountlines *countlines ) } /** - * vips_countlines: + * vips_countlines: (method) * @in: input image - * @nolines: output average number of lines + * @nolines: (out): output average number of lines * @direction: count lines horizontally or vertically * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/morphology/labelregions.c b/libvips/morphology/labelregions.c index 880b21be..161fb754 100644 --- a/libvips/morphology/labelregions.c +++ b/libvips/morphology/labelregions.c @@ -142,7 +142,7 @@ vips_labelregions_init( VipsLabelregions *labelregions ) } /** - * vips_labelregions: + * vips_labelregions: (method) * @in: image to test * @mask: write labelled regions here * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/morphology/morph.c b/libvips/morphology/morph.c index 5b38d00e..d19833a0 100644 --- a/libvips/morphology/morph.c +++ b/libvips/morphology/morph.c @@ -168,9 +168,9 @@ vips_morph_init( VipsMorph *morph ) } /** - * vips_morph: + * vips_morph: (method) * @in: input image - * @out: output image + * @out: (out): output image * @mask: morphology with this mask * @morph: operation to perform * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/morphology/rank.c b/libvips/morphology/rank.c index fea8e211..d0a52851 100644 --- a/libvips/morphology/rank.c +++ b/libvips/morphology/rank.c @@ -447,9 +447,9 @@ vips_rank_init( VipsRank *rank ) } /** - * vips_rank: + * vips_rank: (method) * @in: input image - * @out: output image + * @out: (out): output image * @width: width of region * @height: height of region * @index: select pixel @@ -491,9 +491,9 @@ vips_rank( VipsImage *in, VipsImage **out, } /** - * vips_median: + * vips_median: (method) * @in: input image - * @out: output image + * @out: (out): output image * @size: size of region * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/mosaicing/global_balance.c b/libvips/mosaicing/global_balance.c index 053330b1..4b2ba12d 100644 --- a/libvips/mosaicing/global_balance.c +++ b/libvips/mosaicing/global_balance.c @@ -1802,9 +1802,9 @@ vips_globalbalance_init( VipsGlobalbalance *globalbalance ) } /** - * vips_globalbalance: + * vips_globalbalance: (method) * @in: mosaic to rebuild - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/mosaicing/im_remosaic.c b/libvips/mosaicing/im_remosaic.c index 8d8729e0..c90db327 100644 --- a/libvips/mosaicing/im_remosaic.c +++ b/libvips/mosaicing/im_remosaic.c @@ -194,9 +194,9 @@ vips_remosaic_init( VipsRemosaic *remosaic ) } /** - * vips_remosaic: + * vips_remosaic: (method) * @in: mosaic to rebuild - * @out: output image + * @out: (out): output image * @old_str: gamma of source images * @new_str: gamma of source images * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/mosaicing/match.c b/libvips/mosaicing/match.c index 60b77594..77b142a4 100644 --- a/libvips/mosaicing/match.c +++ b/libvips/mosaicing/match.c @@ -315,7 +315,7 @@ vips_match_init( VipsMatch *match ) * vips_match: * @ref: reference image * @sec: secondary image - * @out: output image + * @out: (out): output image * @xr1: first reference tie-point * @yr1: first reference tie-point * @xs1: first secondary tie-point diff --git a/libvips/mosaicing/merge.c b/libvips/mosaicing/merge.c index d003deab..ad21e2e3 100644 --- a/libvips/mosaicing/merge.c +++ b/libvips/mosaicing/merge.c @@ -168,7 +168,7 @@ vips_merge_init( VipsMerge *merge ) * vips_merge: * @ref: reference image * @sec: secondary image - * @out: output image + * @out: (out): output image * @direction: horizontal or vertical merge * @dx: displacement of ref from sec * @dy: displacement of ref from sec diff --git a/libvips/mosaicing/mosaic.c b/libvips/mosaicing/mosaic.c index 629a1132..5ec010ef 100644 --- a/libvips/mosaicing/mosaic.c +++ b/libvips/mosaicing/mosaic.c @@ -314,7 +314,7 @@ vips_mosaic_init( VipsMosaic *mosaic ) * vips_mosaic: * @ref: reference image * @sec: secondary image - * @out: output image + * @out: (out): output image * @direction: horizontal or vertical join * @xref: position in reference image * @yref: position in reference image diff --git a/libvips/resample/affine.c b/libvips/resample/affine.c index 76ff1a9c..e737395c 100644 --- a/libvips/resample/affine.c +++ b/libvips/resample/affine.c @@ -599,9 +599,9 @@ vips_affine_init( VipsAffine *affine ) } /** - * vips_affine: + * vips_affine: (method) * @in: input image - * @out: output image + * @out: (out): output image * @a: transformation matrix coefficient * @b: transformation matrix coefficient * @c: transformation matrix coefficient diff --git a/libvips/resample/interpolate.c b/libvips/resample/interpolate.c index 66a8b24e..a002070d 100644 --- a/libvips/resample/interpolate.c +++ b/libvips/resample/interpolate.c @@ -617,7 +617,7 @@ vips__interpolate_init( void ) } /** - * vips_interpolate_new: + * vips_interpolate_new: (constructor) * @nickname: nickname for interpolator * * Look up an interpolator from a nickname and make one. You need to free the diff --git a/libvips/resample/mapim.c b/libvips/resample/mapim.c index d2524200..ee19c85b 100644 --- a/libvips/resample/mapim.c +++ b/libvips/resample/mapim.c @@ -410,9 +410,9 @@ vips_mapim_init( VipsMapim *mapim ) } /** - * vips_mapim: + * vips_mapim: (method) * @in: input image - * @out: output image + * @out: (out): output image * @index: index image * @...: %NULL-terminated list of optional named arguments * @@ -447,7 +447,7 @@ vips_mapim_init( VipsMapim *mapim ) * Returns: 0 on success, -1 on error */ int -vips_mapim( VipsImage *in, VipsImage **out, VipsImage *index, ... ) +vips_mapim( VipsImage *in, VipsImage **out, VipsImage *index, ... ) { va_list ap; int result; diff --git a/libvips/resample/presample.h b/libvips/resample/presample.h index be563059..0dc98734 100644 --- a/libvips/resample/presample.h +++ b/libvips/resample/presample.h @@ -67,7 +67,7 @@ GType vips_resample_get_type( void ); /* The max size of the vector we use. */ -#define MAX_POINT (50) +#define MAX_POINT (2000) int vips_reduce_get_points( VipsKernel kernel, double shrink ); void vips_reduce_make_mask( double *c, diff --git a/libvips/resample/quadratic.c b/libvips/resample/quadratic.c index 8db0fd6a..06363f1a 100644 --- a/libvips/resample/quadratic.c +++ b/libvips/resample/quadratic.c @@ -363,9 +363,9 @@ vips_quadratic_init( VipsQuadratic *quadratic ) } /** - * vips_quadratic: + * vips_quadratic: (method) * @in: input image - * @out: output image + * @out: (out): output image * @coeff: horizontal quadratic * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/resample/reduce.c b/libvips/resample/reduce.c index 6f76ade8..729a4d3a 100644 --- a/libvips/resample/reduce.c +++ b/libvips/resample/reduce.c @@ -183,9 +183,9 @@ vips_reduce_init( VipsReduce *reduce ) } /** - * vips_reduce: + * vips_reduce: (method) * @in: input image - * @out: output image + * @out: (out): output image * @hshrink: horizontal shrink * @vshrink: vertical shrink * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/resample/reduceh.cpp b/libvips/resample/reduceh.cpp index 6372ce41..a13ad0d6 100644 --- a/libvips/resample/reduceh.cpp +++ b/libvips/resample/reduceh.cpp @@ -57,17 +57,6 @@ #include "presample.h" #include "templates.h" -/** - * VipsKernel: - * @VIPS_KERNEL_NEAREST: nearest-neighbour - * @VIPS_KERNEL_LINEAR: linear interpolation - * @VIPS_KERNEL_CUBIC: cubic interpolation - * @VIPS_KERNEL_LANCZOS2: lanczos2 interpolation - * @VIPS_KERNEL_LANCZOS3: lanczos3 interpolation - * - * 1D resampling kernels. - */ - typedef struct _VipsReduceh { VipsResample parent_instance; @@ -465,7 +454,7 @@ vips_reduceh_build( VipsObject *object ) */ reduceh->n_point = vips_reduce_get_points( reduceh->kernel, reduceh->hshrink ); - g_info( "%d point mask", reduceh->n_point ); + g_info( "reduceh: %d point mask", reduceh->n_point ); if( reduceh->n_point > MAX_POINT ) { vips_error( object_class->nickname, "%s", _( "reduce factor too large" ) ); @@ -610,9 +599,9 @@ vips_reduceh_init( VipsReduceh *reduceh ) } /** - * vips_reduceh: + * vips_reduceh: (method) * @in: input image - * @out: output image + * @out: (out): output image * @hshrink: horizontal reduce * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/resample/reducev.cpp b/libvips/resample/reducev.cpp index 24671621..d0cf278e 100644 --- a/libvips/resample/reducev.cpp +++ b/libvips/resample/reducev.cpp @@ -781,7 +781,7 @@ vips_reducev_raw( VipsReducev *reducev, VipsImage *in, VipsImage **out ) if( in->BandFmt == VIPS_FORMAT_UCHAR && vips_vector_isenabled() && !vips_reducev_compile( reducev ) ) { - g_info( "using vector path" ); + g_info( "reducev: using vector path" ); generate = vips_reducev_vector_gen; } @@ -848,12 +848,12 @@ vips_reducev_build( VipsObject *object ) reducev->n_point = vips_reduce_get_points( reducev->kernel, reducev->vshrink ); + g_info( "reducev: %d point mask", reducev->n_point ); if( reducev->n_point > MAX_POINT ) { vips_error( object_class->nickname, "%s", _( "reduce factor too large" ) ); return( -1 ); } - g_info( "%d point mask", reducev->n_point ); /* Unpack for processing. */ @@ -964,9 +964,9 @@ vips_reducev_init( VipsReducev *reducev ) } /** - * vips_reducev: + * vips_reducev: (method) * @in: input image - * @out: output image + * @out: (out): output image * @vshrink: horizontal reduce * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/resample/resize.c b/libvips/resample/resize.c index d6c6abda..583cfae7 100644 --- a/libvips/resample/resize.c +++ b/libvips/resample/resize.c @@ -115,22 +115,26 @@ G_DEFINE_TYPE( VipsResize, vips_resize, VIPS_TYPE_RESAMPLE ); static int vips_resize_int_shrink( VipsResize *resize, double scale ) { + int shrink; + if( scale > 1.0 ) - return( 1 ); + shrink = 1; + else + switch( resize->kernel ) { + case VIPS_KERNEL_NEAREST: + shrink = 1; - switch( resize->kernel ) { - case VIPS_KERNEL_NEAREST: - return( 1 ); + case VIPS_KERNEL_LINEAR: + case VIPS_KERNEL_CUBIC: + default: + shrink = VIPS_FLOOR( 1.0 / scale ); - case VIPS_KERNEL_LINEAR: - case VIPS_KERNEL_CUBIC: - default: - return( VIPS_FLOOR( 1.0 / scale ) ); + case VIPS_KERNEL_LANCZOS2: + case VIPS_KERNEL_LANCZOS3: + shrink = VIPS_MAX( 1, VIPS_FLOOR( 1.0 / (scale * 2) ) ); + } - case VIPS_KERNEL_LANCZOS2: - case VIPS_KERNEL_LANCZOS3: - return( VIPS_MAX( 1, VIPS_FLOOR( 1.0 / (scale * 2) ) ) ); - } + return( shrink ); } /* Suggest a VipsInterpolate which corresponds to a VipsKernel. We use @@ -238,7 +242,17 @@ vips_resize_build( VipsObject *object ) return( -1 ); vips_object_local( object, interpolate ); - if( hscale > 1.0 && + if( resize->kernel == VIPS_KERNEL_NEAREST && + hscale == VIPS_FLOOR( hscale ) && + vscale == VIPS_FLOOR( vscale ) ) { + /* Fast, integral nearest neighbour enlargement + */ + if( vips_zoom( in, &t[4], VIPS_FLOOR( hscale ), + VIPS_FLOOR( vscale ), NULL ) ) + return( -1 ); + in = t[4]; + } + else if( hscale > 1.0 && vscale > 1.0 ) { g_info( "residual scale %g x %g", hscale, vscale ); if( vips_affine( in, &t[4], @@ -352,9 +366,9 @@ vips_resize_init( VipsResize *resize ) } /** - * vips_resize: + * vips_resize: (method) * @in: input image - * @out: output image + * @out: (out): output image * @scale: scale factor * @...: %NULL-terminated list of optional named arguments * @@ -382,7 +396,7 @@ vips_resize_init( VipsResize *resize ) * a #VipsInterpolate selected depending on @kernel. It will use * #VipsInterpolateBicubic for #VIPS_KERNEL_CUBIC and above. * - * vips_resize() normally maintains the image apect ratio. If you set + * vips_resize() normally maintains the image aspect ratio. If you set * @vscale, that factor is used for the vertical scale and @scale for the * horizontal. * diff --git a/libvips/resample/shrink.c b/libvips/resample/shrink.c index e97fb3c1..f675ab49 100644 --- a/libvips/resample/shrink.c +++ b/libvips/resample/shrink.c @@ -171,9 +171,9 @@ vips_shrink_init( VipsShrink *shrink ) } /** - * vips_shrink: + * vips_shrink: (method) * @in: input image - * @out: output image + * @out: (out): output image * @hshrink: horizontal shrink * @vshrink: vertical shrink * @...: %NULL-terminated list of optional named arguments diff --git a/libvips/resample/shrinkh.c b/libvips/resample/shrinkh.c index e44f8352..97678e8f 100644 --- a/libvips/resample/shrinkh.c +++ b/libvips/resample/shrinkh.c @@ -342,9 +342,9 @@ vips_shrinkh_init( VipsShrinkh *shrink ) } /** - * vips_shrinkh: + * vips_shrinkh: (method) * @in: input image - * @out: output image + * @out: (out): output image * @hshrink: horizontal shrink * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/resample/shrinkv.c b/libvips/resample/shrinkv.c index bf011685..13da3218 100644 --- a/libvips/resample/shrinkv.c +++ b/libvips/resample/shrinkv.c @@ -470,9 +470,9 @@ vips_shrinkv_init( VipsShrinkv *shrink ) } /** - * vips_shrinkv: + * vips_shrinkv: (method) * @in: input image - * @out: output image + * @out: (out): output image * @vshrink: vertical shrink * @...: %NULL-terminated list of optional named arguments * diff --git a/libvips/resample/similarity.c b/libvips/resample/similarity.c index 89c0c6c4..35312072 100644 --- a/libvips/resample/similarity.c +++ b/libvips/resample/similarity.c @@ -229,9 +229,9 @@ vips_similarity_init( VipsSimilarity *similarity ) } /** - * vips_similarity: + * vips_similarity: (method) * @in: input image - * @out: output image + * @out: (out): output image * @...: %NULL-terminated list of optional named arguments * * Optional arguments: diff --git a/libvips/resample/thumbnail.c b/libvips/resample/thumbnail.c index 672c7b1a..211d09d1 100644 --- a/libvips/resample/thumbnail.c +++ b/libvips/resample/thumbnail.c @@ -751,7 +751,7 @@ vips_thumbnail_file_init( VipsThumbnailFile *file ) /** * vips_thumbnail: * @filename: file to read from - * @out: output image + * @out: (out): output image * @width: target width in pixels * @...: %NULL-terminated list of optional named arguments * @@ -925,9 +925,9 @@ vips_thumbnail_buffer_init( VipsThumbnailBuffer *buffer ) /** * vips_thumbnail_buffer: - * @buf: memory area to load - * @len: size of memory area - * @out: output image + * @buf: (array length=len) (element-type guint8): memory area to load + * @len: (type gsize): size of memory area + * @out: (out): output image * @width: target width in pixels * @...: %NULL-terminated list of optional named arguments * @@ -1040,9 +1040,9 @@ vips_thumbnail_image_init( VipsThumbnailImage *image ) } /** - * vips_thumbnail_image: + * vips_thumbnail_image: (method) * @in: input image - * @out: output image + * @out: (out): output image * @width: target width in pixels * @...: %NULL-terminated list of optional named arguments * diff --git a/m4/ax_gcc_var_attribute.m4 b/m4/ax_gcc_var_attribute.m4 new file mode 100644 index 00000000..47635d46 --- /dev/null +++ b/m4/ax_gcc_var_attribute.m4 @@ -0,0 +1,141 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_gcc_var_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_VAR_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's variable +# attributes; many other compilers also provide variable attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_VAR_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_var_attribute_ +# variable. +# +# The macro currently supports the following variable attributes: +# +# aligned +# cleanup +# common +# nocommon +# deprecated +# mode +# packed +# tls_model +# unused +# used +# vector_size +# weak +# dllimport +# dllexport +# init_priority +# +# Unsupported variable attributes will be tested against a global integer +# variable and without any arguments given to the attribute itself; the +# result of this check might be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 5 + +AC_DEFUN([AX_GCC_VAR_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_var_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [aligned], [ + int foo __attribute__(($1(32))); + ], + [cleanup], [ + int bar(int *t) { return *t; }; + ], + [common], [ + int foo __attribute__(($1)); + ], + [nocommon], [ + int foo __attribute__(($1)); + ], + [deprecated], [ + int foo __attribute__(($1)) = 0; + ], + [mode], [ + long foo __attribute__(($1(word))); + ], + [packed], [ + struct bar { + int baz __attribute__(($1)); + }; + ], + [tls_model], [ + __thread int bar1 __attribute__(($1("global-dynamic"))); + __thread int bar2 __attribute__(($1("local-dynamic"))); + __thread int bar3 __attribute__(($1("initial-exec"))); + __thread int bar4 __attribute__(($1("local-exec"))); + ], + [unused], [ + int foo __attribute__(($1)); + ], + [used], [ + int foo __attribute__(($1)); + ], + [vector_size], [ + int foo __attribute__(($1(16))); + ], + [weak], [ + int foo __attribute__(($1)); + ], + [dllimport], [ + int foo __attribute__(($1)); + ], + [dllexport], [ + int foo __attribute__(($1)); + ], + [init_priority], [ + struct bar { bar() {} ~bar() {} }; + bar b __attribute__(($1(65535/2))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo __attribute__(($1)); + ] + )], [ + m4_case([$1], + [cleanup], [ + int foo __attribute__(($1(bar))) = 0; + foo = foo + 1; + ], + [] + )]) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_VAR_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' variable attribute])], []) + + AS_VAR_POPDEF([ac_var]) +])