[poppler] 2 commits - poppler/CharCodeToUnicode.cc utils/ImageOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Aug 30 03:54:18 PDT 2008


 poppler/CharCodeToUnicode.cc |    3 ++-
 utils/ImageOutputDev.cc      |   12 +++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

New commits:
commit 8670bfed7900586725b30e3af67f6849acc6efda
Author: Vasile Gaburici <gaburici at cs.umd.edu>
Date:   Sat Aug 30 12:47:13 2008 +0200

    Fix extraction of images
    
    See bug 16999 for more info

diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc
index 9655679..3f44077 100644
--- a/utils/ImageOutputDev.cc
+++ b/utils/ImageOutputDev.cc
@@ -13,6 +13,7 @@
 // Copyright (C) 2005, 2007 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Rainer Keller <class321 at gmx.de>
 // Copyright (C) 2008 Timothy Lee <timothy.lee at siriushk.com>
+// Copyright (C) 2008 Vasile Gaburici <gaburici at cs.umd.edu>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -116,10 +117,13 @@ void ImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   FILE *f;
   ImageStream *imgStr;
   Guchar *p;
+  Guchar zero = 0;
+  GfxGray gray;
   GfxRGB rgb;
   int x, y;
   int c;
   int size, i;
+  int pbm_mask = 0xff;
 
   // dump JPEG file
   if (dumpJPEG && str->getKind() == strDCT &&
@@ -162,10 +166,16 @@ void ImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
     // initialize stream
     str->reset();
 
+    // if 0 comes out as 0 in the color map, the we _flip_ stream bits
+    // otherwise we pass through stream bits unmolested
+    colorMap->getGray(&zero, &gray);
+    if(colToByte(gray))
+      pbm_mask = 0;
+
     // copy the stream
     size = height * ((width + 7) / 8);
     for (i = 0; i < size; ++i) {
-      fputc(str->getChar(), f);
+      fputc(str->getChar() ^ pbm_mask, f);
     }
 
     str->close();
commit 1c98f197664b1a2c06e2caf32116a8487f4054bf
Author: Vasile Gaburici <gaburici at cs.umd.edu>
Date:   Sat Aug 30 12:44:02 2008 +0200

    Read sMap reverse so CMap entries take precedence
    
    See bug 17321 for a more in depth explanation

diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index 40d33a4..11eb300 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -14,6 +14,7 @@
 // Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
+// Copyright (C) 2008 Vasile Gaburici <gaburici at cs.umd.edu>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -507,7 +508,7 @@ int CharCodeToUnicode::mapToUnicode(CharCode c, Unicode **u) {
     *u = &map[c];
     return 1;
   }
-  for (i = 0; i < sMapLen; ++i) {
+  for (i = sMapLen - 1; i >= 0; --i) { // in reverse so CMap takes precedence
     if (sMap[i].c == c) {
       *u = sMap[i].u;
       return sMap[i].len;


More information about the poppler mailing list