[poppler] poppler/SplashOutputDev.cc splash/Splash.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Wed Aug 1 13:58:15 PDT 2012
poppler/SplashOutputDev.cc | 76 +++++++++++++++++++++++++++++++--------------
splash/Splash.cc | 22 -------------
2 files changed, 54 insertions(+), 44 deletions(-)
New commits:
commit d0e55aa49484263882345fa648e1e907d2b172f2
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date: Wed Aug 1 22:56:49 2012 +0200
Splash: Blend mode enhancements for CMYK
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index abdcea4..9e07060 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -661,11 +661,6 @@ static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest,
SplashColor rgbSrc;
SplashColor rgbDest;
SplashColor rgbBlend;
- for (i = 0; i < 4; i++) {
- // convert back to subtractive (s. Splash.cc)
- src[i] = 0xff - src[i];
- dest[i] = 0xff - dest[i];
- }
cmykToRGB(src, rgbSrc);
cmykToRGB(dest, rgbDest);
for (i = 0; i < 3; ++i) {
@@ -681,10 +676,6 @@ static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest,
}
}
rgbToCMYK(rgbBlend, blend);
- for (i = 0; i < 4; i++) {
- // convert back to additive (s. Splash.cc)
- blend[i] = 0xff - blend[i];
- }
} else
#endif
{
@@ -848,6 +839,8 @@ static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest,
Guchar r0, g0, b0;
#ifdef SPLASH_CMYK
Guchar r1, g1, b1;
+ int i;
+ SplashColor src2, dest2;
#endif
switch (cm) {
@@ -866,15 +859,24 @@ static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest,
break;
#if SPLASH_CMYK
case splashModeCMYK8:
+ for (i = 0; i < 4; i++) {
+ // convert to additive
+ src2[i] = 0xff - src[i];
+ dest2[i] = 0xff - dest[i];
+ }
// NB: inputs have already been converted to additive mode
- setSat(src[0], src[1], src[2], getSat(dest[0], dest[1], dest[2]),
+ setSat(src2[0], src2[1], src2[2], getSat(dest2[0], dest2[1], dest2[2]),
&r0, &g0, &b0);
- setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]),
+ setLum(r0, g0, b0, getLum(dest2[0], dest2[1], dest2[2]),
&r1, &g1, &b1);
blend[0] = r1;
blend[1] = g1;
blend[2] = b1;
- blend[3] = dest[3];
+ blend[3] = dest2[3];
+ for (i = 0; i < 4; i++) {
+ // convert back to subtractive
+ blend[i] = 0xff - blend[i];
+ }
break;
#endif
}
@@ -886,6 +888,8 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest,
Guchar r0, g0, b0;
#ifdef SPLASH_CMYK
Guchar r1, g1, b1;
+ int i;
+ SplashColor src2, dest2;
#endif
switch (cm) {
@@ -904,15 +908,23 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest,
break;
#if SPLASH_CMYK
case splashModeCMYK8:
- // NB: inputs have already been converted to additive mode
- setSat(dest[0], dest[1], dest[2], getSat(src[0], src[1], src[2]),
+ for (i = 0; i < 4; i++) {
+ // convert to additive
+ src2[i] = 0xff - src[i];
+ dest2[i] = 0xff - dest[i];
+ }
+ setSat(dest2[0], dest2[1], dest2[2], getSat(src2[0], src2[1], src2[2]),
&r0, &g0, &b0);
- setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]),
+ setLum(r0, g0, b0, getLum(dest2[0], dest2[1], dest2[2]),
&r1, &g1, &b1);
blend[0] = r1;
blend[1] = g1;
blend[2] = b1;
- blend[3] = dest[3];
+ blend[3] = dest2[3];
+ for (i = 0; i < 4; i++) {
+ // convert back to subtractive
+ blend[i] = 0xff - blend[i];
+ }
break;
#endif
}
@@ -922,6 +934,8 @@ static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest,
SplashColorPtr blend, SplashColorMode cm) {
#if SPLASH_CMYK
Guchar r, g, b;
+ int i;
+ SplashColor src2, dest2;
#endif
switch (cm) {
@@ -938,13 +952,21 @@ static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest,
break;
#if SPLASH_CMYK
case splashModeCMYK8:
- // NB: inputs have already been converted to additive mode
- setLum(src[0], src[1], src[2], getLum(dest[0], dest[1], dest[2]),
+ for (i = 0; i < 4; i++) {
+ // convert to additive
+ src2[i] = 0xff - src[i];
+ dest2[i] = 0xff - dest[i];
+ }
+ setLum(src2[0], src2[1], src2[2], getLum(dest2[0], dest2[1], dest2[2]),
&r, &g, &b);
blend[0] = r;
blend[1] = g;
blend[2] = b;
- blend[3] = dest[3];
+ blend[3] = dest2[3];
+ for (i = 0; i < 4; i++) {
+ // convert back to subtractive
+ blend[i] = 0xff - blend[i];
+ }
break;
#endif
}
@@ -955,6 +977,8 @@ static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest,
SplashColorMode cm) {
#if SPLASH_CMYK
Guchar r, g, b;
+ int i;
+ SplashColor src2, dest2;
#endif
switch (cm) {
@@ -971,13 +995,21 @@ static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest,
break;
#if SPLASH_CMYK
case splashModeCMYK8:
- // NB: inputs have already been converted to additive mode
- setLum(dest[0], dest[1], dest[2], getLum(src[0], src[1], src[2]),
+ for (i = 0; i < 4; i++) {
+ // convert to additive
+ src2[i] = 0xff - src[i];
+ dest2[i] = 0xff - dest[i];
+ }
+ setLum(dest2[0], dest2[1], dest2[2], getLum(src2[0], src2[1], src2[2]),
&r, &g, &b);
blend[0] = r;
blend[1] = g;
blend[2] = b;
- blend[3] = src[3];
+ blend[3] = src2[3];
+ for (i = 0; i < 4; i++) {
+ // convert back to subtractive
+ blend[i] = 0xff - blend[i];
+ }
break;
#endif
}
diff --git a/splash/Splash.cc b/splash/Splash.cc
index b927e5e..d2d965a 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -337,9 +337,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
SplashColorPtr cSrc;
Guchar cResult0, cResult1, cResult2, cResult3;
int t;
-#if SPLASH_CMYK
- SplashColor cSrc2, cDest2;
-#endif
//----- source color
@@ -521,25 +518,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
//----- blend function
if (state->blendFunc) {
-#if SPLASH_CMYK
- if (bitmap->mode == splashModeCMYK8) {
- // convert colors to additive
- cSrc2[0] = 0xff - cSrc[0];
- cSrc2[1] = 0xff - cSrc[1];
- cSrc2[2] = 0xff - cSrc[2];
- cSrc2[3] = 0xff - cSrc[3];
- cDest2[0] = 0xff - cDest[0];
- cDest2[1] = 0xff - cDest[1];
- cDest2[2] = 0xff - cDest[2];
- cDest2[3] = 0xff - cDest[3];
- (*state->blendFunc)(cSrc2, cDest2, cBlend, bitmap->mode);
- // convert result back to subtractive
- cBlend[0] = 0xff - cBlend[0];
- cBlend[1] = 0xff - cBlend[1];
- cBlend[2] = 0xff - cBlend[2];
- cBlend[3] = 0xff - cBlend[3];
- } else
-#endif
(*state->blendFunc)(cSrc, cDest, cBlend, bitmap->mode);
}
More information about the poppler
mailing list