You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Dave Smith (JIRA)" <ji...@apache.org> on 2012/11/13 14:50:11 UTC
[jira] [Created] (PDFBOX-1445) /ImageMask true does not work. Patch
included.
Dave Smith created PDFBOX-1445:
----------------------------------
Summary: /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
<<
/Type /Page
/MediaBox [ 0 0 612.0 792.0 ]
/Parent 3 0 R
/Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
/Contents [ 8 0 R 9 0 R ]
>>
endobj
Which then draws 4 images. The first one is a "base" and then rest are image masks
9 0 obj
<< /Filter /FlateDecode /Length 121 >>
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 /BitsPerComponent 8
/ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
stream
endstream
endobj
5 0 obj
<< /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
/ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
/Length 15580 >>
stream
etc ...
The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
after
if (awtImage == null)
{
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.
/**
* 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).
* Convert the map to an image with an Alpha channel so we can lay it on top
*/
if(image.getImageMask())
{
Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
final int onColour = 0xff000000 | currentColour.getRGB();
BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
for(int y=0;y<awtImage.getHeight();y++)
{
for(int x=0;x<awtImage.getWidth();x++)
{
bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
}
}
awtImage = bia;
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Dave Smith (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496369#comment-13496369 ]
Dave Smith commented on PDFBOX-1445:
------------------------------------
Nope. We only have one ImageMask and the current state of the drawn images. PDPixelMap assumes you have an image and a image mask. What I am doing is converting an ImageMask to an image that we can write on top to the current image
I will figure out how eclipse generates patches and go from there. Unfortunately there is other debug code I have in there so it is not so easy .....
> /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
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496354#comment-13496354 ]
Andreas Lehmkühler 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
> /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
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496387#comment-13496387 ]
Andreas Lehmkühler commented on PDFBOX-1445:
--------------------------------------------
The idea is to replace your code with the code from PDPixelMap and remove the code from PDPIxelMap. So that the ImageMask stuff will be used with all kind of PDXObjectImages (PixelMap, Ccitt and Jpeg). WDYT
> /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
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496376#comment-13496376 ]
Andreas Lehmkühler commented on PDFBOX-1445:
--------------------------------------------
PDPixelMap combines 2 images if it contains a soft mask (SMask == true). If it is an image mask it will be used to create a mask using the nonstroking color and the 1-pixel map.
> /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
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Dave Smith (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496380#comment-13496380 ]
Dave Smith commented on PDFBOX-1445:
------------------------------------
I see it now. BUT .. In my case I have an /ImageMask that is type PDCcitt and a /Mask that is a JBIG2 and they do not go through the PDPixelMap code...
> /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
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Dave Smith (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496633#comment-13496633 ]
Dave Smith commented on PDFBOX-1445:
------------------------------------
I have included fixed for both /ImageMask and /Mask . The latter was not being handled at all. I have samples for both but I need the ttps://issues.apache.org/jira/browse/PDFBOX-1067 applied to test the /Mask case...
> /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
> Attachments: PDCcitt.java.patch, PDJpeg.java.patch, PDPixelMap.java.patch, PDXObjectImage.java.patch
>
>
> I have the following pdf...
> 10 0 obj
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (PDFBOX-1445) /ImageMask true does not work.
Patch included.
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Lehmkühler resolved PDFBOX-1445.
----------------------------------------
Resolution: Fixed
Fix Version/s: 1.8.0
Assignee: Andreas Lehmkühler
I applied the patch in revision 1410890 as proposed.
Thanks for the contribution
> /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
> Assignee: Andreas Lehmkühler
> Fix For: 1.8.0
>
> Attachments: PDCcitt.java.patch, PDJpeg.java.patch, PDPixelMap.java.patch, PDXObjectImage.java.patch
>
>
> I have the following pdf...
> 10 0 obj
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PDFBOX-1445) /ImageMask true does not work. Patch
included.
Posted by "Dave Smith (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dave Smith updated PDFBOX-1445:
-------------------------------
Attachment: PDCcitt.java.patch
PDJpeg.java.patch
PDXObjectImage.java.patch
PDPixelMap.java.patch
These move the /ImageMask and /Mask code to the base PDXObjectImage class
Each class that extends the PDXObjectImage simply call applyMask at the end.
> /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
> Attachments: PDCcitt.java.patch, PDJpeg.java.patch, PDPixelMap.java.patch, PDXObjectImage.java.patch
>
>
> I have the following pdf...
> 10 0 obj
> <<
> /Type /Page
> /MediaBox [ 0 0 612.0 792.0 ]
> /Parent 3 0 R
> /Resources << /XObject << /Obj4 4 0 R /Obj5 5 0 R /Obj6 6 0 R /Obj7 7 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >>
> /Contents [ 8 0 R 9 0 R ]
> >>
> endobj
> Which then draws 4 images. The first one is a "base" and then rest are image masks
> 9 0 obj
> << /Filter /FlateDecode /Length 121 >>
> 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 /BitsPerComponent 8
> /ColorSpace /DeviceGray /Filter [ /FlateDecode /DCTDecode ] /Length 50485 >>
> stream
> endstream
> endobj
> 5 0 obj
> << /Type /XObject /Subtype /Image /Width 2184 /Height 2320 /BitsPerComponent 1
> /ImageMask true /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2184 >>
> /Length 15580 >>
> stream
> etc ...
> The current code simply treats the imagemask as an image. Since this is just 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<COSBase> arguments) throws IOException
> after
> if (awtImage == null)
> {
> 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.
> /**
> * 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).
> * Convert the map to an image with an Alpha channel so we can lay it on top
> */
> if(image.getImageMask())
> {
> Color currentColour = drawer.getGraphicsState().getStrokingColor().getJavaColor();
> final int onColour = 0xff000000 | currentColour.getRGB();
> BufferedImage bia = new BufferedImage(awtImage.getWidth(),awtImage.getHeight(),BufferedImage.TYPE_INT_ARGB);
> for(int y=0;y<awtImage.getHeight();y++)
> {
> for(int x=0;x<awtImage.getWidth();x++)
> {
> bia.setRGB(x, y, (awtImage.getRGB(x, y) & 0x00ffffff) == 0xffffff ? 0x00ffffff : onColour);
> }
> }
> awtImage = bia;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira