static int vips_colour_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { VipsRegion **ir = (VipsRegion **) seq; VipsColour *colour = VIPS_COLOUR( b ); VipsColourClass *class = VIPS_COLOUR_GET_CLASS( colour ); VipsRect *r = &or->valid; int i, y; VipsPel *p[MAX_INPUT_IMAGES], *q; for( i = 0; ir[i]; i++ ) if( vips_region_prepare( ir[i], r ) ) return( -1 ); VIPS_GATE_START( "vips_colour_gen: work" ); for( y = 0; y < r->height; y++ ) { for( i = 0; ir[i]; i++ ) p[i] = VIPS_REGION_ADDR( ir[i], r->left, r->top + y ); p[i] = NULL; q = VIPS_REGION_ADDR( or, r->left, r->top + y ); class->process_line( colour, q, p, r->width ); } VIPS_GATE_STOP( "vips_colour_gen: work" ); return( 0 ); }
static int vips_XYZ2scRGB_build( VipsObject *object ) { if( VIPS_OBJECT_CLASS( vips_XYZ2scRGB_parent_class )->build( object ) ) return( -1 ); /* We've converted to sRGB without a profile. We must remove any ICC * profile left over from import or there will be a mismatch between * pixel values and the attached profile. */ vips_image_remove( VIPS_COLOUR( object )->out, VIPS_META_ICC_NAME ); return( 0 ); }
size_t data_length; if( !(data = vips__file_read_name( filename, VIPS_ICC_DIR, &data_length )) ) return( -1 ); vips_image_set_blob( im, VIPS_META_ICC_NAME, (VipsCallbackFn) g_free, data, data_length ); return( 0 ); } static int vips_colour_build( VipsObject *object ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsColour *colour = VIPS_COLOUR( object ); VipsImage **in; VipsImage **extra_bands; VipsImage *out; int i; #ifdef DEBUG printf( "vips_colour_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ if( VIPS_OBJECT_CLASS( vips_colour_parent_class )-> build( object ) )
VipsscRGB2sRGB *scRGB2sRGB = (VipsscRGB2sRGB *) colour; if( scRGB2sRGB->depth == 16 ) vips_scRGB2sRGB_line_16( (unsigned short *) out, (float *) in[0], width ); else vips_scRGB2sRGB_line_8( (VipsPel *) out, (float *) in[0], width ); } static int vips_scRGB2sRGB_build( VipsObject *object ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsscRGB2sRGB *scRGB2sRGB = (VipsscRGB2sRGB *) object; VipsColour *colour = VIPS_COLOUR( scRGB2sRGB ); switch( scRGB2sRGB->depth ) { case 16: colour->interpretation = VIPS_INTERPRETATION_RGB16; colour->format = VIPS_FORMAT_USHORT; break; case 8: colour->interpretation = VIPS_INTERPRETATION_sRGB; colour->format = VIPS_FORMAT_UCHAR; break; default: vips_error( class->nickname, "%s", _( "depth must be 8 or 16" ) );