/* The inverse: take ink to a vec of double. Used in the vips7 compat * wrappers. Result valid while im is valid. */ double * vips__ink_to_vector( const char *domain, VipsImage *im, VipsPel *ink, int *n ) { VipsImage **t = (VipsImage **) vips_object_local_array( VIPS_OBJECT( im ), 6 ); double *result; #ifdef VIPS_DEBUG printf( "vips__ink_to_vector: starting\n" ); #endif /*VIPS_DEBUG*/ /* Wrap a VipsImage around ink. */ t[0] = vips_image_new_from_memory( ink, 1, 1, VIPS_IMAGE_SIZEOF_PEL( im ), VIPS_FORMAT_UCHAR ); if( vips_copy( t[0], &t[1], "bands", im->Bands, "format", im->BandFmt, "coding", im->Coding, "interpretation", im->Type, NULL ) ) return( NULL ); /* The image may be coded .. unpack to double. */ if( vips_image_decode( t[1], &t[2] ) || vips_cast( t[2], &t[3], VIPS_FORMAT_DOUBLE, NULL ) ) return( NULL ); /* To a mem buffer, then copy to out. */ if( !(t[4] = vips_image_new_memory()) || vips_image_write( t[3], t[4] ) ) return( NULL ); if( !(result = VIPS_ARRAY( im, t[4]->Bands, double )) ) return( NULL ); memcpy( result, t[4]->data, VIPS_IMAGE_SIZEOF_PEL( t[4] ) ); *n = t[4]->Bands; #ifdef VIPS_DEBUG { int i; printf( "vips__ink_to_vector:\n" ); printf( "\tink = " ); for( i = 0; i < n; i++ ) printf( "%d ", ink[i] ); printf( "\n" ); printf( "\tvec = " ); for( i = 0; i < *n; i++ ) printf( "%d ", result[i] ); printf( "\n" ); } #endif /*VIPS_DEBUG*/ return( result ); }
static int vips_bandary_build( VipsObject *object ) { VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object ); VipsBandaryClass *class = VIPS_BANDARY_GET_CLASS( object ); VipsConversion *conversion = VIPS_CONVERSION( object ); VipsBandary *bandary = VIPS_BANDARY( object ); int i; VipsImage **decode; VipsImage **format; VipsImage **size; if( VIPS_OBJECT_CLASS( vips_bandary_parent_class )->build( object ) ) return( -1 ); if( bandary->n <= 0 ) { vips_error( object_class->nickname, "%s", _( "no input images" ) ); return( -1 ); } if( bandary->n > MAX_INPUT_IMAGES ) { vips_error( object_class->nickname, "%s", _( "too many input images" ) ); return( -1 ); } decode = (VipsImage **) vips_object_local_array( object, bandary->n ); format = (VipsImage **) vips_object_local_array( object, bandary->n ); size = (VipsImage **) vips_object_local_array( object, bandary->n ); for( i = 0; i < bandary->n; i++ ) if( vips_image_decode( bandary->in[i], &decode[i] ) ) return( -1 ); if( vips__formatalike_vec( decode, format, bandary->n ) || vips__sizealike_vec( format, size, bandary->n ) ) return( -1 ); bandary->ready = size; if( vips_image_pipeline_array( conversion->out, VIPS_DEMAND_STYLE_THINSTRIP, bandary->ready ) ) return( -1 ); conversion->out->Bands = bandary->out_bands; if( class->format_table ) conversion->out->BandFmt = class->format_table[bandary->ready[0]->BandFmt]; if( vips_image_generate( conversion->out, vips_start_many, vips_bandary_gen, vips_stop_many, bandary->ready, bandary ) ) return( -1 ); return( 0 ); }
static int vips_statistic_build( VipsObject *object ) { VipsStatistic *statistic = VIPS_STATISTIC( object ); VipsStatisticClass *sclass = VIPS_STATISTIC_GET_CLASS( statistic ); VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 ); #ifdef DEBUG printf( "vips_statistic_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ if( VIPS_OBJECT_CLASS( vips_statistic_parent_class )->build( object ) ) return( -1 ); statistic->ready = statistic->in; if( vips_image_decode( statistic->ready, &t[0] ) ) return( -1 ); statistic->ready = t[0]; /* If there's a format table, cast the input. */ if( sclass->format_table ) { if( vips_cast( statistic->ready, &t[1], sclass->format_table[statistic->in->BandFmt], NULL ) ) return( -1 ); statistic->ready = t[1]; } if( vips_sink( statistic->ready, vips_statistic_scan_start, vips_statistic_scan, vips_statistic_scan_stop, statistic, NULL ) ) return( -1 ); return( 0 ); }