diff --git a/ChangeLog b/ChangeLog index c1d6e471..a6b54000 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ - rename vipsthumbnail -o as -f, -o stays as a hidden flag - fix some small leaks - faster openslide load, thanks Benjamin +- add VInterpolate class to cplusplus binding, thanks Lovell 24/12/14 started 7.42.1 - add gobject-2.0 to Requires: in vips and vips-cpp .pc files diff --git a/cplusplus/Makefile.am b/cplusplus/Makefile.am index 2714a5a1..8cf58984 100644 --- a/cplusplus/Makefile.am +++ b/cplusplus/Makefile.am @@ -10,6 +10,7 @@ lib_LTLIBRARIES = libvips-cpp.la libvips_cpp_la_SOURCES = \ VImage.cpp \ + VInterpolate.cpp \ VError.cpp libvips_cpp_la_LDFLAGS = \ diff --git a/cplusplus/VInterpolate.cpp b/cplusplus/VInterpolate.cpp new file mode 100644 index 00000000..2be7be34 --- /dev/null +++ b/cplusplus/VInterpolate.cpp @@ -0,0 +1,77 @@ +/* Object part of VInterpolate class + */ + +/* + + Copyright (C) 1991-2001 The National Gallery + + This program 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 + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include + +#include + +/* +#define VIPS_DEBUG +#define VIPS_DEBUG_VERBOSE + */ + +VIPS_NAMESPACE_START + +VInterpolate +VInterpolate::new_from_name( const char *name, VOption *options ) + throw( VError ) +{ + VipsInterpolate *interp; + + if( !(interp = vips_interpolate_new( name )) ) { + delete options; + throw VError(); + } + delete options; + + VInterpolate out( interp ); + + return( out ); +} + +VOption * +VOption::set( const char *name, VInterpolate value ) +{ + Pair *pair = new Pair( name ); + + pair->input = true; + g_value_init( &pair->value, VIPS_TYPE_INTERPOLATE ); + g_value_set_object( &pair->value, value.get_interpolate() ); + options.push_back( pair ); + + return( this ); +} + +VIPS_NAMESPACE_END diff --git a/cplusplus/examples/resize.cpp b/cplusplus/examples/resize.cpp new file mode 100644 index 00000000..010b34df --- /dev/null +++ b/cplusplus/examples/resize.cpp @@ -0,0 +1,54 @@ +/* + * compile with: + * + * g++ -g -Wall resize.cpp `pkg-config vips-cpp --cflags --libs` + * + */ + +#define DEBUG + +#include + +using namespace vips; + +int +main( int argc, char **argv ) +{ + GOptionContext *context; + GOptionGroup *main_group; + GError *error = NULL; + + if( vips_init( argv[0] ) ) + vips_error_exit( NULL ); + + context = g_option_context_new( "" ); + + main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL ); + g_option_context_set_main_group( context, main_group ); + g_option_context_add_group( context, vips_get_option_group() ); + + if( !g_option_context_parse( context, &argc, &argv, &error ) ) { + if( error ) { + fprintf( stderr, "%s\n", error->message ); + g_error_free( error ); + } + + vips_error_exit( NULL ); + } + +{ + VImage in = VImage::new_from_file( argv[1], + VImage::option()->set( "access", VIPS_ACCESS_SEQUENTIAL ) ); + VInterpolate interp = VInterpolate::new_from_name( "nohalo" ); + + VImage out; + + out = in.resize( 0.2, VImage::option()->set( "interpolate", interp ) ); + + out.write_to_file( argv[2] ); +} + + vips_shutdown(); + + return( 0 ); +} diff --git a/cplusplus/include/vips/Makefile.am b/cplusplus/include/vips/Makefile.am index dd9db403..020aa10d 100644 --- a/cplusplus/include/vips/Makefile.am +++ b/cplusplus/include/vips/Makefile.am @@ -1,6 +1,7 @@ pkginclude_HEADERS = \ VError8.h \ VImage8.h \ + VInterpolate8.h \ vips8 \ vips-operators.h diff --git a/cplusplus/include/vips/VImage8.h b/cplusplus/include/vips/VImage8.h index 4a502e42..7489d232 100644 --- a/cplusplus/include/vips/VImage8.h +++ b/cplusplus/include/vips/VImage8.h @@ -163,6 +163,7 @@ public: }; class VImage; +class VInterpolate; class VOption; class VOption @@ -215,6 +216,7 @@ public: VOption *set( const char *name, double value ); VOption *set( const char *name, const char *value ); VOption *set( const char *name, VImage value ); + 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, VipsBlob *value ); diff --git a/cplusplus/include/vips/VInterpolate8.h b/cplusplus/include/vips/VInterpolate8.h new file mode 100644 index 00000000..a811dcb0 --- /dev/null +++ b/cplusplus/include/vips/VInterpolate8.h @@ -0,0 +1,65 @@ +// VIPS interpolate wrapper + +/* + + 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 + + */ + +#ifndef VIPS_VINTERPOLATE_H +#define VIPS_VINTERPOLATE_H + +#include +#include +#include + +#include + +#include + +VIPS_NAMESPACE_START + +class VInterpolate : VObject +{ +public: + VInterpolate( VipsInterpolate *interpolate, VSteal steal = STEAL ) : + VObject( (VipsObject *) interpolate, steal ) + { + } + + static + VInterpolate new_from_name( const char *name, VOption *options = 0 ) + throw( VError ); + + VipsInterpolate * + get_interpolate() + { + return( (VipsInterpolate *) VObject::get_object() ); + } + +}; + +VIPS_NAMESPACE_END + +#endif /*VIPS_VIMAGE_H*/ diff --git a/cplusplus/include/vips/vips8 b/cplusplus/include/vips/vips8 index 4d697f17..87bce4d2 100644 --- a/cplusplus/include/vips/vips8 +++ b/cplusplus/include/vips/vips8 @@ -39,5 +39,6 @@ #include "VError8.h" #include "VImage8.h" +#include "VInterpolate8.h" #endif /*VIPS_CPLUSPLUS*/