[poppler] Soft Masking bugs [was Supporting PDF 1.6 UserUnit]

Brad Hards bradh at frogmouth.net
Tue Jul 12 22:14:29 EST 2005


On Tue, 12 Jul 2005 03:08 am, Leonard Rosenthol wrote:
> >   https://bugs.freedesktop.org/show_bug.cgi?id=3098
>
>          This one comes out just with Xpdf/Splash
> just fine.  Is it possible that the poppler
> caller isn't setting an alpha-enabled output (eg. RGB vs. RGBA)?

OK, after staring at this for a while, I'm starting to believe that it really 
is possible to read a PDF file by eye. I'm not sure if I'm doing it right 
though.

If I'm following along, then the following snippet is the part that draws the 
section that is meant to be alpha-blended:

3 0 obj
<< /Type /XObject
   /Subtype /Image
   /Width 200
   /Height 200
   /BitsPerComponent 8
   /ColorSpace /DeviceRGB
   /Filter /DCTDecode
   /Length 2631
   /SMask 4 0 R
>>
stream
  <stuff snipped>
endstream
endobj

4 0 obj
<< /Type /XObject
   /Subtype /Image
   /Width 200
   /Height 200
   /BitsPerComponent 8
   /Length 5 0 R
   /Filter /FlateDecode
   /ColorSpace /DeviceGray
   /Decode [ 1 0 ]
>>
stream
 <stuff snipped>
endstream
endobj

From that, I think that this file uses softmasking, which poppler doesn't 
currently do - certainly I couldn't find any reference to an "SMask" lookup.

So the appropriate place to do such a lookup would presumably be in 
Gfx::doImage(). However if I'm getting enough of softmasking, then there can 
actually be at least two soft masks - an softmask in the state, and a 
softmask for in a particular image. The image one apparently takes precedence 
though.

So I've played around a bit with trying to get an image softmask to work.At 
this stage, I'm not sure how to modify the OutputDev interface (how much 
processing should we do before handing it over?). I think I also need a Dict 
to get the softmask size out, but it isn't working for me. Anyone else 
thought about this, or can see what I'm doing wrong?

Brad

Index: Gfx.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Gfx.cc,v
retrieving revision 1.1.1.1
diff -u -4 -p -r1.1.1.1 Gfx.cc
--- Gfx.cc      3 Mar 2005 19:46:02 -0000       1.1.1.1
+++ Gfx.cc      12 Jul 2005 12:11:57 -0000
@@ -2525,8 +2525,10 @@ void Gfx::opXObject(Object args[], int n
 #endif
   obj1.free();
 }

+#include <iostream>
+
 void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
   Dict *dict;
   int width, height;
   int bits;
@@ -2534,9 +2536,12 @@ void Gfx::doImage(Object *ref, Stream *s
   GBool invert;
   GfxColorSpace *colorSpace;
   GfxImageColorMap *colorMap;
   Object maskObj;
+  Object smaskObj;
   GBool haveMask;
+  GBool haveSoftMask;
+  Dict *softMaskDict;
   int maskColors[2*gfxColorMaxComps];
   Object obj1, obj2;
   int i;

@@ -2663,14 +2668,23 @@ void Gfx::doImage(Object *ref, Stream *s
       }
       haveMask = gTrue;
     }

+    int smWidth = 0;
+    haveSoftMask = gFalse;
+    dict->lookup("SMask", &smaskObj);
+    if (smaskObj.isStream()) {
+      haveSoftMask = gTrue;
+      softMaskDict = smaskObj.getDict();
+    }
+
     // draw it
     out->drawImage(state, ref, str, width, height, colorMap,
                   haveMask ? maskColors : (int *)NULL,  inlineImg);
     delete colorMap;

     maskObj.free();
+    smaskObj.free();
   }

   if ((i = width * height) > 1000) {
     i = 1000;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/poppler/attachments/20050712/3e475ac9/attachment.pgp


More information about the poppler mailing list