diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 01979fd..10b44b5 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -447,22 +447,26 @@ static void splashOutBlendMultiply(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = (rgbDest[i] * rgbSrc[i]) / 255; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = (dest[i] * src[i]) / 255; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest, @@ -471,22 +475,26 @@ static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbDest[i] + rgbSrc[i] - (rgbDest[i] * rgbSrc[i]) / 255; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = dest[i] + src[i] - (dest[i] * src[i]) / 255; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, @@ -495,18 +503,11 @@ static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbDest[i] < 0x80 - ? (rgbSrc[i] * 2 * rgbDest[i]) / 255 - : 255 - 2 * ((255 - rgbSrc[i]) * (255 - rgbDest[i])) / 255; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { @@ -515,6 +516,15 @@ static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, : 255 - 2 * ((255 - src[i]) * (255 - dest[i])) / 255; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendDarken(SplashColorPtr src, SplashColorPtr dest, @@ -523,22 +533,26 @@ static void splashOutBlendDarken(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbDest[i] < rgbSrc[i] ? rgbDest[i] : rgbSrc[i]; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = dest[i] < src[i] ? dest[i] : src[i]; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendLighten(SplashColorPtr src, SplashColorPtr dest, @@ -547,22 +561,26 @@ static void splashOutBlendLighten(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbDest[i] > rgbSrc[i] ? rgbDest[i] : rgbSrc[i]; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = dest[i] > src[i] ? dest[i] : src[i]; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, @@ -572,21 +590,11 @@ static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - if (rgbSrc[i] == 255) { - rgbBlend[i] = 255; - } else { - x = (rgbDest[i] * 255) / (255 - rgbSrc[i]); - rgbBlend[i] = x <= 255 ? x : 255; - } + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { @@ -598,6 +606,15 @@ static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, } } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, @@ -606,21 +623,11 @@ static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - if (rgbSrc[i] == 0) { - rgbBlend[i] = 0; - } else { - x = ((255 - rgbDest[i]) * 255) / rgbSrc[i]; - rgbBlend[i] = x <= 255 ? 255 - x : 0; - } + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { @@ -632,6 +639,15 @@ static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, } } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, @@ -640,18 +656,11 @@ static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbSrc[i] < 0x80 - ? (rgbDest[i] * 2 * rgbSrc[i]) / 255 - : 255 - 2 * ((255 - rgbDest[i]) * (255 - rgbSrc[i])) / 255; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { @@ -660,6 +669,15 @@ static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, : 255 - 2 * ((255 - dest[i]) * (255 - src[i])) / 255; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, @@ -668,25 +686,11 @@ static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - if (rgbSrc[i] < 0x80) { - rgbBlend[i] = rgbDest[i] - (255 - 2 * rgbSrc[i]) * rgbDest[i] * (255 - rgbDest[i]) / (255 * 255); - } else { - if (rgbDest[i] < 0x40) { - x = (((((16 * rgbDest[i] - 12 * 255) * rgbDest[i]) / 255) + 4 * 255) * rgbDest[i]) / 255; - } else { - x = (int)sqrt(255.0 * rgbDest[i]); - } - rgbBlend[i] = rgbDest[i] + (2 * rgbSrc[i] - 255) * (x - rgbDest[i]) / 255; - } + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { @@ -702,6 +706,15 @@ static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, } } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendDifference(SplashColorPtr src, SplashColorPtr dest, @@ -711,22 +724,26 @@ static void splashOutBlendDifference(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbDest[i] < rgbSrc[i] ? rgbSrc[i] - rgbDest[i] : rgbDest[i] - rgbSrc[i]; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = dest[i] < src[i] ? src[i] - dest[i] : dest[i] - src[i]; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest, @@ -735,22 +752,26 @@ static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest, #if SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - SplashColor rgbSrc; - SplashColor rgbDest; - SplashColor rgbBlend; - cmykToRGB(src, rgbSrc); - cmykToRGB(dest, rgbDest); - for (i = 0; i < 3; ++i) { - rgbBlend[i] = rgbDest[i] + rgbSrc[i] - (2 * rgbDest[i] * rgbSrc[i]) / 255; + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; } - rgbToCMYK(rgbBlend, blend); - } else + } #endif { for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = dest[i] + src[i] - (2 * dest[i] * src[i]) / 255; } } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif } static int getLum(int r, int g, int b) {