GBoxed almost working

This commit is contained in:
John Cupitt 2014-08-29 18:14:22 +01:00
parent 2ba3a1a674
commit 42dac9209a
3 changed files with 94 additions and 58 deletions

24
TODO
View File

@ -1,3 +1,27 @@
- python:
- add more constructors
- need the filename splitter
- need more writers
- need GBoxed
seems to be almost there!
we have:
a = Vips.array_double_new([1,2,3])
but no VipsArrayDouble type, strangely
VipsThing is there? odd
seems be have spotted that it's just an alias for VipsArea and
elided the type
- can we pick the vipsthumbnail int shrink factor more intelligently?
- vips_resize() should use vipsthumbnail's block/cache/affine/sharpen chain

View File

@ -688,6 +688,70 @@ vips_array_int_get_type( void )
return( type );
}
/**
* vips_array_double_new:
* @array: (array length=n): array of double
* @n: number of doubles
*
* Allocate a new array of doubles and copy @array into it. Free with
* vips_area_unref().
*
* See also: #VipsArea.
*
* Returns: (transfer full): A new #VipsArrayDouble.
*/
VipsArrayDouble *
vips_array_double_new( const double *array, int n )
{
VipsArea *area;
double *array_copy;
area = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
array_copy = vips_area_get_data( area, NULL, NULL, NULL, NULL );
memcpy( array_copy, array, n * sizeof( double ) );
{
int i;
printf( "vips_array_double_new: %p\n", area );
for( i = 0; i < n; i++ )
printf( "\t%d) %g\n", i, array[i] );
}
return( area );
}
/**
* vips_array_double_newv:
* @n: number of doubles
* @...: list of double arguments
*
* Allocate a new array of @n doubles and copy @... into it. Free with
* vips_area_unref().
*
* See also: vips_array_double_new()
*
* Returns: (transfer full): A new #VipsArrayDouble.
*/
VipsArrayDouble *
vips_array_double_newv( int n, ... )
{
va_list ap;
VipsArea *area;
double *array;
int i;
area = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
array = vips_area_get_data( area, NULL, NULL, NULL, NULL );
va_start( ap, n );
for( i = 0; i < n; i++ )
array[i] = va_arg( ap, double );
va_end( ap );
return( area );
}
static void
transform_array_double_g_string( const GValue *src_value, GValue *dest_value )
{
@ -1179,62 +1243,6 @@ vips_value_set_array_int( GValue *value, const int *array, int n )
return( 0 );
}
/**
* vips_array_double_new:
* @array: (array length=n): array of double
* @n: number of doubles
*
* Allocate a new array of doubles and copy @array into it. Free with
* vips_area_unref().
*
* See also: #VipsArea.
*
* Returns: (transfer full): A new #VipsArrayDouble.
*/
VipsArrayDouble *
vips_array_double_new( const double *array, int n )
{
VipsArea *area;
double *array_copy;
area = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
array_copy = vips_area_get_data( area, NULL, NULL, NULL, NULL );
memcpy( array_copy, array, n * sizeof( double ) );
return( area );
}
/**
* vips_array_double_newv:
* @n: number of doubles
* @...: list of double arguments
*
* Allocate a new array of @n doubles and copy @... into it. Free with
* vips_area_unref().
*
* See also: vips_array_double_new()
*
* Returns: (transfer full): A new #VipsArrayDouble.
*/
VipsArrayDouble *
vips_array_double_newv( int n, ... )
{
va_list ap;
VipsArea *area;
double *array;
int i;
area = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
array = vips_area_get_data( area, NULL, NULL, NULL, NULL );
va_start( ap, n );
for( i = 0; i < n; i++ )
array[i] = va_arg( ap, double );
va_end( ap );
return( area );
}
/**
* vips_value_get_array_double:
* @value: %GValue to get from

View File

@ -27,5 +27,9 @@ out = a.add(b)
print 'out =', out
# we need to get GBoxed working for this
#out = a.linear(1, 2)
ones = Vips.array_double_new([1])
twos = Vips.array_double_new([2])
out = out.linear(ones, twos)
out.write_to_file("x.v")