You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by da...@apache.org on 2012/05/26 23:19:22 UTC

svn commit: r1342971 [11/20] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/formats/bmp/ main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/ main/java/org/apache/commons/imaging/formats/bmp/writers/ main/java/or...

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java Sat May 26 21:19:03 2012
@@ -51,22 +51,18 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreterYCbCr;
 import org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossy;
 
-public class TiffImageParser extends ImageParser implements TiffConstants
-{
-    public TiffImageParser()
-    {
+public class TiffImageParser extends ImageParser implements TiffConstants {
+    public TiffImageParser() {
         // setDebug(true);
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "Tiff-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
 
@@ -75,42 +71,40 @@ public class TiffImageParser extends Ima
     private static final String ACCEPTED_EXTENSIONS[] = { ".tif", ".tiff", };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
+    protected ImageFormat[] getAcceptedTypes() {
         return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_TIFF, //
         };
     }
 
     @Override
     public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
         TiffDirectory directory = contents.directories.get(0);
 
-        return directory.getFieldValue(AllTagConstants.EXIF_TAG_ICC_PROFILE, false);
+        return directory.getFieldValue(AllTagConstants.EXIF_TAG_ICC_PROFILE,
+                false);
     }
 
     @Override
     public Dimension getImageSize(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
         TiffDirectory directory = contents.directories.get(0);
 
-        TiffField widthField = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true);
-        TiffField heightField = directory
-                .findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true);
+        TiffField widthField = directory.findField(
+                TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true);
+        TiffField heightField = directory.findField(
+                TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true);
 
         if ((widthField == null) || (heightField == null))
             throw new ImageReadException("TIFF image missing size info.");
@@ -121,40 +115,36 @@ public class TiffImageParser extends Ima
         return new Dimension(width, height);
     }
 
-    public byte[] embedICCProfile(byte image[], byte profile[])
-    {
+    public byte[] embedICCProfile(byte image[], byte profile[]) {
         return null;
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[])
-    {
+    public boolean embedICCProfile(File src, File dst, byte profile[]) {
         return false;
     }
 
     @Override
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffReader tiffReader = new TiffReader(isStrict(params));
-        TiffContents contents = tiffReader.readContents(
-                byteSource, params, formatCompliance);
+        TiffContents contents = tiffReader.readContents(byteSource, params,
+                formatCompliance);
 
         List<TiffDirectory> directories = contents.directories;
 
         TiffImageMetadata result = new TiffImageMetadata(contents);
 
-        for (int i = 0; i < directories.size(); i++)
-        {
+        for (int i = 0; i < directories.size(); i++) {
             TiffDirectory dir = directories.get(i);
 
-            TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(tiffReader.getByteOrder(), dir);
+            TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(
+                    tiffReader.getByteOrder(), dir);
 
             List<TiffField> entries = dir.getDirectoryEntrys();
 
-            for (int j = 0; j < entries.size(); j++)
-            {
+            for (int j = 0; j < entries.size(); j++) {
                 TiffField entry = entries.get(j);
                 metadataDirectory.add(entry);
             }
@@ -167,16 +157,16 @@ public class TiffImageParser extends Ima
 
     @Override
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, false, formatCompliance);
         TiffDirectory directory = contents.directories.get(0);
 
-        TiffField widthField = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true);
-        TiffField heightField = directory
-                .findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true);
+        TiffField widthField = directory.findField(
+                TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true);
+        TiffField heightField = directory.findField(
+                TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true);
 
         if ((widthField == null) || (heightField == null))
             throw new ImageReadException("TIFF image missing size info.");
@@ -194,8 +184,7 @@ public class TiffImageParser extends Ima
             resolutionUnit = resolutionUnitField.getIntValue();
 
         double unitsPerInch = -1;
-        switch (resolutionUnit)
-        {
+        switch (resolutionUnit) {
         case 1:
             break;
         case 2: // Inch
@@ -208,30 +197,31 @@ public class TiffImageParser extends Ima
             break;
 
         }
-        TiffField xResolutionField = directory.findField(TiffTagConstants.TIFF_TAG_XRESOLUTION);
-        TiffField yResolutionField = directory.findField(TiffTagConstants.TIFF_TAG_YRESOLUTION);
+        TiffField xResolutionField = directory
+                .findField(TiffTagConstants.TIFF_TAG_XRESOLUTION);
+        TiffField yResolutionField = directory
+                .findField(TiffTagConstants.TIFF_TAG_YRESOLUTION);
 
         int physicalWidthDpi = -1;
         float physicalWidthInch = -1;
         int physicalHeightDpi = -1;
         float physicalHeightInch = -1;
 
-        if (unitsPerInch > 0)
-        {
+        if (unitsPerInch > 0) {
             if ((xResolutionField != null)
-                    && (xResolutionField.getValue() != null))
-            {
+                    && (xResolutionField.getValue() != null)) {
                 double XResolutionPixelsPerUnit = xResolutionField
                         .getDoubleValue();
-                physicalWidthDpi = (int) Math.round((XResolutionPixelsPerUnit * unitsPerInch));
+                physicalWidthDpi = (int) Math
+                        .round((XResolutionPixelsPerUnit * unitsPerInch));
                 physicalWidthInch = (float) (width / (XResolutionPixelsPerUnit * unitsPerInch));
             }
             if ((yResolutionField != null)
-                    && (yResolutionField.getValue() != null))
-            {
+                    && (yResolutionField.getValue() != null)) {
                 double YResolutionPixelsPerUnit = yResolutionField
                         .getDoubleValue();
-                physicalHeightDpi = (int) Math.round((YResolutionPixelsPerUnit * unitsPerInch));
+                physicalHeightDpi = (int) Math
+                        .round((YResolutionPixelsPerUnit * unitsPerInch));
                 physicalHeightInch = (float) (height / (YResolutionPixelsPerUnit * unitsPerInch));
             }
         }
@@ -253,8 +243,7 @@ public class TiffImageParser extends Ima
 
         List<String> comments = new ArrayList<String>();
         List<TiffField> entries = directory.entries;
-        for (int i = 0; i < entries.size(); i++)
-        {
+        for (int i = 0; i < entries.size(); i++) {
             TiffField field = entries.get(i);
             String comment = field.toString();
             comments.add(comment);
@@ -272,17 +261,18 @@ public class TiffImageParser extends Ima
 
         boolean isTransparent = false; // TODO: wrong
         boolean usesPalette = false;
-        TiffField colorMapField = directory.findField(TiffTagConstants.TIFF_TAG_COLOR_MAP);
+        TiffField colorMapField = directory
+                .findField(TiffTagConstants.TIFF_TAG_COLOR_MAP);
         if (colorMapField != null)
             usesPalette = true;
 
         int colorType = ImageInfo.COLOR_TYPE_RGB;
 
-        int compression = 0xffff & directory.getSingleFieldValue(TiffTagConstants.TIFF_TAG_COMPRESSION);
+        int compression = 0xffff & directory
+                .getSingleFieldValue(TiffTagConstants.TIFF_TAG_COMPRESSION);
         String compressionAlgorithm;
 
-        switch (compression)
-        {
+        switch (compression) {
         case TIFF_COMPRESSION_UNCOMPRESSED_1:
             compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_NONE;
             break;
@@ -323,35 +313,31 @@ public class TiffImageParser extends Ima
 
     @Override
     public String getXmpXml(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, false, formatCompliance);
         TiffDirectory directory = contents.directories.get(0);
 
-        byte bytes[] = directory.getFieldValue(TiffTagConstants.TIFF_TAG_XMP, false);
+        byte bytes[] = directory.getFieldValue(TiffTagConstants.TIFF_TAG_XMP,
+                false);
         if (bytes == null) {
             return null;
         }
 
-        try
-        {
+        try {
             // segment data is UTF-8 encoded xml.
             String xml = new String(bytes, "utf-8");
             return xml;
-        } catch (UnsupportedEncodingException e)
-        {
+        } catch (UnsupportedEncodingException e) {
             throw new ImageReadException("Invalid JPEG XMP Segment.");
         }
     }
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
-        try
-        {
+            throws ImageReadException, IOException {
+        try {
             pw.println("tiff.dumpImageFile");
 
             {
@@ -377,10 +363,8 @@ public class TiffImageParser extends Ima
                 if (directories == null)
                     return false;
 
-                for (int d = 0; d < directories.size(); d++)
-                {
-                    TiffDirectory directory = directories
-                            .get(d);
+                for (int d = 0; d < directories.size(); d++) {
+                    TiffDirectory directory = directories.get(d);
 
                     List<TiffField> entries = directory.entries;
 
@@ -389,8 +373,7 @@ public class TiffImageParser extends Ima
 
                     // Debug.debug("directory offset", directory.offset);
 
-                    for (int i = 0; i < entries.size(); i++)
-                    {
+                    for (int i = 0; i < entries.size(); i++) {
                         TiffField field = entries.get(i);
 
                         field.dump(pw, d + "");
@@ -407,16 +390,14 @@ public class TiffImageParser extends Ima
             // }
 
             return true;
-        } finally
-        {
+        } finally {
             pw.println("");
         }
     }
 
     @Override
     public FormatCompliance getFormatCompliance(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         Map params = null;
         new TiffReader(isStrict(params)).readContents(byteSource, params,
@@ -425,20 +406,17 @@ public class TiffImageParser extends Ima
     }
 
     public List<byte[]> collectRawImageData(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, true, formatCompliance);
 
         List<byte[]> result = new ArrayList<byte[]>();
-        for (int i = 0; i < contents.directories.size(); i++)
-        {
-            TiffDirectory directory = contents.directories
-                    .get(i);
-            List<ImageDataElement> dataElements = directory.getTiffRawImageDataElements();
-            for (int j = 0; j < dataElements.size(); j++)
-            {
+        for (int i = 0; i < contents.directories.size(); i++) {
+            TiffDirectory directory = contents.directories.get(i);
+            List<ImageDataElement> dataElements = directory
+                    .getTiffRawImageDataElements();
+            for (int j = 0; j < dataElements.size(); j++) {
                 TiffDirectory.ImageDataElement element = dataElements.get(j);
                 byte bytes[] = byteSource.getBlock(element.offset,
                         element.length);
@@ -450,11 +428,11 @@ public class TiffImageParser extends Ima
 
     @Override
     public BufferedImage getBufferedImage(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffReader reader = new TiffReader(isStrict(params));
-        TiffContents contents = reader.readFirstDirectory(byteSource, params, true, formatCompliance);
+        TiffContents contents = reader.readFirstDirectory(byteSource, params,
+                true, formatCompliance);
         int byteOrder = reader.getByteOrder();
         TiffDirectory directory = contents.directories.get(0);
         BufferedImage result = directory.getTiffImage(byteOrder, params);
@@ -465,48 +443,48 @@ public class TiffImageParser extends Ima
 
     @Override
     public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffReader tiffReader = new TiffReader(true);
-        TiffContents contents = tiffReader.readDirectories(byteSource, true, formatCompliance);
+        TiffContents contents = tiffReader.readDirectories(byteSource, true,
+                formatCompliance);
         List<BufferedImage> results = new ArrayList<BufferedImage>();
-        for (int i = 0; i < contents.directories.size(); i++)
-        {
+        for (int i = 0; i < contents.directories.size(); i++) {
             TiffDirectory directory = contents.directories.get(i);
-            BufferedImage result = directory.getTiffImage(tiffReader.getByteOrder(), null);
-            if (result != null)
-            {
+            BufferedImage result = directory.getTiffImage(
+                    tiffReader.getByteOrder(), null);
+            if (result != null) {
                 results.add(result);
             }
         }
         return results;
-    } 
+    }
 
-    protected BufferedImage getBufferedImage(TiffDirectory directory, int byteOrder, Map params)
-            throws ImageReadException, IOException
-    {
+    protected BufferedImage getBufferedImage(TiffDirectory directory,
+            int byteOrder, Map params) throws ImageReadException, IOException {
         List<TiffField> entries = directory.entries;
-        
+
         if (entries == null)
             throw new ImageReadException("TIFF missing entries");
 
-        int photometricInterpretation = 0xffff & directory.getSingleFieldValue(
-                TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION);
-        int compression = 0xffff & directory.getSingleFieldValue(TiffTagConstants.TIFF_TAG_COMPRESSION);
-        int width = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true)
-                .getIntValue();
-        int height = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true)
-                .getIntValue();
+        int photometricInterpretation = 0xffff & directory
+                .getSingleFieldValue(TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION);
+        int compression = 0xffff & directory
+                .getSingleFieldValue(TiffTagConstants.TIFF_TAG_COMPRESSION);
+        int width = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH,
+                true).getIntValue();
+        int height = directory.findField(
+                TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true).getIntValue();
         int samplesPerPixel = 1;
-        TiffField samplesPerPixelField = directory.findField(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL);
+        TiffField samplesPerPixelField = directory
+                .findField(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL);
         if (samplesPerPixelField != null)
             samplesPerPixel = samplesPerPixelField.getIntValue();
         int bitsPerSample[] = { 1 };
         int bitsPerPixel = samplesPerPixel;
-        TiffField bitsPerSampleField = directory.findField(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE);
-        if (bitsPerSampleField != null)
-        {
+        TiffField bitsPerSampleField = directory
+                .findField(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE);
+        if (bitsPerSampleField != null) {
             bitsPerSample = bitsPerSampleField.getIntArrayValue();
             bitsPerPixel = bitsPerSampleField.getIntValueOrArraySum();
         }
@@ -521,7 +499,8 @@ public class TiffImageParser extends Ima
             // dumpOptionalNumberTag(entries, TIFF_TAG_FREE_OFFSETS);
             // dumpOptionalNumberTag(entries, TIFF_TAG_ORIENTATION);
             // dumpOptionalNumberTag(entries, TIFF_TAG_PLANAR_CONFIGURATION);
-            TiffField predictorField = directory.findField(TiffTagConstants.TIFF_TAG_PREDICTOR);
+            TiffField predictorField = directory
+                    .findField(TiffTagConstants.TIFF_TAG_PREDICTOR);
             if (null != predictorField)
                 predictor = predictorField.getIntValueOrArraySum();
         }
@@ -554,10 +533,9 @@ public class TiffImageParser extends Ima
     private PhotometricInterpreter getPhotometricInterpreter(
             TiffDirectory directory, int photometricInterpretation,
             int bitsPerPixel, int bitsPerSample[], int predictor,
-            int samplesPerPixel, int width, int height) throws ImageReadException
-    {
-        switch (photometricInterpretation)
-        {
+            int samplesPerPixel, int width, int height)
+            throws ImageReadException {
+        switch (photometricInterpretation) {
         case 0:
         case 1:
             boolean invert = photometricInterpretation == 0;
@@ -567,7 +545,8 @@ public class TiffImageParser extends Ima
                     invert);
         case 3: // Palette
         {
-            int colorMap[] = directory.findField(TiffTagConstants.TIFF_TAG_COLOR_MAP, true)
+            int colorMap[] = directory.findField(
+                    TiffTagConstants.TIFF_TAG_COLOR_MAP, true)
                     .getIntArrayValue();
 
             int expected_colormap_size = 3 * (1 << bitsPerPixel);
@@ -589,15 +568,19 @@ public class TiffImageParser extends Ima
         case 6: //
         {
             double yCbCrCoefficients[] = directory.findField(
-                    TiffTagConstants.TIFF_TAG_YCBCR_COEFFICIENTS, true).getDoubleArrayValue();
+                    TiffTagConstants.TIFF_TAG_YCBCR_COEFFICIENTS, true)
+                    .getDoubleArrayValue();
 
             int yCbCrPositioning[] = directory.findField(
-                    TiffTagConstants.TIFF_TAG_YCBCR_POSITIONING, true).getIntArrayValue();
+                    TiffTagConstants.TIFF_TAG_YCBCR_POSITIONING, true)
+                    .getIntArrayValue();
             int yCbCrSubSampling[] = directory.findField(
-                    TiffTagConstants.TIFF_TAG_YCBCR_SUB_SAMPLING, true).getIntArrayValue();
+                    TiffTagConstants.TIFF_TAG_YCBCR_SUB_SAMPLING, true)
+                    .getIntArrayValue();
 
             double referenceBlackWhite[] = directory.findField(
-                    TiffTagConstants.TIFF_TAG_REFERENCE_BLACK_WHITE, true).getDoubleArrayValue();
+                    TiffTagConstants.TIFF_TAG_REFERENCE_BLACK_WHITE, true)
+                    .getDoubleArrayValue();
 
             return new PhotometricInterpreterYCbCr(yCbCrCoefficients,
                     yCbCrPositioning, yCbCrSubSampling, referenceBlackWhite,
@@ -624,8 +607,7 @@ public class TiffImageParser extends Ima
 
     @Override
     public void writeImage(BufferedImage src, OutputStream os, Map params)
-            throws ImageWriteException, IOException
-    {
+            throws ImageWriteException, IOException {
         new TiffImageWriterLossy().writeImage(src, os, params);
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Sat May 26 21:19:03 2012
@@ -33,33 +33,26 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.imaging.util.Debug;
 
-public class TiffReader extends BinaryFileParser implements TiffConstants
-{
+public class TiffReader extends BinaryFileParser implements TiffConstants {
 
     private final boolean strict;
 
-    public TiffReader(boolean strict)
-    {
+    public TiffReader(boolean strict) {
         this.strict = strict;
     }
 
     private TiffHeader readTiffHeader(ByteSource byteSource,
             FormatCompliance formatCompliance) throws ImageReadException,
-            IOException
-    {
+            IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             return readTiffHeader(is, formatCompliance);
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
         }
@@ -67,8 +60,7 @@ public class TiffReader extends BinaryFi
 
     private TiffHeader readTiffHeader(InputStream is,
             FormatCompliance formatCompliance) throws ImageReadException,
-            IOException
-    {
+            IOException {
         int BYTE_ORDER_1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF File");
         int BYTE_ORDER_2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF File");
         setByteOrder(BYTE_ORDER_1, BYTE_ORDER_2);
@@ -91,8 +83,7 @@ public class TiffReader extends BinaryFi
 
     private void readDirectories(ByteSource byteSource,
             FormatCompliance formatCompliance, Listener listener)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         TiffHeader tiffHeader = readTiffHeader(byteSource, formatCompliance);
         if (!listener.setTiffHeader(tiffHeader))
             return;
@@ -107,8 +98,7 @@ public class TiffReader extends BinaryFi
 
     private boolean readDirectory(ByteSource byteSource, int offset,
             int dirType, FormatCompliance formatCompliance, Listener listener,
-            List<Number> visited) throws ImageReadException, IOException
-    {
+            List<Number> visited) throws ImageReadException, IOException {
         boolean ignoreNextDirectory = false;
         return readDirectory(byteSource, offset, dirType, formatCompliance,
                 listener, ignoreNextDirectory, visited);
@@ -117,8 +107,7 @@ public class TiffReader extends BinaryFi
     private boolean readDirectory(ByteSource byteSource, int offset,
             int dirType, FormatCompliance formatCompliance, Listener listener,
             boolean ignoreNextDirectory, List<Number> visited)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
 
         // Debug.debug();
         // Debug.debug("dir offset", offset + " (0x" +
@@ -134,10 +123,8 @@ public class TiffReader extends BinaryFi
         visited.add(offset);
 
         InputStream is = null;
-        try
-        {
-            if (offset >= byteSource.getLength())
-            {
+        try {
+            if (offset >= byteSource.getLength()) {
                 // Debug.debug("skipping invalid directory!");
                 return true;
             }
@@ -148,12 +135,10 @@ public class TiffReader extends BinaryFi
             List<TiffField> fields = new ArrayList<TiffField>();
 
             int entryCount;
-            try
-            {
+            try {
                 entryCount = read2Bytes("DirectoryEntryCount", is,
                         "Not a Valid TIFF File");
-            } catch (IOException e)
-            {
+            } catch (IOException e) {
                 if (strict)
                     throw e;
                 else
@@ -162,8 +147,7 @@ public class TiffReader extends BinaryFi
 
             // Debug.debug("entryCount", entryCount);
 
-            for (int i = 0; i < entryCount; i++)
-            {
+            for (int i = 0; i < entryCount; i++) {
                 int tag = read2Bytes("Tag", is, "Not a Valid TIFF File");
                 int type = read2Bytes("Type", is, "Not a Valid TIFF File");
                 int length = read4Bytes("Length", is, "Not a Valid TIFF File");
@@ -176,8 +160,7 @@ public class TiffReader extends BinaryFi
                 int valueOffset = convertByteArrayToInt("ValueOffset",
                         valueOffsetBytes);
 
-                if (tag == 0)
-                {
+                if (tag == 0) {
                     // skip invalid fields.
                     // These are seen very rarely, but can have invalid value
                     // lengths,
@@ -197,7 +180,8 @@ public class TiffReader extends BinaryFi
                     field.fillInValue(byteSource);
                 } catch (TiffValueOutsideFileBoundsException valueOutsideFileException) {
                     if (strict) {
-                        // Java 1.5+ throw new IOException(valueOutsideFileException);
+                        // Java 1.5+ throw new
+                        // IOException(valueOutsideFileException);
                         IOException ioe = new IOException();
                         ioe.initCause(valueOutsideFileException);
                         throw ioe;
@@ -222,16 +206,13 @@ public class TiffReader extends BinaryFi
             TiffDirectory directory = new TiffDirectory(dirType, fields,
                     offset, nextDirectoryOffset);
 
-            if (listener.readImageData())
-            {
-                if (directory.hasTiffImageData())
-                {
+            if (listener.readImageData()) {
+                if (directory.hasTiffImageData()) {
                     TiffImageData rawImageData = getTiffRawImageData(
                             byteSource, directory);
                     directory.setTiffImageData(rawImageData);
                 }
-                if (directory.hasJpegImageData())
-                {
+                if (directory.hasJpegImageData()) {
                     JpegImageData rawJpegImageData = getJpegRawImageData(
                             byteSource, directory);
                     directory.setJpegImageData(rawJpegImageData);
@@ -241,18 +222,18 @@ public class TiffReader extends BinaryFi
             if (!listener.addDirectory(directory))
                 return true;
 
-            if (listener.readOffsetDirectories())
-            {
+            if (listener.readOffsetDirectories()) {
                 List<TiffField> fieldsToRemove = new ArrayList<TiffField>();
-                for (int j = 0; j < fields.size(); j++)
-                {
+                for (int j = 0; j < fields.size(); j++) {
                     TiffField entry = fields.get(j);
 
                     if (entry.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag
                             || entry.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag
-                            || entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag)
-                    { /* do nothing */ }
-                    else
+                            || entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) { /*
+                                                                                             * do
+                                                                                             * nothing
+                                                                                             */
+                    } else
                         continue;
 
                     int subDirectoryOffset = ((Number) entry.getValue())
@@ -273,8 +254,7 @@ public class TiffReader extends BinaryFi
                             subDirectoryOffset, subDirectoryType,
                             formatCompliance, listener, true, visited);
 
-                    if (!subDirectoryRead)
-                    {
+                    if (!subDirectoryRead) {
                         // Offset field pointed to invalid location.
                         // This is a bug in certain cameras. Ignore offset
                         // field.
@@ -285,29 +265,24 @@ public class TiffReader extends BinaryFi
                 fields.removeAll(fieldsToRemove);
             }
 
-            if (!ignoreNextDirectory && directory.nextDirectoryOffset > 0)
-            {
+            if (!ignoreNextDirectory && directory.nextDirectoryOffset > 0) {
                 // Debug.debug("next dir", directory.nextDirectoryOffset );
                 readDirectory(byteSource, directory.nextDirectoryOffset,
                         dirType + 1, formatCompliance, listener, visited);
             }
 
             return true;
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
         }
     }
 
-    public static interface Listener
-    {
+    public static interface Listener {
         public boolean setTiffHeader(TiffHeader tiffHeader);
 
         public boolean addDirectory(TiffDirectory directory);
@@ -319,20 +294,17 @@ public class TiffReader extends BinaryFi
         public boolean readOffsetDirectories();
     }
 
-    private static class Collector implements Listener
-    {
+    private static class Collector implements Listener {
         private TiffHeader tiffHeader = null;
         private List<TiffDirectory> directories = new ArrayList<TiffDirectory>();
         private List<TiffField> fields = new ArrayList<TiffField>();
         private final boolean readThumbnails;
 
-        public Collector()
-        {
+        public Collector() {
             this(null);
         }
 
-        public Collector(Map params)
-        {
+        public Collector(Map params) {
             boolean readThumbnails = true;
             if (params != null && params.containsKey(PARAM_KEY_READ_THUMBNAILS))
                 readThumbnails = Boolean.TRUE.equals(params
@@ -340,90 +312,75 @@ public class TiffReader extends BinaryFi
             this.readThumbnails = readThumbnails;
         }
 
-        public boolean setTiffHeader(TiffHeader tiffHeader)
-        {
+        public boolean setTiffHeader(TiffHeader tiffHeader) {
             this.tiffHeader = tiffHeader;
             return true;
         }
 
-        public boolean addDirectory(TiffDirectory directory)
-        {
+        public boolean addDirectory(TiffDirectory directory) {
             directories.add(directory);
             return true;
         }
 
-        public boolean addField(TiffField field)
-        {
+        public boolean addField(TiffField field) {
             fields.add(field);
             return true;
         }
 
-        public boolean readImageData()
-        {
+        public boolean readImageData() {
             return readThumbnails;
         }
 
-        public boolean readOffsetDirectories()
-        {
+        public boolean readOffsetDirectories() {
             return true;
         }
 
-        public TiffContents getContents()
-        {
+        public TiffContents getContents() {
             return new TiffContents(tiffHeader, directories);
         }
     }
 
-    private static class FirstDirectoryCollector extends Collector
-    {
+    private static class FirstDirectoryCollector extends Collector {
         private final boolean readImageData;
 
-        public FirstDirectoryCollector(final boolean readImageData)
-        {
+        public FirstDirectoryCollector(final boolean readImageData) {
             this.readImageData = readImageData;
         }
 
         @Override
-        public boolean addDirectory(TiffDirectory directory)
-        {
+        public boolean addDirectory(TiffDirectory directory) {
             super.addDirectory(directory);
             return false;
         }
 
         @Override
-        public boolean readImageData()
-        {
+        public boolean readImageData() {
             return readImageData;
         }
     }
 
-    private static class DirectoryCollector extends Collector
-    {
+    private static class DirectoryCollector extends Collector {
         private final boolean readImageData;
 
-        public DirectoryCollector(final boolean readImageData)
-        {
+        public DirectoryCollector(final boolean readImageData) {
             this.readImageData = readImageData;
         }
 
         @Override
-        public boolean addDirectory(TiffDirectory directory)
-        {
+        public boolean addDirectory(TiffDirectory directory) {
             super.addDirectory(directory);
             return false;
         }
 
         @Override
-        public boolean readImageData()
-        {
+        public boolean readImageData() {
             return readImageData;
         }
     }
 
     public TiffContents readFirstDirectory(ByteSource byteSource, Map params,
             boolean readImageData, FormatCompliance formatCompliance)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         Collector collector = new FirstDirectoryCollector(readImageData);
         read(byteSource, params, formatCompliance, collector);
         TiffContents contents = collector.getContents();
@@ -435,8 +392,7 @@ public class TiffReader extends BinaryFi
 
     public TiffContents readDirectories(ByteSource byteSource,
             boolean readImageData, FormatCompliance formatCompliance)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         Collector collector = new Collector(null);
         readDirectories(byteSource, formatCompliance, collector);
         TiffContents contents = collector.getContents();
@@ -448,8 +404,7 @@ public class TiffReader extends BinaryFi
 
     public TiffContents readContents(ByteSource byteSource, Map params,
             FormatCompliance formatCompliance) throws ImageReadException,
-            IOException
-    {
+            IOException {
 
         Collector collector = new Collector(params);
         read(byteSource, params, formatCompliance, collector);
@@ -459,58 +414,56 @@ public class TiffReader extends BinaryFi
 
     public void read(ByteSource byteSource, Map params,
             FormatCompliance formatCompliance, Listener listener)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         // TiffContents contents =
         readDirectories(byteSource, formatCompliance, listener);
     }
 
     private TiffImageData getTiffRawImageData(ByteSource byteSource,
-            TiffDirectory directory) throws ImageReadException, IOException
-    {
+            TiffDirectory directory) throws ImageReadException, IOException {
 
-     
-        List<ImageDataElement> elements = directory.getTiffRawImageDataElements();
+        List<ImageDataElement> elements = directory
+                .getTiffRawImageDataElements();
         TiffImageData.Data data[] = new TiffImageData.Data[elements.size()];
-        
+
         if (byteSource instanceof ByteSourceFile) {
             ByteSourceFile bsf = (ByteSourceFile) byteSource;
             for (int i = 0; i < elements.size(); i++) {
-                TiffDirectory.ImageDataElement element = elements.get(i);          
-                data[i] = new TiffImageData.ByteSourceData(
-                        element.offset, element.length,
-                        bsf);
+                TiffDirectory.ImageDataElement element = elements.get(i);
+                data[i] = new TiffImageData.ByteSourceData(element.offset,
+                        element.length, bsf);
             }
         } else {
             for (int i = 0; i < elements.size(); i++) {
                 TiffDirectory.ImageDataElement element = elements.get(i);
-                byte bytes[] = byteSource.getBlock(element.offset, element.length);
-                data[i] = new TiffImageData.Data(element.offset, element.length,
-                        bytes);
+                byte bytes[] = byteSource.getBlock(element.offset,
+                        element.length);
+                data[i] = new TiffImageData.Data(element.offset,
+                        element.length, bytes);
             }
         }
 
-        if (directory.imageDataInStrips())
-        {
+        if (directory.imageDataInStrips()) {
             TiffField rowsPerStripField = directory
                     .findField(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP);
-            int rowsPerStrip ; 
+            int rowsPerStrip;
 
             if (null != rowsPerStripField) {
                 rowsPerStrip = rowsPerStripField.getIntValue();
             } else {
-                TiffField imageHeight = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH);
+                TiffField imageHeight = directory
+                        .findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH);
                 /**
-                 * if rows per strip not present then rowsPerStrip 
-                 * is equal to imageLength or an infinity value;
+                 * if rows per strip not present then rowsPerStrip is equal to
+                 * imageLength or an infinity value;
                  */
-                rowsPerStrip = imageHeight.getIntValue();           
+                rowsPerStrip = imageHeight.getIntValue();
             }
 
             return new TiffImageData.Strips(data, rowsPerStrip);
-        } else
-        {
-            TiffField tileWidthField = directory.findField(TiffTagConstants.TIFF_TAG_TILE_WIDTH);
+        } else {
+            TiffField tileWidthField = directory
+                    .findField(TiffTagConstants.TIFF_TAG_TILE_WIDTH);
             if (null == tileWidthField)
                 throw new ImageReadException("Can't find tile width field.");
             int tileWidth = tileWidthField.getIntValue();
@@ -526,8 +479,7 @@ public class TiffReader extends BinaryFi
     }
 
     private JpegImageData getJpegRawImageData(ByteSource byteSource,
-            TiffDirectory directory) throws ImageReadException, IOException
-    {
+            TiffDirectory directory) throws ImageReadException, IOException {
         ImageDataElement element = directory.getJpegRawImageDataElement();
         int offset = element.offset;
         int length = element.length;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AllTagConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AllTagConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AllTagConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AllTagConstants.java Sat May 26 21:19:03 2012
@@ -40,8 +40,7 @@ public interface AllTagConstants extends
         Tiff4TagConstants,
         TiffEpTagConstants,
         TiffTagConstants,
-        WangTagConstants
-{
+        WangTagConstants {
     public static final List<TagInfo> ALL_TAGS = Collections.unmodifiableList(
             TagConstantsUtils.mergeTagLists(
                     AdobePageMaker6TagConstants.ALL_ADOBE_PAGEMAKER_6_TAGS,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java Sat May 26 21:19:03 2012
@@ -28,9 +28,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoGpsText;
 
 public interface GpsTagConstants
-        extends
-            TiffFieldTypeConstants
-{
+        extends TiffFieldTypeConstants {
     public static final TagInfoByte GPS_TAG_GPS_VERSION_ID = new TagInfoByte(
             "GPS Version ID", 0x0000, 4,
             TiffDirectoryType.EXIF_DIRECTORY_GPS);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java Sat May 26 21:19:03 2012
@@ -22,12 +22,11 @@ import java.util.List;
 import org.apache.commons.imaging.common.BinaryConstant;
 import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
 
-public class TagConstantsUtils implements TiffDirectoryConstants
-{
-    private static final TiffDirectoryType[] tiffDirectoryTypes = TiffDirectoryType.values();
+public class TagConstantsUtils implements TiffDirectoryConstants {
+    private static final TiffDirectoryType[] tiffDirectoryTypes = TiffDirectoryType
+            .values();
 
-    public static List<TagInfo> mergeTagLists(List<TagInfo>... tagLists)
-    {
+    public static List<TagInfo> mergeTagLists(List<TagInfo>... tagLists) {
         int count = 0;
         for (int i = 0; i < tagLists.length; i++) {
             count += tagLists[i].size();
@@ -44,21 +43,20 @@ public class TagConstantsUtils implement
         return result;
     }
 
-    public static TiffDirectoryType getExifDirectoryType(int type)
-    {
-        
+    public static TiffDirectoryType getExifDirectoryType(int type) {
+
         for (int i = 0; i < tiffDirectoryTypes.length; i++)
             if (tiffDirectoryTypes[i].directoryType == type)
                 return tiffDirectoryTypes[i];
         return TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN;
     }
-    
+
     public static BinaryConstant createMicrosoftHdPhotoGuidEndingWith(byte end) {
-        return new BinaryConstant(new byte[] {
-                (byte)0x24, (byte)0xC3, (byte)0xDD, (byte)0x6F,
-                (byte)0x03, (byte)0x4E,
-                (byte)0xFE, (byte)0x4B,
-                (byte)0xB1, (byte)0x85, (byte)0x3D, (byte)0x77, (byte)0x76, (byte)0x8D, (byte)0xC9, end});
+        return new BinaryConstant(new byte[] { (byte) 0x24, (byte) 0xC3,
+                (byte) 0xDD, (byte) 0x6F, (byte) 0x03, (byte) 0x4E,
+                (byte) 0xFE, (byte) 0x4B, (byte) 0xB1, (byte) 0x85,
+                (byte) 0x3D, (byte) 0x77, (byte) 0x76, (byte) 0x8D,
+                (byte) 0xC9, end });
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffConstants.java Sat May 26 21:19:03 2012
@@ -25,8 +25,7 @@ public interface TiffConstants
             TiffFieldTypeConstants,
             TiffDirectoryConstants,
             AllTagConstants,
-            BinaryConstants
-{
+            BinaryConstants {
     public static final int DEFAULT_TIFF_BYTE_ORDER = BYTE_ORDER_INTEL;
 
     public static final int TIFF_HEADER_SIZE = 8;
@@ -68,4 +67,4 @@ public interface TiffConstants
     public static final int TIFF_FLAG_T4_OPTIONS_UNCOMPRESSED_MODE = 2;
     public static final int TIFF_FLAG_T4_OPTIONS_FILL = 4;
     public static final int TIFF_FLAG_T6_OPTIONS_UNCOMPRESSED_MODE = 2;
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffDirectoryConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffDirectoryConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffDirectoryConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffDirectoryConstants.java Sat May 26 21:19:03 2012
@@ -16,9 +16,8 @@
  */
 package org.apache.commons.imaging.formats.tiff.constants;
 
-public interface TiffDirectoryConstants
-{
-    
+public interface TiffDirectoryConstants {
+
     public static final int DIRECTORY_TYPE_UNKNOWN = -1;
     public static final int DIRECTORY_TYPE_ROOT = 0;
     public static final int DIRECTORY_TYPE_SUB = 1;
@@ -35,4 +34,4 @@ public interface TiffDirectoryConstants
     public static final int DIRECTORY_TYPE_DIR_2 = 2;
     public static final int DIRECTORY_TYPE_DIR_3 = 3;
     public static final int DIRECTORY_TYPE_DIR_4 = 4;
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java Sat May 26 21:19:03 2012
@@ -31,8 +31,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeShort;
 import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeUnknown;
 
-public interface TiffFieldTypeConstants extends ImagingConstants
-{
+public interface TiffFieldTypeConstants extends ImagingConstants {
 
     public static final FieldTypeByte FIELD_TYPE_BYTE = new FieldTypeByte(1,
             "Byte");
@@ -104,4 +103,4 @@ public interface TiffFieldTypeConstants 
     public static final List<FieldType> FIELD_TYPE_DESCRIPTION_ASCII_OR_BYTE =
             Collections.unmodifiableList(Arrays.asList(
                     FIELD_TYPE_ASCII, FIELD_TYPE_BYTE));
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java Sat May 26 21:19:03 2012
@@ -37,9 +37,7 @@ import org.apache.commons.imaging.format
  * http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf
  */
 public interface TiffTagConstants
-        extends
-            TiffFieldTypeConstants
-{
+        extends TiffFieldTypeConstants {
     public static final TagInfoLong TIFF_TAG_NEW_SUBFILE_TYPE = new TagInfoLong(
             "New Subfile Type", 0xFE, 1,
             TiffDirectoryType.TIFF_DIRECTORY_ROOT);
@@ -474,4 +472,4 @@ public interface TiffTagConstants
                     TIFF_TAG_YCBCR_POSITIONING, TIFF_TAG_REFERENCE_BLACK_WHITE,
                     TIFF_TAG_COPYRIGHT,
                     TIFF_TAG_XMP));
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -33,8 +33,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter;
 
-public abstract class DataReader implements TiffConstants, BinaryConstants
-{
+public abstract class DataReader implements TiffConstants, BinaryConstants {
     protected final TiffDirectory directory;
     protected final PhotometricInterpreter photometricInterpreter;
     protected final int bitsPerSample[];
@@ -45,10 +44,8 @@ public abstract class DataReader impleme
     protected final int width, height;
 
     public DataReader(TiffDirectory directory,
-            PhotometricInterpreter photometricInterpreter,
-            int bitsPerSample[], int predictor, int samplesPerPixel,
-            int width, int height)
-    {
+            PhotometricInterpreter photometricInterpreter, int bitsPerSample[],
+            int predictor, int samplesPerPixel, int width, int height) {
         this.directory = directory;
         this.photometricInterpreter = photometricInterpreter;
         this.bitsPerSample = bitsPerSample;
@@ -59,32 +56,32 @@ public abstract class DataReader impleme
         last = new int[samplesPerPixel];
     }
 
-    //    public abstract void readImageData(BufferedImage bi, ByteSource byteSource)
+    // public abstract void readImageData(BufferedImage bi, ByteSource
+    // byteSource)
     public abstract void readImageData(ImageBuilder imageBuilder)
             throws ImageReadException, IOException;
 
     /**
      * Reads samples and returns them in an int array.
-     * @param bis the stream to read from
-     * @param result the samples array to populate, must be the same length as bitsPerSample.length
+     * 
+     * @param bis
+     *            the stream to read from
+     * @param result
+     *            the samples array to populate, must be the same length as
+     *            bitsPerSample.length
      * @throws IOException
      */
     protected void getSamplesAsBytes(BitInputStream bis, int[] result)
-            throws IOException
-    {
-        for (int i = 0; i < bitsPerSample.length; i++)
-        {
+            throws IOException {
+        for (int i = 0; i < bitsPerSample.length; i++) {
             int bits = bitsPerSample[i];
             int sample = bis.readBits(bits);
-            if (bits < 8)
-            {
+            if (bits < 8) {
                 int sign = sample & 1;
                 sample = sample << (8 - bits); // scale to byte.
                 if (sign > 0)
                     sample = sample | ((1 << (8 - bits)) - 1); // extend to byte
-            }
-            else if (bits > 8)
-            {
+            } else if (bits > 8) {
                 sample = sample >> (bits - 8); // extend to byte.
             }
             result[i] = sample;
@@ -96,13 +93,11 @@ public abstract class DataReader impleme
             last[i] = 0;
         }
     }
-    
-    protected int[] applyPredictor(int samples[])
-    {
+
+    protected int[] applyPredictor(int samples[]) {
         if (predictor == 2) // Horizontal differencing.
         {
-            for (int i = 0; i < samples.length; i++)
-            {
+            for (int i = 0; i < samples.length; i++) {
                 samples[i] = 0xff & (samples[i] + last[i]);
                 last[i] = samples[i];
             }
@@ -114,9 +109,10 @@ public abstract class DataReader impleme
     private int count = 0;
 
     protected byte[] decompress(byte compressed[], int compression,
-            int expected_size, int tileWidth, int tileHeight) throws ImageReadException, IOException
-    {
-        TiffField fillOrderField = directory.findField(TiffTagConstants.TIFF_TAG_FILL_ORDER);
+            int expected_size, int tileWidth, int tileHeight)
+            throws ImageReadException, IOException {
+        TiffField fillOrderField = directory
+                .findField(TiffTagConstants.TIFF_TAG_FILL_ORDER);
         int fillOrder = TiffTagConstants.FILL_ORDER_VALUE_NORMAL;
         if (fillOrderField != null) {
             fillOrder = fillOrderField.getIntValue();
@@ -128,76 +124,83 @@ public abstract class DataReader impleme
                 compressed[i] = (byte) (Integer.reverse(0xff & compressed[i]) >>> 24);
             }
         } else {
-            throw new ImageReadException("TIFF FillOrder=" + fillOrder + " is invalid");
+            throw new ImageReadException("TIFF FillOrder=" + fillOrder
+                    + " is invalid");
         }
-        
-        switch (compression)
+
+        switch (compression) {
+        case TIFF_COMPRESSION_UNCOMPRESSED: // None;
+            return compressed;
+        case TIFF_COMPRESSION_CCITT_1D: // CCITT Group 3 1-Dimensional Modified
+                                        // Huffman run-length encoding.
+            return T4AndT6Compression.decompressModifiedHuffman(compressed,
+                    tileWidth, tileHeight);
+        case TIFF_COMPRESSION_CCITT_GROUP_3: {
+            int t4Options = 0;
+            TiffField field = directory
+                    .findField(TiffTagConstants.TIFF_TAG_T4_OPTIONS);
+            if (field != null) {
+                t4Options = field.getIntValue();
+            }
+            boolean is2D = (t4Options & TIFF_FLAG_T4_OPTIONS_2D) != 0;
+            boolean usesUncompressedMode = (t4Options & TIFF_FLAG_T4_OPTIONS_UNCOMPRESSED_MODE) != 0;
+            if (usesUncompressedMode) {
+                throw new ImageReadException(
+                        "T.4 compression with the uncompressed mode extension is not yet supported");
+            }
+            boolean hasFillBitsBeforeEOL = (t4Options & TIFF_FLAG_T4_OPTIONS_FILL) != 0;
+            if (is2D) {
+                return T4AndT6Compression.decompressT4_2D(compressed,
+                        tileWidth, tileHeight, hasFillBitsBeforeEOL);
+            } else {
+                return T4AndT6Compression.decompressT4_1D(compressed,
+                        tileWidth, tileHeight, hasFillBitsBeforeEOL);
+            }
+        }
+        case TIFF_COMPRESSION_CCITT_GROUP_4: {
+            int t6Options = 0;
+            TiffField field = directory
+                    .findField(TiffTagConstants.TIFF_TAG_T6_OPTIONS);
+            if (field != null) {
+                t6Options = field.getIntValue();
+            }
+            boolean usesUncompressedMode = (t6Options & TIFF_FLAG_T6_OPTIONS_UNCOMPRESSED_MODE) != 0;
+            if (usesUncompressedMode) {
+                throw new ImageReadException(
+                        "T.6 compression with the uncompressed mode extension is not yet supported");
+            }
+            return T4AndT6Compression.decompressT6(compressed, tileWidth,
+                    tileHeight);
+        }
+        case TIFF_COMPRESSION_LZW: // LZW
         {
-            case TIFF_COMPRESSION_UNCOMPRESSED : // None;
-                return compressed;
-            case TIFF_COMPRESSION_CCITT_1D : // CCITT Group 3 1-Dimensional Modified Huffman run-length encoding.
-                return T4AndT6Compression.decompressModifiedHuffman(compressed, tileWidth, tileHeight);
-            case TIFF_COMPRESSION_CCITT_GROUP_3 :
-            {
-                int t4Options = 0;
-                TiffField field = directory.findField(TiffTagConstants.TIFF_TAG_T4_OPTIONS);
-                if (field != null) {
-                    t4Options = field.getIntValue();
-                }
-                boolean is2D = (t4Options & TIFF_FLAG_T4_OPTIONS_2D) != 0;
-                boolean usesUncompressedMode = (t4Options & TIFF_FLAG_T4_OPTIONS_UNCOMPRESSED_MODE) != 0;
-                if (usesUncompressedMode) {
-                    throw new ImageReadException("T.4 compression with the uncompressed mode extension is not yet supported");
-                }
-                boolean hasFillBitsBeforeEOL = (t4Options & TIFF_FLAG_T4_OPTIONS_FILL) != 0;
-                if (is2D) {
-                    return T4AndT6Compression.decompressT4_2D(compressed, tileWidth, tileHeight, hasFillBitsBeforeEOL);
-                } else {
-                    return T4AndT6Compression.decompressT4_1D(compressed, tileWidth, tileHeight, hasFillBitsBeforeEOL);
-                }
-            }
-            case TIFF_COMPRESSION_CCITT_GROUP_4 :
-            {
-                int t6Options = 0;
-                TiffField field = directory.findField(TiffTagConstants.TIFF_TAG_T6_OPTIONS);
-                if (field != null) {
-                    t6Options = field.getIntValue();
-                }
-                boolean usesUncompressedMode = (t6Options & TIFF_FLAG_T6_OPTIONS_UNCOMPRESSED_MODE) != 0;
-                if (usesUncompressedMode) {
-                    throw new ImageReadException("T.6 compression with the uncompressed mode extension is not yet supported");
-                }
-                return T4AndT6Compression.decompressT6(compressed, tileWidth, tileHeight);
-            }
-            case TIFF_COMPRESSION_LZW : // LZW
-            {
-                InputStream is = new ByteArrayInputStream(compressed);
-
-                int LZWMinimumCodeSize = 8;
-
-                MyLzwDecompressor myLzwDecompressor = new MyLzwDecompressor(
-                        LZWMinimumCodeSize, BYTE_ORDER_NETWORK);
-
-                myLzwDecompressor.setTiffLZWMode();
-
-                byte[] result = myLzwDecompressor.decompress(is, expected_size);
-
-                return result;
-            }
-
-            case TIFF_COMPRESSION_PACKBITS : // Packbits
-            {
-                byte unpacked[] = new PackBits().decompress(compressed,
-                        expected_size);
-                count++;
-
-                return unpacked;
-            }
-
-            default :
-                throw new ImageReadException("Tiff: unknown/unsupported compression: "
-                        + compression);
+            InputStream is = new ByteArrayInputStream(compressed);
+
+            int LZWMinimumCodeSize = 8;
+
+            MyLzwDecompressor myLzwDecompressor = new MyLzwDecompressor(
+                    LZWMinimumCodeSize, BYTE_ORDER_NETWORK);
+
+            myLzwDecompressor.setTiffLZWMode();
+
+            byte[] result = myLzwDecompressor.decompress(is, expected_size);
+
+            return result;
+        }
+
+        case TIFF_COMPRESSION_PACKBITS: // Packbits
+        {
+            byte unpacked[] = new PackBits().decompress(compressed,
+                    expected_size);
+            count++;
+
+            return unpacked;
+        }
+
+        default:
+            throw new ImageReadException(
+                    "Tiff: unknown/unsupported compression: " + compression);
         }
     }
 
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -26,8 +26,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.TiffImageData;
 import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter;
 
-public final class DataReaderStrips extends DataReader
-{
+public final class DataReaderStrips extends DataReader {
 
     private final int bitsPerPixel;
     private final int compression;
@@ -37,12 +36,12 @@ public final class DataReaderStrips exte
     private final TiffImageData.Strips imageData;
 
     public DataReaderStrips(TiffDirectory directory,
-            PhotometricInterpreter photometricInterpreter,
-            int bitsPerPixel, int bitsPerSample[], int predictor,
-            int samplesPerPixel, int width, int height, int compression,
-            int byteOrder, int rowsPerStrip, TiffImageData.Strips imageData)
-    {
-        super(directory, photometricInterpreter, bitsPerSample, predictor, samplesPerPixel, width, height);
+            PhotometricInterpreter photometricInterpreter, int bitsPerPixel,
+            int bitsPerSample[], int predictor, int samplesPerPixel, int width,
+            int height, int compression, int byteOrder, int rowsPerStrip,
+            TiffImageData.Strips imageData) {
+        super(directory, photometricInterpreter, bitsPerSample, predictor,
+                samplesPerPixel, width, height);
 
         this.bitsPerPixel = bitsPerPixel;
         this.compression = compression;
@@ -52,8 +51,7 @@ public final class DataReaderStrips exte
     }
 
     private void interpretStrip(ImageBuilder imageBuilder, byte bytes[],
-            int pixels_per_strip) throws ImageReadException, IOException
-    {
+            int pixels_per_strip) throws ImageReadException, IOException {
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         BitInputStream bis = new BitInputStream(bais, byteOrder);
 
@@ -62,20 +60,18 @@ public final class DataReaderStrips exte
         }
         int[] samples = new int[bitsPerSample.length];
         resetPredictor();
-        for (int i = 0; i < pixels_per_strip; i++)
-        {
+        for (int i = 0; i < pixels_per_strip; i++) {
             getSamplesAsBytes(bis, samples);
 
-            if (x < width)
-            {
+            if (x < width) {
                 samples = applyPredictor(samples);
 
-                photometricInterpreter.interpretPixel(imageBuilder, samples, x, y);
+                photometricInterpreter.interpretPixel(imageBuilder, samples, x,
+                        y);
             }
 
             x++;
-            if (x >= width)
-            {
+            if (x >= width) {
                 x = 0;
                 resetPredictor();
                 y++;
@@ -89,11 +85,9 @@ public final class DataReaderStrips exte
     private int x = 0, y = 0;
 
     @Override
-    public void readImageData(ImageBuilder imageBuilder) throws ImageReadException,
-            IOException
-    {
-        for (int strip = 0; strip < imageData.strips.length; strip++)
-        {
+    public void readImageData(ImageBuilder imageBuilder)
+            throws ImageReadException, IOException {
+        for (int strip = 0; strip < imageData.strips.length; strip++) {
             long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
             long rowsRemaining = height - (strip * rowsPerStripLong);
             long rowsInThisStrip = Math.min(rowsRemaining, rowsPerStripLong);
@@ -104,9 +98,9 @@ public final class DataReaderStrips exte
             byte compressed[] = imageData.strips[strip].getData();
 
             byte decompressed[] = decompress(compressed, compression,
-                    (int)bytesPerStrip, width, (int)rowsInThisStrip);
+                    (int) bytesPerStrip, width, (int) rowsInThisStrip);
 
-            interpretStrip(imageBuilder, decompressed, (int)pixelsPerStrip);
+            interpretStrip(imageBuilder, decompressed, (int) pixelsPerStrip);
 
         }
     }

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -26,8 +26,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.TiffImageData;
 import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter;
 
-public final class DataReaderTiled extends DataReader
-{
+public final class DataReaderTiled extends DataReader {
 
     private final int tileWidth;
     private final int tileLength;
@@ -40,12 +39,12 @@ public final class DataReaderTiled exten
     private final TiffImageData.Tiles imageData;
 
     public DataReaderTiled(TiffDirectory directory,
-            PhotometricInterpreter photometricInterpreter,
-            int tileWidth, int tileLength, int bitsPerPixel,
-            int bitsPerSample[], int predictor, int samplesPerPixel, int width,
-            int height, int compression, int byteOrder, TiffImageData.Tiles imageData)
-    {
-        super(directory, photometricInterpreter, bitsPerSample, predictor, samplesPerPixel, width, height);
+            PhotometricInterpreter photometricInterpreter, int tileWidth,
+            int tileLength, int bitsPerPixel, int bitsPerSample[],
+            int predictor, int samplesPerPixel, int width, int height,
+            int compression, int byteOrder, TiffImageData.Tiles imageData) {
+        super(directory, photometricInterpreter, bitsPerSample, predictor,
+                samplesPerPixel, width, height);
 
         this.tileWidth = tileWidth;
         this.tileLength = tileLength;
@@ -57,9 +56,8 @@ public final class DataReaderTiled exten
         this.byteOrder = byteOrder;
     }
 
-    private void interpretTile(ImageBuilder imageBuilder, byte bytes[], int startX,
-            int startY) throws ImageReadException, IOException
-    {
+    private void interpretTile(ImageBuilder imageBuilder, byte bytes[],
+            int startX, int startY) throws ImageReadException, IOException {
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         BitInputStream bis = new BitInputStream(bais, byteOrder);
 
@@ -69,24 +67,22 @@ public final class DataReaderTiled exten
 
         int[] samples = new int[bitsPerSample.length];
         resetPredictor();
-        for (int i = 0; i < pixelsPerTile; i++)
-        {
+        for (int i = 0; i < pixelsPerTile; i++) {
 
             int x = tileX + startX;
             int y = tileY + startY;
 
             getSamplesAsBytes(bis, samples);
 
-            if ((x < width) && (y < height))
-            {
+            if ((x < width) && (y < height)) {
                 samples = applyPredictor(samples);
-                photometricInterpreter.interpretPixel(imageBuilder, samples, x, y);
+                photometricInterpreter.interpretPixel(imageBuilder, samples, x,
+                        y);
             }
 
             tileX++;
 
-            if (tileX >= tileWidth)
-            {
+            if (tileX >= tileWidth) {
                 tileX = 0;
                 resetPredictor();
                 tileY++;
@@ -99,16 +95,14 @@ public final class DataReaderTiled exten
     }
 
     @Override
-    public void readImageData(ImageBuilder imageBuilder) throws ImageReadException,
-            IOException
-    {
+    public void readImageData(ImageBuilder imageBuilder)
+            throws ImageReadException, IOException {
         int bitsPerRow = tileWidth * bitsPerPixel;
         int bytesPerRow = (bitsPerRow + 7) / 8;
         int bytesPerTile = bytesPerRow * tileLength;
         int x = 0, y = 0;
 
-        for (int tile = 0; tile < imageData.tiles.length; tile++)
-        {
+        for (int tile = 0; tile < imageData.tiles.length; tile++) {
             byte compressed[] = imageData.tiles[tile].getData();
 
             byte decompressed[] = decompress(compressed, compression,
@@ -117,8 +111,7 @@ public final class DataReaderTiled exten
             interpretTile(imageBuilder, decompressed, x, y);
 
             x += tileWidth;
-            if (x >= width)
-            {
+            if (x >= width) {
                 x = 0;
                 y += tileLength;
                 if (y >= height)

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java Sat May 26 21:19:03 2012
@@ -23,20 +23,17 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 
 public abstract class FieldType extends BinaryFileFunctions implements
-        TiffConstants
-{
+        TiffConstants {
     public final int type, length;
     public final String name;
 
-    public FieldType(int type, int length, String name)
-    {
+    public FieldType(int type, int length, String name) {
         this.type = type;
         this.length = length;
         this.name = name;
     }
 
-    public boolean isLocalValue(TiffField entry)
-    {
+    public boolean isLocalValue(TiffField entry) {
         // FIXME: we should use unsigned ints for offsets and lengths
         // when parsing TIFF files. But since we don't,
         // at least make this method treat length as unsigned,
@@ -45,8 +42,7 @@ public abstract class FieldType extends 
         return ((length > 0) && ((length * entryLength) <= TIFF_ENTRY_MAX_VALUE_LENGTH));
     }
 
-    public int getBytesLength(TiffField entry) throws ImageReadException
-    {
+    public int getBytesLength(TiffField entry) throws ImageReadException {
         if (length < 1)
             throw new ImageReadException("Unknown field type");
 
@@ -56,34 +52,29 @@ public abstract class FieldType extends 
     // public static final byte[] STUB_LOCAL_VALUE = new
     // byte[TIFF_ENTRY_MAX_VALUE_LENGTH];
 
-    public static final byte[] getStubLocalValue()
-    {
+    public static final byte[] getStubLocalValue() {
         return new byte[TIFF_ENTRY_MAX_VALUE_LENGTH];
     }
 
-    public final byte[] getStubValue(int count)
-    {
+    public final byte[] getStubValue(int count) {
         return new byte[count * length];
     }
 
-    public String getDisplayValue(TiffField entry) throws ImageReadException
-    {
+    public String getDisplayValue(TiffField entry) throws ImageReadException {
         Object o = getSimpleValue(entry);
         if (o == null)
             return "NULL";
         return o.toString();
     }
 
-    public final byte[] getRawBytes(TiffField entry)
-    {
-        if (isLocalValue(entry))
-        {
+    public final byte[] getRawBytes(TiffField entry) {
+        if (isLocalValue(entry)) {
             int rawLength = length * entry.length;
             byte result[] = new byte[rawLength];
             System.arraycopy(entry.valueOffsetBytes, 0, result, 0, rawLength);
             return result;
-//            return readBytearray(name, entry.valueOffsetBytes, 0, length
-//                    * entry.length);
+            // return readBytearray(name, entry.valueOffsetBytes, 0, length
+            // * entry.length);
             // return getBytearrayHead(name + " (" + entry.tagInfo.name + ")",
             // entry.valueOffsetBytes, length * entry.length);
         }
@@ -107,8 +98,7 @@ public abstract class FieldType extends 
     // public abstract Object[] getValueArray(TiffField entry);
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return "[" + getClass().getName() + ". type: " + type + ", name: "
                 + name + ", length: " + length + "]";
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java Sat May 26 21:19:03 2012
@@ -21,16 +21,15 @@ import java.io.UnsupportedEncodingExcept
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.formats.tiff.TiffField;
 
-public class FieldTypeAscii extends FieldType
-{
-    public FieldTypeAscii(int type, String name)
-    {
+public class FieldTypeAscii extends FieldType {
+    public FieldTypeAscii(int type, String name) {
         super(type, 1, name);
     }
 
     @Override
     public Object getSimpleValue(TiffField entry) {
-        // According to EXIF specification "2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL."
+        // According to EXIF specification
+        // "2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL."
         byte bytes[] = getRawBytes(entry);
         int nullCount = 1;
         for (int i = 0; i < bytes.length - 1; i++) {
@@ -48,7 +47,8 @@ public class FieldTypeAscii extends Fiel
         for (int i = 0; i < bytes.length; i++) {
             if (bytes[i] == 0) {
                 try {
-                    String string = new String(bytes, nextStringPos, i - nextStringPos, "UTF-8");
+                    String string = new String(bytes, nextStringPos, i
+                            - nextStringPos, "UTF-8");
                     strings[stringsAdded++] = string;
                 } catch (UnsupportedEncodingException unsupportedEncoding) {
                 }
@@ -58,7 +58,8 @@ public class FieldTypeAscii extends Fiel
         if (nextStringPos < bytes.length) {
             // Buggy file, string wasn't null terminated
             try {
-                String string = new String(bytes, nextStringPos, bytes.length - nextStringPos, "UTF-8");
+                String string = new String(bytes, nextStringPos, bytes.length
+                        - nextStringPos, "UTF-8");
                 strings[stringsAdded++] = string;
             } catch (UnsupportedEncodingException unsupportedEncoding) {
             }
@@ -71,8 +72,7 @@ public class FieldTypeAscii extends Fiel
     }
 
     @Override
-    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException
-    {
+    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
         if (o instanceof byte[]) {
             byte bytes[] = (byte[]) o;
             byte result[] = new byte[bytes.length + 1];
@@ -90,7 +90,7 @@ public class FieldTypeAscii extends Fiel
             result[result.length - 1] = 0;
             return result;
         } else if (o instanceof String[]) {
-            String[] strings = (String[])o;
+            String[] strings = (String[]) o;
             int totalLength = 0;
             for (int i = 0; i < strings.length; i++) {
                 byte[] bytes = null;
@@ -112,9 +112,8 @@ public class FieldTypeAscii extends Fiel
                 position += (bytes.length + 1);
             }
             return result;
-        }
-        else
+        } else
             throw new ImageWriteException("Unknown data type: " + o);
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java Sat May 26 21:19:03 2012
@@ -20,16 +20,13 @@ import org.apache.commons.imaging.ImageW
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.util.Debug;
 
-public class FieldTypeByte extends FieldType
-{
-    public FieldTypeByte(int type, String name)
-    {
+public class FieldTypeByte extends FieldType {
+    public FieldTypeByte(int type, String name) {
         super(type, 1, name);
     }
 
     @Override
-    public Object getSimpleValue(TiffField entry)
-    {
+    public Object getSimpleValue(TiffField entry) {
         if (entry.length == 1)
             return entry.valueOffsetBytes[0];
 
@@ -37,12 +34,9 @@ public class FieldTypeByte extends Field
     }
 
     @Override
-    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException
-    {
+    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
         if (o instanceof Byte)
-            return new byte[]{
-                ((Byte) o).byteValue(),
-            };
+            return new byte[] { ((Byte) o).byteValue(), };
         else if (o instanceof byte[])
             return (byte[]) o;
         else
@@ -50,4 +44,4 @@ public class FieldTypeByte extends Field
                     + Debug.getType(o) + ")");
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java Sat May 26 21:19:03 2012
@@ -20,41 +20,33 @@ import org.apache.commons.imaging.ImageW
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.util.Debug;
 
-public class FieldTypeDouble extends FieldType
-{
-    public FieldTypeDouble()
-    {
+public class FieldTypeDouble extends FieldType {
+    public FieldTypeDouble() {
         super(12, 8, "Double");
     }
 
     @Override
-    public Object getSimpleValue(TiffField entry)
-    {
+    public Object getSimpleValue(TiffField entry) {
         return "?";
     }
 
     @Override
-    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException
-    {
+    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
         if (o instanceof Double)
             return convertDoubleToByteArray(((Double) o).doubleValue(),
                     byteOrder);
-        else if (o instanceof double[])
-        {
+        else if (o instanceof double[]) {
             double numbers[] = (double[]) o;
             return convertDoubleArrayToByteArray(numbers, byteOrder);
-        }
-        else if (o instanceof Double[])
-        {
+        } else if (o instanceof Double[]) {
             Double numbers[] = (Double[]) o;
             double values[] = new double[numbers.length];
             for (int i = 0; i < values.length; i++)
                 values[i] = numbers[i].doubleValue();
             return convertDoubleArrayToByteArray(values, byteOrder);
-        }
-        else
+        } else
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java Sat May 26 21:19:03 2012
@@ -20,18 +20,15 @@ import org.apache.commons.imaging.ImageW
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.util.Debug;
 
-public class FieldTypeFloat extends FieldType
-{
-    public FieldTypeFloat()
-    {
+public class FieldTypeFloat extends FieldType {
+    public FieldTypeFloat() {
         super(11, 4, "Float");
     }
 
-    //    = new FieldType(11, 4, "Float")
+    // = new FieldType(11, 4, "Float")
 
     @Override
-    public Object getSimpleValue(TiffField entry)
-    {
+    public Object getSimpleValue(TiffField entry) {
         if (entry.length == 1)
             return new Float(convertByteArrayToFloat(name + " ("
                     + entry.tagInfo.name + ")", entry.valueOffsetBytes,
@@ -42,26 +39,21 @@ public class FieldTypeFloat extends Fiel
     }
 
     @Override
-    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException
-    {
+    public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
         if (o instanceof Float)
             return convertFloatToByteArray(((Float) o).floatValue(), byteOrder);
-        else if (o instanceof float[])
-        {
+        else if (o instanceof float[]) {
             float numbers[] = (float[]) o;
             return convertFloatArrayToByteArray(numbers, byteOrder);
-        }
-        else if (o instanceof Float[])
-        {
+        } else if (o instanceof Float[]) {
             Float numbers[] = (Float[]) o;
             float values[] = new float[numbers.length];
             for (int i = 0; i < values.length; i++)
                 values[i] = numbers[i].floatValue();
             return convertFloatArrayToByteArray(values, byteOrder);
-        }
-        else
+        } else
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
     }
 
-}
\ No newline at end of file
+}