From 101d09ea6dfede5a35986264ddb18ec830dd6808 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sat, 8 Oct 2011 19:15:50 +1030 Subject: [PATCH 5/5] cairo: implement transfer function in setSoftMask --- poppler/CairoOutputDev.cc | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index c2b6445..fae0136 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -1497,14 +1497,14 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo popTransparencyGroup(); } -static uint32_t luminocity(uint32_t x) +static int luminocity(uint32_t x) { int r = (x >> 16) & 0xff; int g = (x >> 8) & 0xff; int b = (x >> 0) & 0xff; // an arbitrary integer approximation of .3*r + .59*g + .11*b int y = (r*19661+g*38666+b*7209 + 32829)>>16; - return y << 24; + return y; } @@ -1591,19 +1591,15 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, int stride = cairo_image_surface_get_stride(source)/4; for (int y=0; ytransform(&lum, &lum2); - } else { - lum2 = lum; + double lum_in, lum_out; + lum_in = lum/256.0; + transferFunc->transform(&lum_in, &lum_out); + lum = (int)(lum_out * 255.0 + 0.5); } - p[x] = (int)(lum2 * 255.0 + 0.5); -#endif - + source_data[y*stride + x] = lum << 24; } } cairo_surface_mark_dirty (source); -- 1.7.4.1