add vips_array_image_empty()/_append()
to help bindings without init from array
This commit is contained in:
parent
36617bd2e4
commit
5160010eda
@ -482,6 +482,9 @@ int vips_system( const char *cmd_format, ... )
|
||||
*/
|
||||
VipsArrayImage *vips_array_image_new( VipsImage **array, int n );
|
||||
VipsArrayImage *vips_array_image_newv( int n, ... );
|
||||
VipsArrayImage *vips_array_image_empty( void );
|
||||
VipsArrayImage *vips_array_image_append( VipsArrayImage *array,
|
||||
VipsImage *image );
|
||||
VipsImage **vips_array_image_get( VipsArrayImage *array, int *n );
|
||||
VipsImage **vips_value_get_array_image( const GValue *value, int *n );
|
||||
void vips_value_set_array_image( GValue *value, int n );
|
||||
|
@ -1205,6 +1205,63 @@ vips_array_image_newv( int n, ... )
|
||||
return( (VipsArrayImage *) area );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_array_image_empty:
|
||||
*
|
||||
* Make an empty image array.
|
||||
* Handy with vips_array_image_add() for bindings
|
||||
* which can't handle object array arguments.
|
||||
*
|
||||
* See also: vips_array_image_add().
|
||||
*
|
||||
* Returns: (transfer full): A new #VipsArrayImage.
|
||||
*/
|
||||
VipsArrayImage *
|
||||
vips_array_image_empty( void )
|
||||
{
|
||||
return( vips_array_image_new( NULL, 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_array_image_append:
|
||||
* @array: (transfer none): append to this
|
||||
* @image: add this
|
||||
*
|
||||
* Make a new #VipsArrayImage, one larger than @array, with @image appended
|
||||
* to the end.
|
||||
* Handy with vips_array_image_empty() for bindings
|
||||
* which can't handle object array arguments.
|
||||
*
|
||||
* See also: vips_array_image_empty().
|
||||
*
|
||||
* Returns: (transfer full): A new #VipsArrayImage.
|
||||
*/
|
||||
VipsArrayImage *
|
||||
vips_array_image_append( VipsArrayImage *array, VipsImage *image )
|
||||
{
|
||||
VipsArea *old_area = VIPS_AREA( array );
|
||||
int n = old_area->n;
|
||||
|
||||
VipsArea *new_area;
|
||||
VipsImage **old_vector;
|
||||
VipsImage **new_vector;
|
||||
int i;
|
||||
|
||||
new_area = vips_area_new_array_object( n + 1 );
|
||||
new_area->type = VIPS_TYPE_IMAGE;
|
||||
|
||||
old_vector = vips_area_get_data( old_area, NULL, NULL, NULL, NULL );
|
||||
new_vector = vips_area_get_data( new_area, NULL, NULL, NULL, NULL );
|
||||
for( i = 0; i < n; i++ ) {
|
||||
new_vector[i] = (VipsImage *) old_vector[i];
|
||||
g_object_ref( new_vector[i] );
|
||||
}
|
||||
new_vector[i] = image;
|
||||
g_object_ref( new_vector[i] );
|
||||
|
||||
return( (VipsArrayImage *) new_area );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_array_image_get:
|
||||
* @array: the #VipsArrayImage to fetch from
|
||||
|
Loading…
x
Reference in New Issue
Block a user