ICEpdf
  1. ICEpdf
  2. PDF-395

B/w TIFF images using RGB are inverted

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.2, 4.3
    • Fix Version/s: 4.3.4
    • Component/s: API
    • Labels:
      None
    • Environment:
      -

      Description

      With the PDF document in the attachment we ran into some problems - the document contains a sequence
      of TIFF images and when we run the document through icePDF, the images are inverted.

      The TIFF images in the PDF input have a particular structure where a "1 bit per pixel black and white image"
      is represented using a color palette that maps 0/1 to RGB ffffff/000000. (the BlackIs1 flag is set to true).

      <</Length 8 0 R
      /Subtype /Image
      /Width 242
      /Height 33
      /ColorSpace [/Indexed /DeviceRGB 1 9 0 R]
      /BitsPerComponent 1
      /Filter /CCITTFaxDecode
      /DecodeParms <</K -1
      /Columns 242
      /BlackIs1 true>>>>

      (the deviceRGB stream is: FF,FF,FF, 00, 00,00).

      I plunged into the code and in the CCITTFax class / applyImageMaskAndDecodeArray() method
      (icepdf-core\src\main\java\org\icepdf\core\pobjects\filters\CCITTFax.java)
      I believe to have found where it happens:

      [....]
      // From empirically testing 6 of the 9 possible combinations of
      // BlackIs1 {true, false, not given} and Decode {[0 1], [1 0], not given}
      // this is the rule. Unknown combinations:
      // BlackIs1=false, Decode=[0 1]
      // BlackIs1=false, Decode=[1 0]
      // BlackIs1=true, Decode=[0 1]
      boolean flag = ((blackIs1 == null) && (defaultDecode == false)) ||
      ((blackIs1 != null) && blackIs1.booleanValue() && (decode == null));


      For our sample document, flag will be set to true here and i believe it should be set to false instead.
      So just after the above line i added the following:

      // Fix for combination "BlackIs1=true, Decode not given"
      if (blackIs1 != null && blackIs1 && defaultDecode && decode == null) {
      flag = false;
      }

      This seems to solve the problem (but i have yet to do more testing).

      (Not knowing the icePDF code very well, i must say it is not a very clean fix and it could/should certainly be improved. Those if's are getting too complex).
      1. 10933-sample.pdf
        41 kB
        Tyler Johnson
      1. screenshot-1.jpg
        27 kB

        Activity

        Hide
        Patrick Corless added a comment -

        Marking issue as resolved. Changes related to PDF-464 have also fixed this test case.

        Show
        Patrick Corless added a comment - Marking issue as resolved. Changes related to PDF-464 have also fixed this test case.

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Tyler Johnson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: