Merge pull request #1366 from kleisauke/vector-array-int

Support std::vector within the image_get/set_array_int functions
This commit is contained in:
John Cupitt 2019-07-16 09:49:24 +01:00 committed by GitHub
commit db5671ecbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -357,6 +357,13 @@ public:
vips_image_set_array_int( this->get_image(), field, value, n );
}
void
set( const char *field, std::vector<int> value )
{
vips_image_set_array_int( this->get_image(), field, &value[0],
static_cast<int>( value.size() ) );
}
void
set( const char *field, double value )
{
@ -401,6 +408,20 @@ public:
throw( VError() );
}
std::vector<int>
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<int> vector( array, array + length );
return( vector );
}
double
get_double( const char *field ) const
{