add get/set array of image from GValue

This commit is contained in:
John Cupitt 2014-04-10 09:21:29 +01:00
parent 3faf9892c5
commit b27c7a40ef
3 changed files with 51 additions and 0 deletions

View File

@ -56,6 +56,10 @@ typedef void *(*VipsSListMap2Fn)( void *, void *, void * );
typedef void *(*VipsSListMap4Fn)( void *, void *, void *, void *, void * );
typedef void *(*VipsSListFold2Fn)( void *, void *, void *, void * );
/* We need to fwd ref this in many places.
*/
typedef struct _VipsImage VipsImage;
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -188,6 +188,9 @@ void *vips_value_get_array( const GValue *value,
double *vips_value_get_array_double( const GValue *value, int *n );
int vips_value_set_array_double( GValue *value, const double *array, int n );
VipsImage **vips_value_get_array_image( const GValue *value, int *n );
int vips_value_set_array_image( GValue *value, const VipsImage **array, int n );
int *vips_value_get_array_int( const GValue *value, int *n );
int vips_value_set_array_int( GValue *value, const int *array, int n );

View File

@ -1272,6 +1272,50 @@ vips_value_set_array_double( GValue *value, const double *array, int n )
return( 0 );
}
/**
* vips_value_get_array_image:
* @value: %GValue to get from
* @n: (allow-none): return the number of elements here, optionally
*
* Return the start of the array of images held by @value.
* optionally return the number of elements in @n.
*
* See also: vips_array_image_set().
*
* Returns: (transfer none): The array address.
*/
VipsImage **
vips_value_get_array_image( const GValue *value, int *n )
{
return( vips_value_get_array( value, n, NULL, NULL ) );
}
/**
* vips_value_set_array_image:
* @value: (out): %GValue to get from
* @array: (array length=n): array of doubles
* @n: the number of elements
*
* Set @value to hold a copy of @array. Pass in the array length in @n.
*
* See also: vips_array_image_get().
*
* Returns: 0 on success, -1 otherwise.
*/
int
vips_value_set_array_image( GValue *value, const VipsImage **array, int n )
{
VipsImage **array_copy;
g_value_init( value, VIPS_TYPE_ARRAY_IMAGE );
vips_value_set_array( value, n, VIPS_TYPE_ARRAY_IMAGE,
sizeof( VipsImage * ) );
array_copy = vips_value_get_array_image( value, NULL );
memcpy( array_copy, array, n * sizeof( VipsImage * ) );
return( 0 );
}
/**
* vips_value_get_array_object: (skip)
* @value: %GValue to get from