You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/12/10 18:19:40 UTC
svn commit: r1644486 -
/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/Predictor.java
Author: tilman
Date: Wed Dec 10 17:19:40 2014
New Revision: 1644486
URL: http://svn.apache.org/r1644486
Log:
PDFBOX-2549: TIFF SUB predictor for 16bpc
Modified:
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/Predictor.java
Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/Predictor.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/Predictor.java?rev=1644486&r1=1644485&r2=1644486&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/Predictor.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/Predictor.java Wed Dec 10 17:19:40 2014
@@ -73,8 +73,22 @@ public class Predictor
switch (linepredictor)
{
case 2:// PRED TIFF SUB
- // TODO decode tiff with bitsPerComponent != 8;
+ // TODO decode tiff with bitsPerComponent < 8;
// e.g. for 4 bpc each nibble must be subtracted separately
+ if (bitsPerComponent == 16)
+ {
+ for (int p = 0; p < rowlength; p += 2)
+ {
+ int sub = ((actline[p] & 0xff) << 8) + (actline[p + 1] & 0xff);
+ int left = p - bytesPerPixel >= 0
+ ? (((actline[p - bytesPerPixel] & 0xff) << 8)
+ + (actline[p - bytesPerPixel + 1] & 0xff))
+ : 0;
+ actline[p] = (byte) (((sub + left) >> 8) & 0xff);
+ actline[p + 1] = (byte) ((sub + left) & 0xff);
+ }
+ break;
+ }
if (bitsPerComponent != 8)
{
throw new IOException("TIFF-Predictor with " + bitsPerComponent