From 526cf4ec377713d0a5f20c99ed4ac713f70e9930 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 21 Apr 2021 18:48:24 +0200 Subject: [PATCH] C++: add set/get for an array of doubles --- cplusplus/include/vips/VImage8.h | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/cplusplus/include/vips/VImage8.h b/cplusplus/include/vips/VImage8.h index a0f52fa3..76642b77 100644 --- a/cplusplus/include/vips/VImage8.h +++ b/cplusplus/include/vips/VImage8.h @@ -600,6 +600,29 @@ public: static_cast( value.size() ) ); } + /** + * Set the value of an double array metadata item on an image. + * + * A copy of the array is taken. + */ + void + set( const char *field, double *value, int n ) + { + vips_image_set_array_double( this->get_image(), field, value, n ); + } + + /** + * Set the value of an double array metadata item on an image. + * + * A copy of the array is taken. + */ + void + set( const char *field, std::vector value ) + { + vips_image_set_array_double( this->get_image(), field, &value[0], + static_cast( value.size() ) ); + } + /** * Set the value of a double metadata item on an image. */ @@ -695,6 +718,40 @@ public: return( vector ); } + /** + * Get the value of a metadata item as an array of doubles. Do not free + * the result. + * + * If the item is not of this type, an exception is thrown. + */ + void + get_array_double( const char *field, double **out, int *n ) const + { + if( vips_image_get_array_double( this->get_image(), + field, out, n ) ) + throw( VError() ); + } + + /** + * Get the value of a metadata item as an array of doubles. + * + * If the item is not of this type, an exception is thrown. + */ + std::vector + get_array_double( const char *field ) const + { + int length; + double *array; + + if( vips_image_get_array_double( this->get_image(), + field, &array, &length ) ) + throw( VError() ); + + std::vector vector( array, array + length ); + + return( vector ); + } + /** * Get the value of a metadata item as a double. *