Details
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).
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).
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
Marking issue as resolved. Changes related to
PDF-464have also fixed this test case.