You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/12/29 15:53:24 UTC

svn commit: r1648354 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats: jpeg/ jpeg/decoder/ jpeg/segments/ png/ png/chunks/ png/transparencyfilters/ tiff/datareaders/ tiff/photometricinterpreters/ tiff/write/

Author: sebb
Date: Mon Dec 29 14:53:23 2014
New Revision: 1648354

URL: http://svn.apache.org/r1648354
Log:
IMAGING-117 Reduce visibility of mutable array

Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/ImageDataOffsets.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java Mon Dec 29 14:53:23 2014
@@ -105,7 +105,7 @@ public class JpegImageMetadata implement
 
             byte[] data = null;
             if (dir.getJpegImageData() != null) {
-                data = dir.getJpegImageData().data;
+                data = dir.getJpegImageData().getData(); // TODO clone?
             }
             // Support other image formats here.
 
@@ -145,7 +145,7 @@ public class JpegImageMetadata implement
                 // JPEG thumbnail as JPEG or other format; try to parse.
                 boolean imageSucceeded = false;
                 try {
-                    image = Imaging.getBufferedImage(jpegImageData.data);
+                    image = Imaging.getBufferedImage(jpegImageData.getData());
                     imageSucceeded = true;
                 } catch (final ImagingException imagingException) { // NOPMD
                 } catch (final IOException ioException) { // NOPMD
@@ -154,7 +154,7 @@ public class JpegImageMetadata implement
                     // fall back to ImageIO on error
                     if (!imageSucceeded) {
                         final ByteArrayInputStream input = new ByteArrayInputStream(
-                                jpegImageData.data);
+                                jpegImageData.getData());
                         image = ImageIO.read(input);
                     }
                 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java Mon Dec 29 14:53:23 2014
@@ -207,7 +207,7 @@ public class JpegDecoder extends BinaryF
                 }
                 quantizationTables[table.destinationIdentifier] = table;
                 final int[] quantizationMatrixInt = new int[64];
-                ZigZag.zigZagToBlock(table.elements, quantizationMatrixInt);
+                ZigZag.zigZagToBlock(table.getElements(), quantizationMatrixInt);
                 final float[] quantizationMatrixFloat = new float[64];
                 for (int j = 0; j < 64; j++) {
                     quantizationMatrixFloat[j] = quantizationMatrixInt[j];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java Mon Dec 29 14:53:23 2014
@@ -54,6 +54,6 @@ public class App14Segment extends AppnSe
     }
 
     public int getAdobeColorTransform() {
-        return 0xff & segmentData[11];
+        return 0xff & getSegmentData(11);
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java Mon Dec 29 14:53:23 2014
@@ -41,7 +41,7 @@ public class ComSegment extends GenericS
     public String getDescription() {
         String commentString = "";
         try {
-            commentString = new String(segmentData, "UTF-8");
+            commentString = getSegmentDataAsString("UTF-8");
         } catch (final UnsupportedEncodingException cannotHappen) { // NOPMD
         }
         return "COM (" + commentString + ")";

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java Mon Dec 29 14:53:23 2014
@@ -31,7 +31,7 @@ public class DqtSegment extends Segment
     public static class QuantizationTable {
         public final int precision;
         public final int destinationIdentifier;
-        public final int[] elements;
+        private final int[] elements;
 
         public QuantizationTable(final int precision, final int destinationIdentifier,
                 final int[] elements) {
@@ -39,6 +39,13 @@ public class DqtSegment extends Segment
             this.destinationIdentifier = destinationIdentifier;
             this.elements = elements;
         }
+
+        /**
+         * @return the elements
+         */
+        public int[] getElements() {
+            return elements;
+        }
     }
 
     public DqtSegment(final int marker, final byte[] segmentData)

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java Mon Dec 29 14:53:23 2014
@@ -19,11 +19,12 @@ package org.apache.commons.imaging.forma
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 
 import static org.apache.commons.imaging.common.BinaryFunctions.*;
 
 public abstract class GenericSegment extends Segment {
-    protected final byte[] segmentData;
+    private final byte[] segmentData;
 
     public GenericSegment(int marker, int markerLength, InputStream is) throws IOException {
         super(marker, markerLength);
@@ -58,6 +59,27 @@ public abstract class GenericSegment ext
         return segmentData.clone();
     }
 
+    /**
+     * Returns a specific byte of the segment's contents,
+     * excluding the marker and length bytes at
+     * the beginning. 
+     * @see GenericSegment#getSegmentData()
+     * @return the bye in the segment's contents
+     */
+    protected byte getSegmentData(int offset) {
+        return segmentData[offset];
+    }
+
+    /**
+     * Convert the bytes to a String
+     * @param encoding
+     * @return the encoded bytes
+     * @throws UnsupportedEncodingException
+     */
+    public String getSegmentDataAsString(String encoding) throws UnsupportedEncodingException {
+        return new String(segmentData, encoding);
+    }
+
     // public String getDescription()
     // {
     // return "Unknown";

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Mon Dec 29 14:53:23 2014
@@ -257,7 +257,7 @@ public class PngImageParser extends Imag
         }
 
         final PngChunkIccp pngChunkiCCP = (PngChunkIccp) chunks.get(0);
-        final byte[] bytes = pngChunkiCCP.uncompressedProfile;
+        final byte[] bytes = pngChunkiCCP.getUncompressedProfile(); // TODO should this be a clone?
 
         return (bytes);
     }
@@ -567,7 +567,7 @@ public class PngImageParser extends Imag
                 }
 
                 final PngChunkIccp pngChunkiCCP = (PngChunkIccp) iCCPs.get(0);
-                final byte[] bytes = pngChunkiCCP.uncompressedProfile;
+                final byte[] bytes = pngChunkiCCP.getUncompressedProfile();
 
                 iccProfile = ICC_Profile.getInstance(bytes);
             } else if (gAMAs.size() == 1) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java Mon Dec 29 14:53:23 2014
@@ -28,8 +28,12 @@ public class PngChunkIccp extends PngChu
     // private final PngImageParser parser;
     public final String profileName;
     public final int compressionMethod;
-    public final byte[] compressedProfile;
-    public final byte[] uncompressedProfile;
+    private final byte[] compressedProfile;
+    private final byte[] uncompressedProfile;
+
+    public byte[] getUncompressedProfile() {
+        return uncompressedProfile;
+    }
 
     public PngChunkIccp(
     // PngImageParser parser,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java Mon Dec 29 14:53:23 2014
@@ -22,7 +22,7 @@ import org.apache.commons.imaging.ImageR
 import org.apache.commons.imaging.common.BinaryFileParser;
 
 public abstract class TransparencyFilter extends BinaryFileParser {
-    protected final byte[] bytes;
+    private final byte[] bytes;
 
     public TransparencyFilter(final byte[] bytes) {
         this.bytes = bytes;
@@ -31,4 +31,18 @@ public abstract class TransparencyFilter
 
     public abstract int filter(int rgb, int index) throws ImageReadException,
             IOException;
+
+    /**
+     * @return a byte
+     */
+    public byte getByte(int offset) {
+        return bytes[offset];
+    }
+
+    /**
+     * @return the length
+     */
+    public int getLength() {
+        return bytes.length;
+    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java Mon Dec 29 14:53:23 2014
@@ -28,16 +28,17 @@ public class TransparencyFilterIndexedCo
 
     @Override
     public int filter(final int rgb, final int index) throws ImageReadException, IOException {
-        if (index >= bytes.length) {
+        final int length = getLength();
+        if (index >= length) { // TODO see below - is this check correct?
             return rgb;
         }
 
-        if ((index < 0) || (index > bytes.length)) {
+        if ((index < 0) || (index > length)) { // TODO check for > length cannot be true because of check above
             throw new ImageReadException(
-                    "TransparencyFilterIndexedColor index: " + index + ", bytes.length: " + bytes.length);
+                    "TransparencyFilterIndexedColor index: " + index + ", bytes.length: " + length);
         }
 
-        final int alpha = bytes[index];
+        final int alpha = getByte(index);
         return ((0xff & alpha) << 24) | (0x00ffffff & rgb);
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java Mon Dec 29 14:53:23 2014
@@ -38,8 +38,9 @@ import static org.apache.commons.imaging
 public abstract class DataReader {
     protected final TiffDirectory directory;
     protected final PhotometricInterpreter photometricInterpreter;
-    protected final int[] bitsPerSample;
-    protected final int[] last;
+    private final int[] bitsPerSample;
+    protected final int bitsPerSampleLength;
+    private final int[] last;
 
     protected final int predictor;
     protected final int samplesPerPixel;
@@ -52,6 +53,7 @@ public abstract class DataReader {
         this.directory = directory;
         this.photometricInterpreter = photometricInterpreter;
         this.bitsPerSample = bitsPerSample;
+        this.bitsPerSampleLength = bitsPerSample.length;
         this.samplesPerPixel = samplesPerPixel;
         this.predictor = predictor;
         this.width = width;
@@ -68,8 +70,20 @@ public abstract class DataReader {
     public abstract BufferedImage readImageData(Rectangle subImage)
             throws ImageReadException, IOException;
 
-    
-    
+    /**
+     * Checks if all the bits per sample entries are the same size
+     * @param size the size to check
+     * @return true if all the bits per sample entries are the same
+     */
+    protected boolean isHomogenous(int size) {
+        for (final int element : bitsPerSample) {
+            if (element != size) {
+                return false;
+            }
+        }
+        return true;
+    }
+ 
     /**
      * Reads samples and returns them in an int array.
      * 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java Mon Dec 29 14:53:23 2014
@@ -105,13 +105,7 @@ public final class DataReaderStrips exte
         // in the 8 bits/pixel case.
 
         // verify that all samples are one byte in size
-        boolean allSamplesAreOneByte = true;
-        for (final int element : bitsPerSample) {
-            if (element != 8) {
-                allSamplesAreOneByte = false;
-                break;
-            }
-        }
+        final boolean allSamplesAreOneByte = isHomogenous(8);
 
         if (predictor != 2 && bitsPerPixel == 8 && allSamplesAreOneByte) {
             int k = 0;
@@ -175,7 +169,7 @@ public final class DataReaderStrips exte
         final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         final BitInputStream bis = new BitInputStream(bais, byteOrder);
 
-        int[] samples = new int[bitsPerSample.length];
+        int[] samples = new int[bitsPerSampleLength];
         resetPredictor();
         for (int i = 0; i < pixelsPerStrip; i++) {
             getSamplesAsBytes(bis, samples);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java Mon Dec 29 14:53:23 2014
@@ -71,13 +71,7 @@ public final class DataReaderTiled exten
         //
 
         // verify that all samples are one byte in size
-        boolean allSamplesAreOneByte = true;
-        for (final int element : bitsPerSample) {
-            if (element != 8) {
-                allSamplesAreOneByte = false;
-                break;
-            }
-        }
+        final boolean allSamplesAreOneByte = isHomogenous(8);
 
         if (predictor != 2 && bitsPerPixel == 24 && allSamplesAreOneByte) {
             int k = 0;
@@ -129,7 +123,7 @@ public final class DataReaderTiled exten
         int tileX = 0;
         int tileY = 0;
 
-        int[] samples = new int[bitsPerSample.length];
+        int[] samples = new int[bitsPerSampleLength];
         resetPredictor();
         for (int i = 0; i < pixelsPerTile; i++) {
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java Mon Dec 29 14:53:23 2014
@@ -23,7 +23,7 @@ import org.apache.commons.imaging.common
 
 public abstract class PhotometricInterpreter {
     protected final int samplesPerPixel;
-    protected final int[] bitsPerSample;
+    private final int[] bitsPerSample;
     protected final int predictor;
     protected final int width;
     protected final int height;
@@ -39,4 +39,8 @@ public abstract class PhotometricInterpr
 
     public abstract void interpretPixel(ImageBuilder imageBuilder,
             int[] samples, int x, int y) throws ImageReadException, IOException;
+    
+    protected int getBitsPerSample(int offset) {
+        return bitsPerSample[offset];
+    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java Mon Dec 29 14:53:23 2014
@@ -34,7 +34,7 @@ public class PhotometricInterpreterPalet
             final int[] colorMap) {
         super(samplesPerPixel, bitsPerSample, predictor, width, height);
 
-        final int bitsPerPixel = this.bitsPerSample[0];
+        final int bitsPerPixel = getBitsPerSample(0);
         final int colormapScale = (1 << bitsPerPixel);
         indexColorMap = new int[colormapScale];
         for (int index = 0; index < colormapScale; index++) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/ImageDataOffsets.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/ImageDataOffsets.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/ImageDataOffsets.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/ImageDataOffsets.java Mon Dec 29 14:53:23 2014
@@ -32,7 +32,7 @@ class ImageDataOffsets {
         outputItems = new TiffOutputItem[imageData.length];
         for (int i = 0; i < imageData.length; i++) {
             final TiffOutputItem item = new TiffOutputItem.Value("TIFF image data",
-                    imageData[i].data);
+                    imageData[i].getData());
             outputItems[i] = item;
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java?rev=1648354&r1=1648353&r2=1648354&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java Mon Dec 29 14:53:23 2014
@@ -627,7 +627,7 @@ public final class TiffOutputDirectory e
 
         if (null != jpegImageData) {
             final TiffOutputItem item = new TiffOutputItem.Value("JPEG image data",
-                    jpegImageData.data);
+                    jpegImageData.getData());
             result.add(item);
             outputSummary.add(item, jpegOffsetField);
         }