[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kpdf/annotations/kdegraphics/kpdf/xpdf/xpdf
From:       Enrico Ros <rosenric () dei ! unipd ! it>
Date:       2005-07-27 22:13:32
Message-ID: 1122502412.999539.8677.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 439364 by eros:

Merging trunk changes (now 3.5) till 2005-07-27.
patch_138 (http://tinyurl.com/8j5nb)


 M  +38 -0     DCTStream.cc  


--- branches/kpdf/annotations/kdegraphics/kpdf/xpdf/xpdf/DCTStream.cc #439363:439364
@@ -64,6 +64,44 @@
   int row_stride;
 
   str->reset();
+  
+  // JPEG data has to start with 0xFF 0xD8
+  // but some pdf like the one on 
+  // https://bugs.freedesktop.org/show_bug.cgi?id=3299
+  // does have some garbage before that this seeks for
+  // the start marker...
+  bool startFound = false;
+  int c = 0, c2 = 0;
+  int n = 0;
+  while (!startFound)
+  {
+    if (!c)
+    {
+      c = str->getChar();
+      if (c != 0xFF) c = 0;
+      if (c == -1)
+      {
+        error(-1, "Could not find start of jpeg data");
+        exit(1);
+      }
+    }
+    else
+    {
+      c2 = str->getChar();
+      if (c2 != 0xD8)
+      {
+        c = 0;
+        c2 = 0;
+      }
+      else startFound = true;
+    }
+    n++;
+  }
+
+  // ...and this skips the garbage
+  str->reset();
+  for (n = n - 2; n > 0; n--) str->getChar();
+  
   jpeg_read_header(&cinfo, TRUE);
   jpeg_start_decompress(&cinfo);
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic