From 3276c636f7ff76132c8bc4ae2203bc60aecdfdf7 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 6 Aug 2012 16:06:17 +0100 Subject: [PATCH] add support for VipsInterpolate to the C++ API quick and ugly hack, this will be replaced in vips8 necessary to get affinei and affinei_all in Python --- TODO | 2 ++ libvips/deprecated/dispatch_types.c | 8 +++++--- libvips/include/vips/internal.h | 2 ++ libvipsCC/VImage.cc | 2 ++ tools/vips.c | 12 ++++++++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 68d0d9be..d1ec1ca6 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ - C++/Python need an im_affinei_all, perhaps with a char* for the interpolator? + test new affinei C++ stuff, esp freeing + blocking bugs ============= diff --git a/libvips/deprecated/dispatch_types.c b/libvips/deprecated/dispatch_types.c index de103d7a..9ff4f932 100644 --- a/libvips/deprecated/dispatch_types.c +++ b/libvips/deprecated/dispatch_types.c @@ -870,9 +870,11 @@ im_type_desc im__output_gvalue = { }; /* Init function for input interpolate. + * + * This is used as a helper function by the C++ interface, so amke it public. */ -static int -input_interpolate_init( im_object *obj, char *str ) +int +vips__input_interpolate_init( im_object *obj, char *str ) { GType type = g_type_from_name( "VipsInterpolate" ); VipsObjectClass *class = VIPS_OBJECT_CLASS( g_type_class_ref( type ) ); @@ -903,7 +905,7 @@ im_type_desc im__input_interpolate = { IM_TYPE_INTERPOLATE, 0, /* No storage required */ IM_TYPE_ARG, /* It requires a command-line arg */ - input_interpolate_init, /* Init function */ + vips__input_interpolate_init, /* Init function */ input_interpolate_dest /* Destroy function */ }; diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index 00971e86..a5f4ae9a 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -304,6 +304,8 @@ guint64 vips__parse_size( const char *size_string ); IMAGE *vips__deprecated_open_read( const char *filename, gboolean sequential ); IMAGE *vips__deprecated_open_write( const char *filename ); +int vips__input_interpolate_init( im_object *obj, char *str ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvipsCC/VImage.cc b/libvipsCC/VImage.cc index dff543a4..c1ee9885 100644 --- a/libvipsCC/VImage.cc +++ b/libvipsCC/VImage.cc @@ -484,6 +484,8 @@ Vargv::~Vargv() io->vec = NULL; } } + else if( strcmp( ty->type, IM_TYPE_INTERPOLATE ) == 0 ) + g_object_unref( base[i] ); } } diff --git a/tools/vips.c b/tools/vips.c index 63be2fa2..afff7169 100644 --- a/tools/vips.c +++ b/tools/vips.c @@ -332,7 +332,8 @@ vips2cpp( im_type_desc *ty ) IM_TYPE_DISPLAY, IM_TYPE_IMAGEVEC, IM_TYPE_DOUBLEVEC, - IM_TYPE_INTVEC + IM_TYPE_INTVEC, + IM_TYPE_INTERPOLATE }; /* Corresponding C++ types. @@ -348,7 +349,8 @@ vips2cpp( im_type_desc *ty ) "VDisplay", "std::vector", "std::vector", - "std::vector" + "std::vector", + "char*" }; for( k = 0; k < IM_NUMBER( vtypes ); k++ ) @@ -771,6 +773,12 @@ print_cppdef( im_function *fn ) else if( strcmp( ty->type, IM_TYPE_INTVEC ) == 0 ) print_invec( j, fn->argv[j].name, "im_intvec_object", "int", "" ); + else if( strcmp( ty->type, IM_TYPE_INTERPOLATE ) == 0 ) { + printf( "\tif( vips__input_interpolate_init( " + "&_vec.data(%d), %s ) )\n", + j, fn->argv[j].name ); + printf( "\t\tverror();\n" ); + } else /* Just use vips2cpp(). */