From 42bb8f51b9d5763d512932312997b786f6a052f5 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 15 Jul 2019 15:29:19 +0200 Subject: [PATCH] Support std::vector within the image_get/set_array_int functions --- cplusplus/include/vips/VImage8.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cplusplus/include/vips/VImage8.h b/cplusplus/include/vips/VImage8.h index 0c51de82..3e67896b 100644 --- a/cplusplus/include/vips/VImage8.h +++ b/cplusplus/include/vips/VImage8.h @@ -357,6 +357,13 @@ public: vips_image_set_array_int( this->get_image(), field, value, n ); } + void + set( const char *field, std::vector value ) + { + vips_image_set_array_int( this->get_image(), field, &value[0], + static_cast( value.size() ) ); + } + void set( const char *field, double value ) { @@ -401,6 +408,20 @@ public: throw( VError() ); } + std::vector + get_array_int( const char *field ) const + { + int length; + int *array; + + if( vips_image_get_array_int( this->get_image(), field, &array, &length ) ) + throw( VError() ); + + std::vector vector( array, array + length ); + + return( vector ); + } + double get_double( const char *field ) const {