[ 
https://issues.apache.org/jira/browse/PDFBOX-1022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Roland Quast updated PDFBOX-1022:
---------------------------------

    Attachment: tast_bb.pdf

An example of an incorrect image with PDIndexed colorspace.

> PDPage convertToImage creates inverted black and white image for indexed 
> colorspace.
> ------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-1022
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1022
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.5.0
>         Environment: Java 1.6, Windows 7.
>            Reporter: Roland Quast
>         Attachments: tast_bb.pdf
>
>
> The attached PDF file demonstrates that line 178 of PDPixelMap.java does not 
> try to determine what is the black value and what is the white value. The 
> colorspace of the attached PDF file is PDIndexed.
> Inverting this value makes the file render correctly, but there needs to be 
> some kind of way to determine what is black/white for a PDIndexed colorspace.
>                 if (colorspace instanceof PDDeviceGray)
>                 {
>                     COSArray decode = getDecode();
>                     // we have to invert the b/w-values, 
>                     // if the Decode array exists and consists of (1,0)
>                     if (decode != null && decode.getInt(0) == 1)
>                     {
>                         map = new byte[] {(byte)0xff};
>                     }
>                     else
>                     {
>                         map = new byte[] {(byte)0x00, (byte)0xff};
>                     }
>                 }
>                 else if (colorspace instanceof PDICCBased)
>                 {
>                     if ( ((PDICCBased)colorspace).getNumberOfComponents() == 
> 1) 
>                     {
>                         map = new byte[] {(byte)0xff};
>                     }
>                     else
>                     {
>                         map = new byte[] {(byte)0x00, (byte)0xff};
>                     }
>                 }
>                 else
>                 {
>                     map = new byte[] {(byte)0x00, (byte)0xff}; // <--- 
> HAPPENS HERE - NO TEST FOR BLACK/WHITE LIKE OTHER CASES ABOVE.
>                 }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to