Return-Path: X-Original-To: apmail-pdfbox-dev-archive@www.apache.org Delivered-To: apmail-pdfbox-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 61011D8FF for ; Tue, 13 Nov 2012 17:28:13 +0000 (UTC) Received: (qmail 7231 invoked by uid 500); 13 Nov 2012 17:28:12 -0000 Delivered-To: apmail-pdfbox-dev-archive@pdfbox.apache.org Received: (qmail 7200 invoked by uid 500); 13 Nov 2012 17:28:12 -0000 Mailing-List: contact dev-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list dev@pdfbox.apache.org Received: (qmail 7069 invoked by uid 99); 13 Nov 2012 17:28:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Nov 2012 17:28:12 +0000 Date: Tue, 13 Nov 2012 17:28:12 +0000 (UTC) From: =?utf-8?Q?Andreas_Lehmk=C3=BChler_=28JIRA=29?= To: dev@pdfbox.apache.org Message-ID: <2032918747.108902.1352827692220.JavaMail.jiratomcat@arcas> In-Reply-To: <1490948876.107782.1352814612390.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (PDFBOX-1445) /ImageMask true does not work. Patch included. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PDFBOX-1445?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D134= 96354#comment-13496354 ]=20 Andreas Lehmk=C3=BChler commented on PDFBOX-1445: -------------------------------------------- Can't we just use the code which already exists in PDPixelMap (starting at = line 369)? It should be faster. P.S.: Please attach patches as diff to make it easier for us the apply them =20 > /ImageMask true does not work. Patch included. > ---------------------------------------------- > > Key: PDFBOX-1445 > URL: https://issues.apache.org/jira/browse/PDFBOX-1445 > Project: PDFBox > Issue Type: Bug > Reporter: Dave Smith > > I have the following pdf... > 10 0 obj > <<=20 > /Type /Page=20 > /MediaBox [ 0 0 612.0 792.0 ]=20 > /Parent 3 0 R=20 > /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R= >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>=20 > /Contents [ 8 0 R 9 0 R ]=20 > >>=20 > endobj > Which then draws 4 images. The first one is a "base" and then rest are im= age masks > 9 0 obj > << /Filter /FlateDecode /Length 121 >>=20 > stream > q > 612.00 0 0 792.00 0.00 0.00 cm > /Obj4 Do > Q > q > 0.129 g > 524.16 0 0 556.80 48.00 127.68 cm > /Obj5 Do > Q > q > 0.302 g > 220.80 0 0 398.40 48.00 286.08 cm > /Obj6 Do > Q > q > 0.204 g > 524.16 0 0 469.44 48.00 185.28 cm > /Obj7 Do > Q > endstream > endobj > 4 0 obj > << /Type /XObject /Subtype /Image /Width 1275 /Height 1650 /BitsPerCompon= ent 8=20 > /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485= >>=20 > stream > endstream > endobj > 5 0 obj > << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerCompon= ent 1=20 > /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 21= 84 >>=20 > /Length 15580 >>=20 > stream > etc ... > The current code simply treats the imagemask as an image. Since this is j= ust a 1 bit image it has no Alpha channel it overwrites the existing image = and we simply get the last image drawn. > In > org.apache.pdfbox.util.operator.pagedrawer.Invoke.java > method > public void process(PDFOperator operator, List arguments) throws= IOException > after=20 > if (awtImage =3D=3D null)=20 > { > LOG.warn("getRGBImage returned NULL"); > return;//TODO PKOCH > } > If you add the following code it fixes the problem. I can not provide the= sample doc due to privacy reasons.=20 > /** > * Spec 8.9.6.2 > * If ImageMask is true then the image is one bit. Black = means draw the current colour and white means use the colour on the current= image (ie Mask).=20 > * Convert the map to an image with an Alpha channel so w= e can lay it on top > */ > if(image.getImageMask()) > { > =09Color currentColour =3D drawer.getGraphicsState().getS= trokingColor().getJavaColor(); > =09final int onColour =3D 0xff000000 | currentColour.getR= GB(); > =09BufferedImage bia =3D new BufferedImage(awtImage.getWi= dth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB); > =09for(int y=3D0;y =09{ > =09=09for(int x=3D0;x =09=09{ > =09=09=09bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ff= ffff) =3D=3D 0xffffff ? 0x00ffffff : onColour); > =09=09} > =09} > =09awtImage =3D bia; > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira