You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Roland Quast (JIRA)" <ji...@apache.org> on 2011/05/30 08:36:47 UTC

[jira] [Created] (PDFBOX-1022) PDPage convertToImage creates inverted black and white image for indexed 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


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

[jira] [Closed] (PDFBOX-1022) PDPage convertToImage creates inverted black and white image for indexed colorspace.

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler closed PDFBOX-1022.
--------------------------------------

    Resolution: Duplicate
      Assignee: Andreas Lehmkühler

> 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
>            Assignee: Andreas Lehmkühler
>            Priority: Critical
>         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

[jira] [Updated] (PDFBOX-1022) PDPage convertToImage creates inverted black and white image for indexed colorspace.

Posted by "Roland Quast (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Priority: Critical  (was: Major)

> 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
>            Priority: Critical
>         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

[jira] [Commented] (PDFBOX-1022) PDPage convertToImage creates inverted black and white image for indexed colorspace.

Posted by "Roland Quast (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041019#comment-13041019 ] 

Roland Quast commented on PDFBOX-1022:
--------------------------------------

Needs something like this?

else if (colorspace instanceof PDIndexed)
{

// code to test black/white

}

> 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
>            Priority: Critical
>         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

[jira] [Updated] (PDFBOX-1022) PDPage convertToImage creates inverted black and white image for indexed colorspace.

Posted by "Roland Quast (JIRA)" <ji...@apache.org>.
     [ 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