Author: lehmi Date: Sat Feb 1 15:07:05 2014 New Revision: 1563426 URL: http://svn.apache.org/r1563426 Log: PDFBOX-1870: fixed sample reader as proposed by Tilman Hausherr
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java?rev=1563426&r1=1563425&r2=1563426&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java Sat Feb 1 15:07:05 2014 @@ -126,18 +126,14 @@ public class PDFunctionType0 extends PDF // Successive values are adjacent in the bit stream; // there is no padding at byte boundaries. ImageInputStream mciis = new MemoryCacheImageInputStream(getPDStream().createInputStream()); - for (int i = 0; i < numberOfInputValues; i++) + for (int i = 0; i < arraySize; i++) { - int sizeInputValues = sizes.getInt(i); - for (int j = 0; j < sizeInputValues; j++) + for (int k = 0; k < numberOfOutputValues; k++) { - for (int k = 0; k < numberOfOutputValues; k++) - { - // TODO will this cast work properly for 32 bitsPerSample or should be use long[]? - samples[index][k] = (int) mciis.readBits(bitsPerSample); - } - index++; + // TODO will this cast work properly for 32 bitsPerSample or should we use long[]? + samples[index][k] = (int) mciis.readBits(bitsPerSample); } + index++; } mciis.close(); } @@ -388,12 +384,10 @@ public class PDFunctionType0 extends PDF } return resultSample; } - int[] coord1 = coord.clone(); - int[] coord2 = coord.clone(); - coord1[step] = inPrev[step]; - coord2[step] = inNext[step]; - int[] sample1 = getSamples()[calcSampleIndex(coord1)]; - int[] sample2 = getSamples()[calcSampleIndex(coord2)]; + coord[step] = inPrev[step]; + int[] sample1 = getSamples()[calcSampleIndex(coord)]; + coord[step] = inNext[step]; + int[] sample2 = getSamples()[calcSampleIndex(coord)]; for (int i = 0; i < numberOfOutputValues; ++i) { resultSample[i] = interpolate(in[step], inPrev[step], inNext[step], sample1[i], sample2[i]); @@ -409,12 +403,10 @@ public class PDFunctionType0 extends PDF coord[step] = inPrev[step]; return rinterpol(coord, step + 1); } - int[] coord1 = coord.clone(); - int[] coord2 = coord.clone(); - coord1[step] = inPrev[step]; - coord2[step] = inNext[step]; - float[] sample1 = rinterpol(coord1, step + 1); - float[] sample2 = rinterpol(coord2, step + 1); + coord[step] = inPrev[step]; + float[] sample1 = rinterpol(coord, step + 1); + coord[step] = inNext[step]; + float[] sample2 = rinterpol(coord, step + 1); for (int i = 0; i < numberOfOutputValues; ++i) { resultSample[i] = interpolate(in[step], inPrev[step], inNext[step], sample1[i], sample2[i]); @@ -439,7 +431,6 @@ public class PDFunctionType0 extends PDF int numberOfInputValues = input.length; int numberOfOutputValues = getNumberOfOutputParameters(); - float[] outputValues = new float[numberOfOutputValues]; int[] inputPrev = new int[numberOfInputValues]; int[] inputNext = new int[numberOfInputValues]; @@ -505,7 +496,7 @@ public class PDFunctionType0 extends PDF // } // } // - outputValues = new Rinterpol(input, inputPrev, inputNext).rinterpolate(); + float[] outputValues = new Rinterpol(input, inputPrev, inputNext).rinterpolate(); for (int i = 0; i < numberOfOutputValues; i++) {