[poppler] 2 commits - poppler/GfxState.cc poppler/GfxState.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Sat Feb 26 17:37:13 PST 2011
poppler/GfxState.cc | 24 ++++++++++++++++++++++--
poppler/GfxState.h | 12 +++++++++++-
2 files changed, 33 insertions(+), 3 deletions(-)
New commits:
commit de77e26759f1c33698abe248ad29b75c329a043c
Author: Albert Astals Cid <aacid at kde.org>
Date: Sun Feb 27 01:39:23 2011 +0000
Fix crash in some pdf
Has to be 3 and not nComps since it's a output buffer, a the input one
Bug 34357
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 6bd643f..8db57b2 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -1636,7 +1636,7 @@ void GfxICCBasedColorSpace::getRGBLine(Guchar *in, unsigned int *out,
int length) {
#ifdef USE_CMS
if (lineTransform != 0) {
- Guchar* tmp = (Guchar *)gmallocn(nComps * length, sizeof(Guchar));
+ Guchar* tmp = (Guchar *)gmallocn(3 * length, sizeof(Guchar));
lineTransform->doTransform(in, tmp, length);
for (int i = 0; i < length; ++i) {
Guchar *current = tmp + (i * 3);
commit 4f82a2e08cb2c930956c6b38030fa7b015a0de5a
Author: Albert Astals Cid <aacid at kde.org>
Date: Sun Feb 27 01:38:33 2011 +0000
Implement GfxDeviceCMYKColorSpace::getRGBLine
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 5716f26..6bd643f 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -16,7 +16,7 @@
// Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright (C) 2006-2010 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2011 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2009 Koji Otani <sho at bbr.jp>
// Copyright (C) 2009, 2011 Thomas Freitag <Thomas.Freitag at alfa.de>
// Copyright (C) 2009 Christian Persch <chpe at gnome.org>
@@ -1086,6 +1086,26 @@ void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
rgb->b = clip01(dblToCol(b));
}
+void GfxDeviceCMYKColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length)
+{
+ double c, m, y, k, c1, m1, y1, k1, r, g, b;
+
+ Guchar *inp = in;
+ for (int i = 0; i < length; i++) {
+ c = byteToDbl(*inp++);
+ m = byteToDbl(*inp++);
+ y = byteToDbl(*inp++);
+ k = byteToDbl(*inp++);
+ c1 = 1 - c;
+ m1 = 1 - m;
+ y1 = 1 - y;
+ k1 = 1 - k;
+ cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b);
+
+ *out++ = (dblToByte(clip01(r)) << 16) | (dblToByte(clip01(g)) << 8) | dblToByte(clip01(b));
+ }
+}
+
void GfxDeviceCMYKColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
cmyk->c = clip01(color->c[0]);
cmyk->m = clip01(color->c[1]);
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 8d853fa..19594ed 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -17,7 +17,7 @@
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
// Copyright (C) 2006 Carlos Garcia Campos <carlosgc at gnome.org>
// Copyright (C) 2009 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2009, 2010 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009-2011 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
// Copyright (C) 2011 Andrea Canciani <ranma42 at gmail.com>
//
@@ -96,6 +96,14 @@ static inline double colToDbl(GfxColorComp x) {
return (double)x / (double)gfxColorComp1;
}
+static inline Guchar dblToByte(double x) {
+ return (x * 255.0);
+}
+
+static inline double byteToDbl(Guchar x) {
+ return (double)x / (double)255.0;
+}
+
static inline GfxColorComp byteToCol(Guchar x) {
// (x / 255) << 16 = (0.0000000100000001... * x) << 16
// = ((x << 8) + (x) + (x >> 8) + ...) << 16
@@ -385,6 +393,8 @@ public:
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+ virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
+ virtual GBool useGetRGBLine() { return gTrue; }
virtual int getNComps() { return 4; }
virtual void getDefaultColor(GfxColor *color);
More information about the poppler
mailing list