easier array arg creation
added stdarg array double creator, used the _new as well, small other fixes
This commit is contained in:
parent
777d1ea554
commit
3216fddc92
@ -280,19 +280,10 @@ vips_linearv( VipsImage *in, VipsImage **out,
|
|||||||
{
|
{
|
||||||
VipsArea *area_a;
|
VipsArea *area_a;
|
||||||
VipsArea *area_b;
|
VipsArea *area_b;
|
||||||
double *array;
|
|
||||||
int result;
|
int result;
|
||||||
int i;
|
|
||||||
|
|
||||||
area_a = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
|
area_a = (VipsArea *) vips_array_double_new( a, n );
|
||||||
array = (double *) area_a->data;
|
area_b = (VipsArea *) vips_array_double_new( b, n );
|
||||||
for( i = 0; i < n; i++ )
|
|
||||||
array[i] = a[i];
|
|
||||||
|
|
||||||
area_b = vips_area_new_array( G_TYPE_DOUBLE, sizeof( double ), n );
|
|
||||||
array = (double *) area_b->data;
|
|
||||||
for( i = 0; i < n; i++ )
|
|
||||||
array[i] = b[i];
|
|
||||||
|
|
||||||
result = vips_call_split( "linear", ap, in, out, area_a, area_b );
|
result = vips_call_split( "linear", ap, in, out, area_a, area_b );
|
||||||
|
|
||||||
@ -306,8 +297,8 @@ vips_linearv( VipsImage *in, VipsImage **out,
|
|||||||
* vips_linear:
|
* vips_linear:
|
||||||
* @in: image to transform
|
* @in: image to transform
|
||||||
* @out: output image
|
* @out: output image
|
||||||
* @a: array of constants for multiplication
|
* @a: (array length=n): array of constants for multiplication
|
||||||
* @b: array of constants for addition
|
* @b: (array length=n): array of constants for addition
|
||||||
* @n: length of constant arrays
|
* @n: length of constant arrays
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
|
@ -2147,14 +2147,10 @@ im_rightshift_size( IMAGE *in, IMAGE *out,
|
|||||||
int
|
int
|
||||||
im_Lab2XYZ_temp( IMAGE *in, IMAGE *out, double X0, double Y0, double Z0 )
|
im_Lab2XYZ_temp( IMAGE *in, IMAGE *out, double X0, double Y0, double Z0 )
|
||||||
{
|
{
|
||||||
double ary[3];
|
|
||||||
VipsArea *temp;
|
VipsArea *temp;
|
||||||
VipsImage *x;
|
VipsImage *x;
|
||||||
|
|
||||||
ary[0] = X0;
|
temp = (VipsArea *) vips_array_double_newv( 3, X0, Y0, Z0 );
|
||||||
ary[1] = Y0;
|
|
||||||
ary[2] = Z0;
|
|
||||||
temp = (VipsArea *) vips_array_double_new( ary, 3 );
|
|
||||||
if( vips_Lab2XYZ( in, &x, "temp", temp, NULL ) ) {
|
if( vips_Lab2XYZ( in, &x, "temp", temp, NULL ) ) {
|
||||||
vips_area_unref( temp );
|
vips_area_unref( temp );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
@ -569,6 +569,10 @@ strip_allocate( VipsThreadState *state, void *a, gboolean *stop )
|
|||||||
|
|
||||||
VipsRect image;
|
VipsRect image;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf( "strip_allocate\n" );
|
||||||
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
image.left = 0;
|
image.left = 0;
|
||||||
image.top = 0;
|
image.top = 0;
|
||||||
image.width = layer->width;
|
image.width = layer->width;
|
||||||
@ -589,6 +593,10 @@ strip_allocate( VipsThreadState *state, void *a, gboolean *stop )
|
|||||||
|
|
||||||
if( vips_rect_isempty( &state->pos ) ) {
|
if( vips_rect_isempty( &state->pos ) ) {
|
||||||
*stop = TRUE;
|
*stop = TRUE;
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf( "strip_allocate: done\n" );
|
||||||
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,6 +711,10 @@ strip_work( VipsThreadState *state, void *a )
|
|||||||
VipsImage *x;
|
VipsImage *x;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf( "strip_work\n" );
|
||||||
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
if( tile_name( layer, buf,
|
if( tile_name( layer, buf,
|
||||||
state->x / dz->tile_size, state->y / dz->tile_size ) )
|
state->x / dz->tile_size, state->y / dz->tile_size ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -732,12 +744,20 @@ strip_work( VipsThreadState *state, void *a )
|
|||||||
x = z;
|
x = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf( "strip_work: writing to %s\n", buf );
|
||||||
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
if( vips_image_write_to_file( x, buf ) ) {
|
if( vips_image_write_to_file( x, buf ) ) {
|
||||||
g_object_unref( x );
|
g_object_unref( x );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
g_object_unref( x );
|
g_object_unref( x );
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf( "strip_work: success\n" );
|
||||||
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +339,28 @@ int vips_object_get_argument_priority( VipsObject *object, const char *name );
|
|||||||
#define VIPS_ARGUMENT_FOR_ALL_END } }
|
#define VIPS_ARGUMENT_FOR_ALL_END } }
|
||||||
|
|
||||||
/* And some macros to collect args from a va list.
|
/* And some macros to collect args from a va list.
|
||||||
|
*
|
||||||
|
* Use something like this:
|
||||||
|
|
||||||
|
GParamSpec *pspec;
|
||||||
|
VipsArgumentClass *argument_class;
|
||||||
|
VipsArgumentInstance *argument_instance;
|
||||||
|
|
||||||
|
if( vips_object_get_argument( VIPS_OBJECT( operation ), name,
|
||||||
|
&pspec, &argument_class, &argument_instance ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
VIPS_ARGUMENT_COLLECT_SET( pspec, argument_class, ap );
|
||||||
|
|
||||||
|
GValue value holds the value of an input argument, do
|
||||||
|
something with it
|
||||||
|
|
||||||
|
VIPS_ARGUMENT_COLLECT_GET( pspec, argument_class, ap );
|
||||||
|
|
||||||
|
void **arg points to where to write an output argument
|
||||||
|
|
||||||
|
VIPS_ARGUMENT_COLLECT_END
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define VIPS_ARGUMENT_COLLECT_SET( PSPEC, ARG_CLASS, AP ) \
|
#define VIPS_ARGUMENT_COLLECT_SET( PSPEC, ARG_CLASS, AP ) \
|
||||||
if( (ARG_CLASS->flags & VIPS_ARGUMENT_INPUT) ) { \
|
if( (ARG_CLASS->flags & VIPS_ARGUMENT_INPUT) ) { \
|
||||||
|
@ -137,6 +137,7 @@ GType vips_blob_get_type( void );
|
|||||||
#define VIPS_TYPE_ARRAY_DOUBLE (vips_array_double_get_type())
|
#define VIPS_TYPE_ARRAY_DOUBLE (vips_array_double_get_type())
|
||||||
typedef VipsArea VipsArrayDouble;
|
typedef VipsArea VipsArrayDouble;
|
||||||
VipsArrayDouble *vips_array_double_new( const double *array, int n );
|
VipsArrayDouble *vips_array_double_new( const double *array, int n );
|
||||||
|
VipsArrayDouble *vips_array_double_newv( int n, ... );
|
||||||
GType vips_array_double_get_type( void );
|
GType vips_array_double_get_type( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
#include <vips/internal.h>
|
#include <vips/internal.h>
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
#include <vips/internal.h>
|
#include <vips/internal.h>
|
||||||
@ -135,7 +136,7 @@ vips_thing_get_type( void )
|
|||||||
* function. It also keeps a count and a GType, so the area can be an array.
|
* function. It also keeps a count and a GType, so the area can be an array.
|
||||||
*
|
*
|
||||||
* This type is used for things like passing an array of double or an array of
|
* This type is used for things like passing an array of double or an array of
|
||||||
* VipsObject pointers to operations, and for reference-countred immutable
|
* VipsObject pointers to operations, and for reference-counted immutable
|
||||||
* strings.
|
* strings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -939,6 +940,37 @@ vips_array_double_new( const double *array, int n )
|
|||||||
return( area );
|
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:
|
* vips_value_get_array_double:
|
||||||
* @value: %GValue to get from
|
* @value: %GValue to get from
|
||||||
|
Loading…
Reference in New Issue
Block a user