[poppler] poppler/CairoOutputDev.cc
Jeff Muizelaar
jrmuizel at kemper.freedesktop.org
Fri Nov 9 17:50:22 PST 2007
poppler/CairoOutputDev.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 934a5ae45eb17bd0e2010be89f55510e8a69816b
Author: Jeff Muizelaar <jeff at infidigm.net>
Date: Sat Nov 3 13:08:51 2007 -0400
Avoiding using floating point when converting to luminance.
The code now also does proper rounding instead of just truncating.
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2d4f663..fd2742a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -601,7 +601,8 @@ static uint32_t luminocity(uint32_t x)
int r = (x >> 16) & 0xff;
int g = (x >> 8) & 0xff;
int b = (x >> 0) & 0xff;
- int y = (int) (0.3 * r + 0.59 * g + 0.11 * b);
+ // an arbitrary integer approximation of .3*r + .59*g + .11*b
+ int y = (r*19661+g*38666+b*7209 + 32829)>>16;
return y << 24;
}
More information about the poppler
mailing list