use new converter

This commit is contained in:
John Cupitt 2012-09-27 14:56:51 +01:00
parent d56943f2c2
commit 2065317272
5 changed files with 43 additions and 158 deletions

16
TODO
View File

@ -1,3 +1,16 @@
- add mono as a colourspace? also rad?
- something to test if an image is in a supported colourspace?
at the moment we only look at interpretation, but for things like labq
we should check coding too
labs needs more checks than that
_RGB and _sRGB as well
move colour_convert into a separate file
- im_icc_ac2rc needs doing once we have a general 'convert' operator
- test new icc stuff with lcms1
@ -5,9 +18,6 @@
- should we have a better thing to stop convert_saveable running for vips
images?
- convert_saveable should become a lot simpler with a general colourspace
converter
- why do we need the extra vips_image_write() at the end of
vips_colour_convert_build()? why can't we just g_object_set() x?

View File

@ -566,7 +566,7 @@ vips_colour_convert_class_init( VipsColourConvertClass *class )
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;
vobject_class->nickname = "convert";
vobject_class->nickname = "colour_convert";
vobject_class->description = _( "convert to a new colourspace" );
vobject_class->build = vips_colour_convert_build;
@ -618,7 +618,7 @@ vips_colour_convert( VipsImage *in, VipsImage **out,
int result;
va_start( ap, space );
result = vips_call_split( "convert", ap, in, out, space );
result = vips_call_split( "colour_convert", ap, in, out, space );
va_end( ap );
return( result );

View File

@ -290,70 +290,3 @@ im_col_dE00( float L1, float a1, float b1,
return( dE00 );
}
/* Quick hack wrappers for common colour functions in the new style.
*/
int
vips_argb2rgba( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_call_split( "im_argb2rgba", ap, in, out );
va_end( ap );
return( result );
}
int
vips_Yxy2Lab( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_call_split( "im_Yxy2Lab", ap, in, out );
va_end( ap );
return( result );
}
int
vips_UCS2XYZ( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_call_split( "im_UCS2XYZ", ap, in, out );
va_end( ap );
return( result );
}
int
im__colour_unary( const char *domain,
IMAGE *in, IMAGE *out, VipsType type,
im_wrapone_fn buffer_fn, void *a, void *b )
{
IMAGE *t[1];
if( im_check_uncoded( domain, in ) ||
im_check_bands( domain, in, 3 ) ||
im_open_local_array( out, t, 1, domain, "p" ) ||
im_clip2fmt( in, t[0], IM_BANDFMT_FLOAT ) )
return( -1 );
if( im_cp_desc( out, t[0] ) )
return( -1 );
out->Type = type;
if( im_wrapone( t[0], out,
(im_wrapone_fn) buffer_fn, a, b ) )
return( -1 );
return( 0 );
}

View File

@ -46,6 +46,31 @@
#include <vips/vips.h>
#include <vips/internal.h>
int
im__colour_unary( const char *domain,
IMAGE *in, IMAGE *out, VipsType type,
im_wrapone_fn buffer_fn, void *a, void *b )
{
IMAGE *t[1];
if( im_check_uncoded( domain, in ) ||
im_check_bands( domain, in, 3 ) ||
im_open_local_array( out, t, 1, domain, "p" ) ||
im_clip2fmt( in, t[0], IM_BANDFMT_FLOAT ) )
return( -1 );
if( im_cp_desc( out, t[0] ) )
return( -1 );
out->Type = type;
if( im_wrapone( t[0], out,
(im_wrapone_fn) buffer_fn, a, b ) )
return( -1 );
return( 0 );
}
typedef struct {
IMAGE *in, *out;

View File

@ -1237,94 +1237,11 @@ vips_foreign_convert_saveable( VipsForeignSave *save )
/* Interpret the Type field for colorimetric images.
*/
if( in->Bands == 3 &&
in->BandFmt == VIPS_FORMAT_SHORT &&
in->Type == VIPS_INTERPRETATION_LABS ) {
if( in->Bands == 3 ) {
VipsImage *out;
if( vips_LabS2LabQ( in, &out, NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
}
if( in->Coding == VIPS_CODING_LABQ ) {
VipsImage *out;
if( vips_LabQ2Lab( in, &out, NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
}
if( in->Coding != VIPS_CODING_NONE ) {
g_object_unref( in );
return( -1 );
}
if( in->Bands == 3 &&
in->Type == VIPS_INTERPRETATION_LCH ) {
VipsImage *out;
if( vips_LCh2Lab( in, &out, NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
}
if( in->Bands == 3 &&
in->Type == VIPS_INTERPRETATION_YXY ) {
VipsImage *out;
if( vips_Yxy2Lab( in, &out, NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
}
if( in->Bands == 3 &&
in->Type == VIPS_INTERPRETATION_UCS ) {
VipsImage *out;
if( vips_UCS2XYZ( in, &out, NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
}
if( in->Bands == 3 &&
in->Type == VIPS_INTERPRETATION_LAB ) {
VipsImage *out;
if( vips_Lab2XYZ( in, &out, NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
}
if( in->Bands == 3 &&
in->Type == VIPS_INTERPRETATION_XYZ ) {
VipsImage *out;
if( vips_XYZ2sRGB( in, &out, NULL ) ) {
if( vips_colour_convert( in, &out,
VIPS_INTERPRETATION_sRGB, NULL ) ) {
g_object_unref( in );
return( -1 );
}