reformat in vips style
This commit is contained in:
parent
d3c73b4d39
commit
a67f92b8d9
@ -129,7 +129,7 @@ vips_CMYK2XYZ_init( VipsCMYK2XYZ *CMYK2XYZ )
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
#else /*!HAVE_LCMS2*/
|
||||
|
||||
typedef VipsColourCode VipsCMYK2XYZ;
|
||||
typedef VipsColourCodeClass VipsCMYK2XYZClass;
|
||||
@ -139,28 +139,28 @@ G_DEFINE_TYPE(VipsCMYK2XYZ, vips_CMYK2XYZ, VIPS_TYPE_COLOUR_CODE);
|
||||
void
|
||||
vips_CMYK2XYZ_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
|
||||
{
|
||||
unsigned char *p = (unsigned char *) in[0];
|
||||
float *q = (float *) out;
|
||||
unsigned char *p = (unsigned char *) in[0];
|
||||
float *q = (float *) out;
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
float c = p[0] / 255.0;
|
||||
float m = p[1] / 255.0;
|
||||
float y = p[2] / 255.0;
|
||||
float k = p[3] / 255.0;
|
||||
for( i = 0; i < width; i++ ) {
|
||||
float c = p[0] / 255.0;
|
||||
float m = p[1] / 255.0;
|
||||
float y = p[2] / 255.0;
|
||||
float k = p[3] / 255.0;
|
||||
|
||||
float r = 1.0 - (c * (1.0 - k) + k);
|
||||
float g = 1.0 - (m * (1.0 - k) + k);
|
||||
float b = 1.0 - (y * (1.0 - k) + k);
|
||||
float r = 1.0 - (c * (1.0 - k) + k);
|
||||
float g = 1.0 - (m * (1.0 - k) + k);
|
||||
float b = 1.0 - (y * (1.0 - k) + k);
|
||||
|
||||
q[0] = VIPS_D65_X0 * r;
|
||||
q[1] = VIPS_D65_Y0 * g;
|
||||
q[2] = VIPS_D65_Z0 * b;
|
||||
q[0] = VIPS_D65_X0 * r;
|
||||
q[1] = VIPS_D65_Y0 * g;
|
||||
q[2] = VIPS_D65_Z0 * b;
|
||||
|
||||
p += 4;
|
||||
q += 3;
|
||||
}
|
||||
p += 4;
|
||||
q += 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -176,23 +176,23 @@ vips_CMYK2XYZ_class_init( VipsCMYK2XYZClass *class )
|
||||
object_class->nickname = "CMYK2XYZ";
|
||||
object_class->description = _( "transform CMYK to XYZ" );
|
||||
|
||||
colour_class->process_line = vips_CMYK2XYZ_line;
|
||||
colour_class->process_line = vips_CMYK2XYZ_line;
|
||||
}
|
||||
|
||||
static void
|
||||
vips_CMYK2XYZ_init( VipsCMYK2XYZ *CMYK2XYZ )
|
||||
{
|
||||
VipsColour *colour = VIPS_COLOUR( CMYK2XYZ );
|
||||
VipsColourCode *code = VIPS_COLOUR_CODE( CMYK2XYZ );
|
||||
VipsColour *colour = VIPS_COLOUR( CMYK2XYZ );
|
||||
VipsColourCode *code = VIPS_COLOUR_CODE( CMYK2XYZ );
|
||||
|
||||
colour->interpretation = VIPS_INTERPRETATION_XYZ;
|
||||
colour->format = VIPS_FORMAT_FLOAT;
|
||||
colour->bands = 3;
|
||||
colour->input_bands = 4;
|
||||
colour->interpretation = VIPS_INTERPRETATION_XYZ;
|
||||
colour->format = VIPS_FORMAT_FLOAT;
|
||||
colour->bands = 3;
|
||||
colour->input_bands = 4;
|
||||
|
||||
code->input_coding = VIPS_CODING_NONE;
|
||||
code->input_format = VIPS_FORMAT_UCHAR;
|
||||
code->input_interpretation = VIPS_INTERPRETATION_CMYK;
|
||||
code->input_coding = VIPS_CODING_NONE;
|
||||
code->input_format = VIPS_FORMAT_UCHAR;
|
||||
code->input_interpretation = VIPS_INTERPRETATION_CMYK;
|
||||
}
|
||||
|
||||
#endif /*HAVE_LCMS2*/
|
||||
|
@ -128,7 +128,7 @@ vips_XYZ2CMYK_init( VipsXYZ2CMYK *XYZ2CMYK )
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
#else /*!HAVE_LCMS2*/
|
||||
|
||||
typedef VipsColourCode VipsXYZ2CMYK;
|
||||
typedef VipsColourCodeClass VipsXYZ2CMYKClass;
|
||||
@ -138,40 +138,42 @@ G_DEFINE_TYPE(VipsXYZ2CMYK, vips_XYZ2CMYK, VIPS_TYPE_COLOUR_CODE);
|
||||
void
|
||||
vips_XYZ2CMYK_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
|
||||
{
|
||||
float *p = (float *) in[0];
|
||||
unsigned char *q = (unsigned char *) out;
|
||||
float *p = (float *) in[0];
|
||||
unsigned char *q = (unsigned char *) out;
|
||||
|
||||
const float epsilon = 0.00001;
|
||||
const float epsilon = 0.00001;
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
float c, m, y, k;
|
||||
float r = p[0] / VIPS_D65_X0;
|
||||
float g = p[1] / VIPS_D65_Y0;
|
||||
float b = p[2] / VIPS_D65_Z0;
|
||||
for( i = 0; i < width; i++ ) {
|
||||
float r = p[0] / VIPS_D65_X0;
|
||||
float g = p[1] / VIPS_D65_Y0;
|
||||
float b = p[2] / VIPS_D65_Z0;
|
||||
|
||||
c = 255.0 - r;
|
||||
m = 255.0 - g;
|
||||
y = 255.0 - b;
|
||||
k = c;
|
||||
k = VIPS_MIN(k, VIPS_MIN(m, y));
|
||||
float c, m, y, k;
|
||||
|
||||
c = (c - k) / (255.0 - k) * 255.0;
|
||||
m = (m - k) / (255.0 - k) * 255.0;
|
||||
y = (y - k) / (255.0 - k) * 255.0;
|
||||
c = 255.0 - r;
|
||||
m = 255.0 - g;
|
||||
y = 255.0 - b;
|
||||
k = VIPS_MIN( c, VIPS_MIN( m, y ) );
|
||||
|
||||
q[0] = (unsigned char) VIPS_CLIP(0, c, 255.0);
|
||||
q[1] = (unsigned char) VIPS_CLIP(0, m, 255.0);
|
||||
q[2] = (unsigned char) VIPS_CLIP(0, y, 255.0);
|
||||
if (r < epsilon && g < epsilon && b < epsilon)
|
||||
q[3] = 255.0;
|
||||
else
|
||||
q[3] = (unsigned char) VIPS_CLIP(0, k, 255.0);
|
||||
c = (c - k) / (255.0 - k) * 255.0;
|
||||
m = (m - k) / (255.0 - k) * 255.0;
|
||||
y = (y - k) / (255.0 - k) * 255.0;
|
||||
|
||||
p += 3;
|
||||
q += 4;
|
||||
}
|
||||
q[0] = (unsigned char) VIPS_CLIP(0, c, 255.0);
|
||||
q[1] = (unsigned char) VIPS_CLIP(0, m, 255.0);
|
||||
q[2] = (unsigned char) VIPS_CLIP(0, y, 255.0);
|
||||
if( r < epsilon &&
|
||||
g < epsilon &&
|
||||
b < epsilon )
|
||||
q[3] = 255.0;
|
||||
else
|
||||
q[3] = VIPS_CLIP( 0, k, 255 );
|
||||
|
||||
p += 3;
|
||||
q += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -187,23 +189,23 @@ vips_XYZ2CMYK_class_init( VipsXYZ2CMYKClass *class )
|
||||
object_class->nickname = "XYZ2CMYK";
|
||||
object_class->description = _( "transform XYZ to CMYK" );
|
||||
|
||||
colour_class->process_line = vips_XYZ2CMYK_line;
|
||||
colour_class->process_line = vips_XYZ2CMYK_line;
|
||||
}
|
||||
|
||||
static void
|
||||
vips_XYZ2CMYK_init( VipsXYZ2CMYK *XYZ2CMYK )
|
||||
{
|
||||
VipsColour *colour = VIPS_COLOUR( XYZ2CMYK );
|
||||
VipsColourCode *code = VIPS_COLOUR_CODE( XYZ2CMYK );
|
||||
VipsColour *colour = VIPS_COLOUR( XYZ2CMYK );
|
||||
VipsColourCode *code = VIPS_COLOUR_CODE( XYZ2CMYK );
|
||||
|
||||
colour->interpretation = VIPS_INTERPRETATION_CMYK;
|
||||
colour->format = VIPS_FORMAT_UCHAR;
|
||||
colour->bands = 4;
|
||||
colour->input_bands = 3;
|
||||
colour->interpretation = VIPS_INTERPRETATION_CMYK;
|
||||
colour->format = VIPS_FORMAT_UCHAR;
|
||||
colour->bands = 4;
|
||||
colour->input_bands = 3;
|
||||
|
||||
code->input_coding = VIPS_CODING_NONE;
|
||||
code->input_format = VIPS_FORMAT_FLOAT;
|
||||
code->input_interpretation = VIPS_INTERPRETATION_XYZ;
|
||||
code->input_coding = VIPS_CODING_NONE;
|
||||
code->input_format = VIPS_FORMAT_FLOAT;
|
||||
code->input_interpretation = VIPS_INTERPRETATION_XYZ;
|
||||
}
|
||||
|
||||
#endif /*HAVE_LCMS2*/
|
||||
|
Loading…
Reference in New Issue
Block a user