static void * vips_reducev_start( VipsImage *out, void *a, void *b ) { VipsImage *in = (VipsImage *) a; VipsReducev *reducev = (VipsReducev *) b; int sz = VIPS_IMAGE_N_ELEMENTS( in ); Sequence *seq; if( !(seq = VIPS_NEW( out, Sequence )) ) return( NULL ); /* Init! */ seq->reducev = reducev; seq->ir = NULL; seq->t1 = NULL; seq->t2 = NULL; /* Attach region and arrays. */ seq->ir = vips_region_new( in ); seq->t1 = VIPS_ARRAY( NULL, sz, signed short ); seq->t2 = VIPS_ARRAY( NULL, sz, signed short ); if( !seq->ir || !seq->t1 || !seq->t2 ) { vips_reducev_stop( seq, NULL, NULL ); return( NULL ); } return( seq ); }
static int vips2csv( VipsImage *in, FILE *fp, const char *sep ) { int w = VIPS_IMAGE_N_ELEMENTS( in ); int es = VIPS_IMAGE_SIZEOF_ELEMENT( in ); int x, y; VipsPel *p; p = in->data; for( y = 0; y < in->Ysize; y++ ) { for( x = 0; x < w; x++ ) { if( x > 0 ) fprintf( fp, "%s", sep ); switch( in->BandFmt ) { case VIPS_FORMAT_UCHAR: PRINT_INT( unsigned char ); break; case VIPS_FORMAT_CHAR: PRINT_INT( char ); break; case VIPS_FORMAT_USHORT: PRINT_INT( unsigned short ); break; case VIPS_FORMAT_SHORT: PRINT_INT( short ); break; case VIPS_FORMAT_UINT: PRINT_INT( unsigned int ); break; case VIPS_FORMAT_INT: PRINT_INT( int ); break; case VIPS_FORMAT_FLOAT: PRINT_FLOAT( float ); break; case VIPS_FORMAT_DOUBLE: PRINT_FLOAT( double ); break; case VIPS_FORMAT_COMPLEX: PRINT_COMPLEX( float ); break; case VIPS_FORMAT_DPCOMPLEX: PRINT_COMPLEX( double ); break; default: g_assert( 0 ); } p += es; } fprintf( fp, "\n" ); } return( 0 ); }