Fix formatting
This commit is contained in:
parent
fa9142b7e4
commit
d4ac2f613d
|
@ -597,9 +597,7 @@ void color_apply_conversion(opj_image_t *image)
|
||||||
in = cmsCreateLab4Profile(NULL);
|
in = cmsCreateLab4Profile(NULL);
|
||||||
out = cmsCreate_sRGBProfile();
|
out = cmsCreate_sRGBProfile();
|
||||||
|
|
||||||
transform =
|
transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);
|
||||||
cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16,
|
|
||||||
INTENT_PERCEPTUAL, 0);
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBLCMS2
|
#ifdef HAVE_LIBLCMS2
|
||||||
cmsCloseProfile(in);
|
cmsCloseProfile(in);
|
||||||
|
@ -631,6 +629,7 @@ void color_apply_conversion(opj_image_t *image)
|
||||||
rl = row[2]; ra = row[4]; rb = row[6];
|
rl = row[2]; ra = row[4]; rb = row[6];
|
||||||
ol = row[3]; oa = row[5]; ob = row[7];
|
ol = row[3]; oa = row[5]; ob = row[7];
|
||||||
}
|
}
|
||||||
|
|
||||||
L = src0 = image->comps[0].data;
|
L = src0 = image->comps[0].data;
|
||||||
a = src1 = image->comps[1].data;
|
a = src1 = image->comps[1].data;
|
||||||
b = src2 = image->comps[2].data;
|
b = src2 = image->comps[2].data;
|
||||||
|
@ -679,69 +678,60 @@ void color_apply_conversion(opj_image_t *image)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n",
|
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__,__LINE__, enumcs);
|
||||||
__FILE__,__LINE__, enumcs);
|
|
||||||
|
|
||||||
}// color_apply_conversion()
|
}// color_apply_conversion()
|
||||||
|
|
||||||
#endif // HAVE_LIBLCMS2 || HAVE_LIBLCMS1
|
#endif // HAVE_LIBLCMS2 || HAVE_LIBLCMS1
|
||||||
|
|
||||||
void color_cmyk_to_rgb(opj_image_t *image)
|
void color_cmyk_to_rgb(opj_image_t *image)
|
||||||
{
|
{
|
||||||
int *R, *G, *B, *dst0, *dst1, *dst2;
|
|
||||||
int *sc, *sm, *sy, *sk, *src0, *src1, *src2, *src3;
|
|
||||||
float C, M, Y, K;
|
float C, M, Y, K;
|
||||||
unsigned int w, h, max, prec, len, i;
|
float sC, sM, sY, sK;
|
||||||
|
unsigned int w, h, max, i;
|
||||||
|
|
||||||
w = image->comps[0].w;
|
w = image->comps[0].w;
|
||||||
h = image->comps[0].h;
|
h = image->comps[0].h;
|
||||||
prec = image->comps[0].prec;
|
|
||||||
|
|
||||||
if(prec != 8) return;
|
if(image->numcomps < 4) return;
|
||||||
if(image->numcomps != 4) return;
|
|
||||||
|
|
||||||
max = w * h;
|
max = w * h;
|
||||||
len = max * sizeof(int);
|
|
||||||
|
|
||||||
R = dst0 = (int*)malloc(len);
|
sC = 1.0F / (float)((1 << image->comps[0].prec) - 1);
|
||||||
G = dst1 = (int*)malloc(len);
|
sM = 1.0F / (float)((1 << image->comps[1].prec) - 1);
|
||||||
B = dst2 = (int*)malloc(len);
|
sY = 1.0F / (float)((1 << image->comps[2].prec) - 1);
|
||||||
|
sK = 1.0F / (float)((1 << image->comps[3].prec) - 1);
|
||||||
sc = src0 = image->comps[0].data;
|
|
||||||
sm = src1 = image->comps[1].data;
|
|
||||||
sy = src2 = image->comps[2].data;
|
|
||||||
sk = src3 = image->comps[3].data;
|
|
||||||
|
|
||||||
for(i = 0; i < max; ++i)
|
for(i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
// CMYK and CMY values from 0 to 1
|
/* CMYK values from 0 to 1 */
|
||||||
//
|
C = (float)(image->comps[0].data[i]) * sC;
|
||||||
C = (float)(*sc++)/(float)255.;
|
M = (float)(image->comps[1].data[i]) * sM;
|
||||||
M = (float)(*sm++)/(float)255;
|
Y = (float)(image->comps[2].data[i]) * sY;
|
||||||
Y = (float)(*sy++)/(float)255;
|
K = (float)(image->comps[3].data[i]) * sK;
|
||||||
K = (float)(*sk++)/(float)255;
|
|
||||||
|
|
||||||
// CMYK -> CMY
|
/* Invert all CMYK values */
|
||||||
//
|
C = 1.0F - C;
|
||||||
C = ( C * ( (float)1. - K ) + K );
|
M = 1.0F - M;
|
||||||
M = ( M * ( (float)1. - K ) + K );
|
Y = 1.0F - Y;
|
||||||
Y = ( Y * ( (float)1. - K ) + K );
|
K = 1.0F - K;
|
||||||
|
|
||||||
// CMY -> RGB : RGB results from 0 to 255
|
/* CMYK -> RGB : RGB results from 0 to 255 */
|
||||||
//
|
image->comps[0].data[i] = (int)(255.0F * C * K); /* R */
|
||||||
*R++ = (int)(unsigned char)(( (float)1. - C ) * (float)255.);
|
image->comps[1].data[i] = (int)(255.0F * M * K); /* G */
|
||||||
*G++ = (int)(unsigned char)(( (float)1. - M ) * (float)255.);
|
image->comps[2].data[i] = (int)(255.0F * Y * K); /* B */
|
||||||
*B++ = (int)(unsigned char)(( (float)1. - Y ) * (float)255.);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(src0); image->comps[0].data = dst0;
|
free(image->comps[3].data); image->comps[3].data = NULL;
|
||||||
free(src1); image->comps[1].data = dst1;
|
image->comps[0].prec = 8;
|
||||||
free(src2); image->comps[2].data = dst2;
|
image->comps[1].prec = 8;
|
||||||
free(src3); image->comps[3].data = NULL;
|
image->comps[2].prec = 8;
|
||||||
|
image->numcomps -= 1;
|
||||||
image->numcomps = 3;
|
|
||||||
image->color_space = OPJ_CLRSPC_SRGB;
|
image->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
|
||||||
|
for (i = 3; i < image->numcomps; ++i) {
|
||||||
|
memcpy(&(image->comps[i]), &(image->comps[i+1]), sizeof(image->comps[i]));
|
||||||
|
}
|
||||||
|
|
||||||
}// color_cmyk_to_rgb()
|
}// color_cmyk_to_rgb()
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -749,35 +739,25 @@ void color_cmyk_to_rgb(opj_image_t *image)
|
||||||
//
|
//
|
||||||
void color_esycc_to_rgb(opj_image_t *image)
|
void color_esycc_to_rgb(opj_image_t *image)
|
||||||
{
|
{
|
||||||
int *s0, *s1, *s2, *src0, *src1, *src2;
|
|
||||||
int *r, *g, *b, *dst0, *dst1, *dst2;
|
|
||||||
int y, cb, cr, sign1, sign2, val;
|
int y, cb, cr, sign1, sign2, val;
|
||||||
unsigned int w, h, max, i;
|
unsigned int w, h, max, i;
|
||||||
int flip_value = (1 << (image->comps[0].prec-1));
|
int flip_value = (1 << (image->comps[0].prec-1));
|
||||||
int max_value = (~(-1 << image->comps[0].prec));
|
int max_value = (~(-1 << image->comps[0].prec));
|
||||||
|
|
||||||
if(image->numcomps != 3) return;
|
if(image->numcomps < 3) return;
|
||||||
|
|
||||||
w = image->comps[0].w;
|
w = image->comps[0].w;
|
||||||
h = image->comps[0].h;
|
h = image->comps[0].h;
|
||||||
|
|
||||||
s0 = src0 = image->comps[0].data;
|
|
||||||
s1 = src1 = image->comps[1].data;
|
|
||||||
s2 = src2 = image->comps[2].data;
|
|
||||||
|
|
||||||
sign1 = image->comps[1].sgnd;
|
sign1 = image->comps[1].sgnd;
|
||||||
sign2 = image->comps[2].sgnd;
|
sign2 = image->comps[2].sgnd;
|
||||||
|
|
||||||
max = w * h;
|
max = w * h;
|
||||||
|
|
||||||
r = dst0 = (int*)malloc(max * sizeof(int));
|
|
||||||
g = dst1 = (int*)malloc(max * sizeof(int));
|
|
||||||
b = dst2 = (int*)malloc(max * sizeof(int));
|
|
||||||
|
|
||||||
for(i = 0; i < max; ++i)
|
for(i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
y = *s0++; cb = *s1++; cr = *s2++;
|
y = image->comps[0].data[i]; cb = image->comps[1].data[i]; cr = image->comps[2].data[i];
|
||||||
|
|
||||||
if( !sign1) cb -= flip_value;
|
if( !sign1) cb -= flip_value;
|
||||||
if( !sign2) cr -= flip_value;
|
if( !sign2) cr -= flip_value;
|
||||||
|
@ -787,28 +767,22 @@ void color_esycc_to_rgb(opj_image_t *image)
|
||||||
+ (float)1.40199 * (float)cr + (float)0.5);
|
+ (float)1.40199 * (float)cr + (float)0.5);
|
||||||
|
|
||||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||||
*r++ = val;
|
image->comps[0].data[i] = val;
|
||||||
|
|
||||||
val = (int)
|
val = (int)
|
||||||
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
|
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
|
||||||
- (float)0.7141128 * (float)cr + (float)0.5);
|
- (float)0.7141128 * (float)cr + (float)0.5);
|
||||||
|
|
||||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||||
*g++ = val;
|
image->comps[1].data[i] = val;
|
||||||
|
|
||||||
val = (int)
|
val = (int)
|
||||||
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
|
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
|
||||||
- (float)0.000008 *(float)cr + (float)0.5);
|
- (float)0.000008 *(float)cr + (float)0.5);
|
||||||
|
|
||||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||||
*b++ = val;
|
image->comps[2].data[i] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(src0); image->comps[0].data = dst0;
|
|
||||||
free(src1); image->comps[1].data = dst1;
|
|
||||||
free(src2); image->comps[2].data = dst2;
|
|
||||||
|
|
||||||
image->numcomps = 3;
|
|
||||||
image->color_space = OPJ_CLRSPC_SRGB;
|
image->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
|
||||||
}// color_esycc_to_rgb()
|
}// color_esycc_to_rgb()
|
||||||
|
|
Loading…
Reference in New Issue