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/09/27 07:42:26 UTC

svn commit: r1390849 [1/3] - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats: bmp/ bmp/pixelparsers/ bmp/writers/ dcx/ gif/ icns/ ico/ jpeg/ jpeg/decoder/ jpeg/exif/ jpeg/iptc/ jpeg/segments/ jpeg/xmp/

Author: damjan
Date: Thu Sep 27 05:42:25 2012
New Revision: 1390849

URL: http://svn.apache.org/viewvc?rev=1390849&view=rev
Log:
More braces.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GenericGifBlock.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
    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/JpegImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.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/decoder/JpegInputStream.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/YCbCrConverter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/JpegIptcRewriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/PhotoshopApp13Data.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App13Segment.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/DhtSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/Segment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java Thu Sep 27 05:42:25 2012
@@ -295,10 +295,12 @@ public class BmpImageParser extends Imag
                     break;
                 default: {
                     int size = b / RLESamplesPerByte;
-                    if ((b % RLESamplesPerByte) > 0)
+                    if ((b % RLESamplesPerByte) > 0) {
                         size++;
-                    if ((size % 2) != 0)
+                    }
+                    if ((size % 2) != 0) {
                         size++;
+                    }
 
                     // System.out.println("b: " + b);
                     // System.out.println("size: " + size);
@@ -324,8 +326,9 @@ public class BmpImageParser extends Imag
         BmpHeaderInfo bhi = readBmpHeaderInfo(is, formatCompliance, verbose);
 
         int colorTableSize = bhi.colorsUsed;
-        if (colorTableSize == 0)
+        if (colorTableSize == 0) {
             colorTableSize = (1 << bhi.bitsPerPixel);
+        }
 
         if (verbose) {
             this.debugNumber("ColorsUsed", bhi.colorsUsed, 4);
@@ -344,12 +347,14 @@ public class BmpImageParser extends Imag
 
         switch (bhi.compression) {
         case BI_RGB:
-            if (verbose)
+            if (verbose) {
                 System.out.println("Compression: BI_RGB");
-            if (bhi.bitsPerPixel <= 8)
+            }
+            if (bhi.bitsPerPixel <= 8) {
                 paletteLength = 4 * colorTableSize;
-            else
+            } else {
                 paletteLength = 0;
+            }
             // BytesPerPaletteEntry = 0;
             // System.out.println("Compression: BI_RGBx2: " + bhi.BitsPerPixel);
             // System.out.println("Compression: BI_RGBx2: " + (bhi.BitsPerPixel
@@ -357,8 +362,9 @@ public class BmpImageParser extends Imag
             break;
 
         case BI_RLE4:
-            if (verbose)
+            if (verbose) {
                 System.out.println("Compression: BI_RLE4");
+            }
             paletteLength = 4 * colorTableSize;
             rleSamplesPerByte = 2;
             // ExtraBitsPerPixel = 4;
@@ -368,8 +374,9 @@ public class BmpImageParser extends Imag
             break;
         //
         case BI_RLE8:
-            if (verbose)
+            if (verbose) {
                 System.out.println("Compression: BI_RLE8");
+            }
             paletteLength = 4 * colorTableSize;
             rleSamplesPerByte = 1;
             // ExtraBitsPerPixel = 8;
@@ -379,12 +386,14 @@ public class BmpImageParser extends Imag
             break;
         //
         case BI_BITFIELDS:
-            if (verbose)
+            if (verbose) {
                 System.out.println("Compression: BI_BITFIELDS");
-            if (bhi.bitsPerPixel <= 8)
+            }
+            if (bhi.bitsPerPixel <= 8) {
                 paletteLength = 4 * colorTableSize;
-            else
+            } else {
                 paletteLength = 0;
+            }
             // BytesPerPixel = 2;
             // BytesPerPaletteEntry = 4;
             break;
@@ -395,9 +404,10 @@ public class BmpImageParser extends Imag
         }
 
         byte colorTable[] = null;
-        if (paletteLength > 0)
+        if (paletteLength > 0) {
             colorTable = this.readByteArray("ColorTable", paletteLength, is,
                     "Not a Valid BMP File");
+        }
 
         if (verbose) {
             this.debugNumber("paletteLength", paletteLength, 4);
@@ -422,8 +432,9 @@ public class BmpImageParser extends Imag
             this.debugNumber("PixelCount", pixelCount, 4);
         }
         // int ImageLineLength = BytesPerPixel * bhi.Width;
-        while ((imageLineLength % 4) != 0)
+        while ((imageLineLength % 4) != 0) {
             imageLineLength++;
+        }
 
         final int headerSize = BITMAP_FILE_HEADER_SIZE
                 + bhi.bitmapHeaderSize
@@ -436,29 +447,33 @@ public class BmpImageParser extends Imag
             this.debugNumber("expectedDataOffset", expectedDataOffset, 4);
         }
         int extraBytes = bhi.bitmapDataOffset - expectedDataOffset;
-        if (extraBytes < 0)
+        if (extraBytes < 0) {
             throw new ImageReadException("BMP has invalid image data offset: "
                     + bhi.bitmapDataOffset + " (expected: "
                     + expectedDataOffset + ", paletteLength: " + paletteLength
                     + ", headerSize: " + headerSize + ")");
-        else if (extraBytes > 0)
+        } else if (extraBytes > 0) {
             this.readByteArray("BitmapDataOffset", extraBytes, is,
                     "Not a Valid BMP File");
+        }
 
         int imageDataSize = bhi.height * imageLineLength;
 
-        if (verbose)
+        if (verbose) {
             this.debugNumber("imageDataSize", imageDataSize, 4);
+        }
 
         byte imageData[];
-        if (rle)
+        if (rle) {
             imageData = getRLEBytes(is, rleSamplesPerByte);
-        else
+        } else {
             imageData = this.readByteArray("ImageData", imageDataSize, is,
                     "Not a Valid BMP File");
+        }
 
-        if (verbose)
+        if (verbose) {
             this.debugNumber("ImageData.length", imageData.length, 4);
+        }
 
         PixelParser pixelParser;
 
@@ -516,8 +531,9 @@ public class BmpImageParser extends Imag
         boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
                 false);
 
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -526,8 +542,9 @@ public class BmpImageParser extends Imag
 
         BmpHeaderInfo bhi = readBmpHeaderInfo(byteSource, verbose);
 
-        if (bhi == null)
+        if (bhi == null) {
             throw new ImageReadException("BMP: couldn't read header");
+        }
 
         return new Dimension(bhi.width, bhi.height);
 
@@ -549,18 +566,24 @@ public class BmpImageParser extends Imag
     }
 
     private String getBmpTypeDescription(int Identifier1, int Identifier2) {
-        if ((Identifier1 == 'B') && (Identifier2 == 'M'))
+        if ((Identifier1 == 'B') && (Identifier2 == 'M')) {
             return "Windows 3.1x, 95, NT,";
-        if ((Identifier1 == 'B') && (Identifier2 == 'A'))
+        }
+        if ((Identifier1 == 'B') && (Identifier2 == 'A')) {
             return "OS/2 Bitmap Array";
-        if ((Identifier1 == 'C') && (Identifier2 == 'I'))
+        }
+        if ((Identifier1 == 'C') && (Identifier2 == 'I')) {
             return "OS/2 Color Icon";
-        if ((Identifier1 == 'C') && (Identifier2 == 'P'))
+        }
+        if ((Identifier1 == 'C') && (Identifier2 == 'P')) {
             return "OS/2 Color Pointer";
-        if ((Identifier1 == 'I') && (Identifier2 == 'C'))
+        }
+        if ((Identifier1 == 'I') && (Identifier2 == 'C')) {
             return "OS/2 Icon";
-        if ((Identifier1 == 'P') && (Identifier2 == 'T'))
+        }
+        if ((Identifier1 == 'P') && (Identifier2 == 'T')) {
             return "OS/2 Pointer";
+        }
 
         return "Unknown";
     }
@@ -574,8 +597,9 @@ public class BmpImageParser extends Imag
         boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
                 false);
 
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -597,14 +621,16 @@ public class BmpImageParser extends Imag
             }
         }
 
-        if (ic == null)
+        if (ic == null) {
             throw new ImageReadException("Couldn't read BMP Data");
+        }
 
         BmpHeaderInfo bhi = ic.bhi;
         byte colorTable[] = ic.colorTable;
 
-        if (bhi == null)
+        if (bhi == null) {
             throw new ImageReadException("BMP: couldn't read header");
+        }
 
         int height = bhi.height;
         int width = bhi.width;
@@ -713,10 +739,12 @@ public class BmpImageParser extends Imag
         boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
                 false);
 
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
-        if (params.containsKey(BUFFERED_IMAGE_FACTORY))
+        }
+        if (params.containsKey(BUFFERED_IMAGE_FACTORY)) {
             params.remove(BUFFERED_IMAGE_FACTORY);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -725,8 +753,9 @@ public class BmpImageParser extends Imag
 
         ImageContents ic = readImageContents(inputStream,
                 FormatCompliance.getDefault(), verbose);
-        if (ic == null)
+        if (ic == null) {
             throw new ImageReadException("Couldn't read BMP Data");
+        }
 
         BmpHeaderInfo bhi = ic.bhi;
         // byte colorTable[] = ic.colorTable;
@@ -762,12 +791,13 @@ public class BmpImageParser extends Imag
         PixelDensity pixelDensity = null;
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
-        if (params.containsKey(PARAM_KEY_PIXEL_DENSITY))
+        }
+        if (params.containsKey(PARAM_KEY_PIXEL_DENSITY)) {
             pixelDensity = (PixelDensity) params
                     .remove(PARAM_KEY_PIXEL_DENSITY);
-
+        }
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
@@ -777,60 +807,57 @@ public class BmpImageParser extends Imag
                 src, 256);
 
         BmpWriter writer = null;
-        if (palette == null)
+        if (palette == null) {
             writer = new BmpWriterRgb();
-        else
+        } else {
             writer = new BmpWriterPalette(palette);
+        }
 
         byte imagedata[] = writer.getImageData(src);
         BinaryOutputStream bos = new BinaryOutputStream(os, BYTE_ORDER_INTEL);
 
-        {
-            // write BitmapFileHeader
-            os.write(0x42); // B, Windows 3.1x, 95, NT, Bitmap
-            os.write(0x4d); // M
-
-            int filesize = BITMAP_FILE_HEADER_SIZE + BITMAP_INFO_HEADER_SIZE + // header
-                    // size
-                    4 * writer.getPaletteSize() + // palette size in bytes
-                    imagedata.length;
-            bos.write4Bytes(filesize);
-
-            bos.write4Bytes(0); // reserved
-            bos.write4Bytes(BITMAP_FILE_HEADER_SIZE + BITMAP_INFO_HEADER_SIZE
-                    + 4 * writer.getPaletteSize()); // Bitmap Data Offset
-        }
+        // write BitmapFileHeader
+        os.write(0x42); // B, Windows 3.1x, 95, NT, Bitmap
+        os.write(0x4d); // M
+
+        int filesize = BITMAP_FILE_HEADER_SIZE + BITMAP_INFO_HEADER_SIZE + // header
+                // size
+                4 * writer.getPaletteSize() + // palette size in bytes
+                imagedata.length;
+        bos.write4Bytes(filesize);
+
+        bos.write4Bytes(0); // reserved
+        bos.write4Bytes(BITMAP_FILE_HEADER_SIZE + BITMAP_INFO_HEADER_SIZE
+                + 4 * writer.getPaletteSize()); // Bitmap Data Offset
 
         int width = src.getWidth();
         int height = src.getHeight();
 
-        { // write BitmapInfoHeader
-            bos.write4Bytes(BITMAP_INFO_HEADER_SIZE); // Bitmap Info Header Size
-            bos.write4Bytes(width); // width
-            bos.write4Bytes(height); // height
-            bos.write2Bytes(1); // Number of Planes
-            bos.write2Bytes(writer.getBitsPerPixel()); // Bits Per Pixel
-
-            bos.write4Bytes(BI_RGB); // Compression
-            bos.write4Bytes(imagedata.length); // Bitmap Data Size
-            bos.write4Bytes(pixelDensity != null ? (int) Math
-                    .round(pixelDensity.horizontalDensityMetres()) : 0); // HResolution
-            bos.write4Bytes(pixelDensity != null ? (int) Math
-                    .round(pixelDensity.verticalDensityMetres()) : 0); // VResolution
-            if (palette == null)
-                bos.write4Bytes(0); // Colors
-            else
-                bos.write4Bytes(palette.length()); // Colors
-            bos.write4Bytes(0); // Important Colors
-            // bos.write_4_bytes(0); // Compression
-        }
-
-        { // write Palette
-            writer.writePalette(bos);
-        }
-        { // write Image Data
-            bos.writeByteArray(imagedata);
-        }
+        // write BitmapInfoHeader
+        bos.write4Bytes(BITMAP_INFO_HEADER_SIZE); // Bitmap Info Header Size
+        bos.write4Bytes(width); // width
+        bos.write4Bytes(height); // height
+        bos.write2Bytes(1); // Number of Planes
+        bos.write2Bytes(writer.getBitsPerPixel()); // Bits Per Pixel
+
+        bos.write4Bytes(BI_RGB); // Compression
+        bos.write4Bytes(imagedata.length); // Bitmap Data Size
+        bos.write4Bytes(pixelDensity != null ? (int) Math
+                .round(pixelDensity.horizontalDensityMetres()) : 0); // HResolution
+        bos.write4Bytes(pixelDensity != null ? (int) Math
+                .round(pixelDensity.verticalDensityMetres()) : 0); // VResolution
+        if (palette == null) {
+            bos.write4Bytes(0); // Colors
+        } else {
+            bos.write4Bytes(palette.length()); // Colors
+        }
+        bos.write4Bytes(0); // Important Colors
+        // bos.write_4_bytes(0); // Compression
+
+        // write Palette
+        writer.writePalette(bos);
+        // write Image Data
+        bos.writeByteArray(imagedata);
     }
 
     /**

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java Thu Sep 27 05:42:25 2012
@@ -84,9 +84,10 @@ public class PixelParserBitFields extend
         } else if (bhi.bitsPerPixel == 16) {
             data = bfp.read2Bytes("Pixel", is, "BMP Image Data");
             bytecount += 2;
-        } else
+        } else {
             throw new ImageReadException("Unknown BitsPerPixel: "
                     + bhi.bitsPerPixel);
+        }
 
         int red = (redMask & data);
         int green = (greenMask & data);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java Thu Sep 27 05:42:25 2012
@@ -38,13 +38,13 @@ public class PixelParserRgb extends Pixe
     public int getNextRGB() throws ImageReadException, IOException {
         pixelCount++;
 
-        if ((bhi.bitsPerPixel == 1) // always grayscale?
-                || (bhi.bitsPerPixel == 4)) // always grayscale?
-        {
+        if ((bhi.bitsPerPixel == 1) 
+                || (bhi.bitsPerPixel == 4)) { // always grayscale?
             if (cached_bit_count < bhi.bitsPerPixel) {
-                if (cached_bit_count != 0)
+                if (cached_bit_count != 0) {
                     throw new ImageReadException("Unexpected leftover bits: "
                             + cached_bit_count + "/" + bhi.bitsPerPixel);
+                }
 
                 cached_bit_count += 8;
                 cached_byte = (0xff & imageData[bytecount]);
@@ -58,8 +58,7 @@ public class PixelParserRgb extends Pixe
             int rgb = getColorTableRGB(sample);
 
             return rgb;
-        } else if (bhi.bitsPerPixel == 8) // always grayscale?
-        {
+        } else if (bhi.bitsPerPixel == 8) { // always grayscale?
             int sample = 0xff & imageData[bytecount + 0];
 
             int rgb = getColorTableRGB(sample);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java Thu Sep 27 05:42:25 2012
@@ -31,13 +31,14 @@ public class PixelParserRle extends Pixe
     }
 
     private int getSamplesPerByte() throws ImageReadException {
-        if (bhi.bitsPerPixel == 8)
+        if (bhi.bitsPerPixel == 8) {
             return 1;
-        else if (bhi.bitsPerPixel == 4)
+        } else if (bhi.bitsPerPixel == 4) {
             return 2;
-        else
+        } else {
             throw new ImageReadException("BMP RLE: bad BitsPerPixel: "
                     + bhi.bitsPerPixel);
+        }
     }
 
     private int[] convertDataToSamples(int data) throws ImageReadException {
@@ -53,9 +54,10 @@ public class PixelParserRle extends Pixe
             rgbs[0] = getColorTableRGB(sample1);
             rgbs[1] = getColorTableRGB(sample2);
             // pixels_written = 2;
-        } else
+        } else {
             throw new ImageReadException("BMP RLE: bad BitsPerPixel: "
                     + bhi.bitsPerPixel);
+        }
 
         return rgbs;
     }
@@ -109,21 +111,20 @@ public class PixelParserRle extends Pixe
 
             if (a == 0) {
                 switch (b) {
-                case 0: // EOL
-                {
+                case 0: {
+                    // EOL
                     // System.out.println("EOL");
                     y--;
                     x = 0;
                 }
                     break;
-                case 1: // EOF
-                    // System.out
-                    // .println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+                case 1:
+                    // EOF
+                    // System.out.println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                     done = true;
                     break;
                 case 2: {
-                    // System.out
-                    // .println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+                    // System.out.println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                     int c = 0xff & bfp.readByte("RLE c", is, "BMP: Bad RLE");
                     // baos.write(c);
                     int d = 0xff & bfp.readByte("RLE d", is, "BMP: Bad RLE");
@@ -132,15 +133,16 @@ public class PixelParserRle extends Pixe
                 }
                     break;
                 default: {
-                    // System.out
-                    // .println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+                    // System.out.println("xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
 
                     int SamplesPerByte = getSamplesPerByte();
                     int size = b / SamplesPerByte;
-                    if ((b % SamplesPerByte) > 0)
+                    if ((b % SamplesPerByte) > 0) {
                         size++;
-                    if ((size % 2) != 0)
+                    }
+                    if ((size % 2) != 0) {
                         size++;
+                    }
 
                     // System.out.println("b: " + b);
                     // System.out.println("size: " + size);
@@ -152,9 +154,8 @@ public class PixelParserRle extends Pixe
                     int remaining = b;
 
                     // while(true)
-                    for (int i = 0; remaining > 0; i++)
+                    for (int i = 0; remaining > 0; i++) {
                     // for (int i = 0; i < bytes.length; i++)
-                    {
                         int samples[] = convertDataToSamples(0xff & bytes[i]);
                         int towrite = Math.min(remaining, SamplesPerByte);
                         // System.out.println("remaining: " + remaining);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java Thu Sep 27 05:42:25 2012
@@ -30,12 +30,13 @@ public class BmpWriterPalette extends Bm
     public BmpWriterPalette(SimplePalette palette) {
         this.palette = palette;
 
-        if (palette.length() <= 2)
+        if (palette.length() <= 2) {
             bitsPerSample = 1;
-        else if (palette.length() <= 16)
+        } else if (palette.length() <= 16) {
             bitsPerSample = 4;
-        else
+        } else {
             bitsPerSample = 8;
+        }
     }
 
     @Override
@@ -85,9 +86,8 @@ public class BmpWriterPalette extends Bm
                 if (bitsPerSample == 8) {
                     baos.write(0xff & index);
                     bytecount++;
-                } else
-                // 4 or 1
-                {
+                } else {
+                    // 4 or 1
                     bit_cache = (bit_cache << bitsPerSample) | index;
                     bits_in_cache += bitsPerSample;
                     if (bits_in_cache >= 8) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java Thu Sep 27 05:42:25 2012
@@ -69,7 +69,8 @@ public class DcxImageParser extends Imag
 
     @Override
     protected ImageFormat[] getAcceptedTypes() {
-        return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_DCX, //
+        return new ImageFormat[] {
+                ImageFormat.IMAGE_FORMAT_DCX, //
         };
     }
 
@@ -131,22 +132,26 @@ public class DcxImageParser extends Imag
             for (int i = 0; i < 1024; i++) {
                 int pageOffset = read4Bytes("PageTable", is,
                         "Not a Valid DCX File");
-                if (pageOffset == 0)
+                if (pageOffset == 0) {
                     break;
+                }
                 pageTable.add(pageOffset);
             }
 
-            if (id != DcxHeader.DCX_ID)
+            if (id != DcxHeader.DCX_ID) {
                 throw new ImageReadException(
                         "Not a Valid DCX File: file id incorrect");
-            if (pageTable.size() == 1024)
+            }
+            if (pageTable.size() == 1024) {
                 throw new ImageReadException(
                         "DCX page table not terminated by zero entry");
+            }
 
             Object[] objects = pageTable.toArray();
             int[] pages = new int[objects.length];
-            for (int i = 0; i < objects.length; i++)
+            for (int i = 0; i < objects.length; i++) {
                 pages[i] = ((Integer) objects[i]).intValue();
+            }
 
             return new DcxHeader(id, pages);
         } finally {
@@ -171,8 +176,9 @@ public class DcxImageParser extends Imag
     public final BufferedImage getBufferedImage(ByteSource byteSource,
             Map params) throws ImageReadException, IOException {
         List<BufferedImage> list = getAllBufferedImages(byteSource);
-        if (list.isEmpty())
+        if (list.isEmpty()) {
             return null;
+        }
         return list.get(0);
     }
 
@@ -193,8 +199,9 @@ public class DcxImageParser extends Imag
                 images.add(image);
             } finally {
                 try {
-                    if (stream != null)
+                    if (stream != null) {
                         stream.close();
+                    }
                 } catch (IOException ignored) {
                     Debug.debug(ignored);
                 }
@@ -225,9 +232,10 @@ public class DcxImageParser extends Imag
         if (params.containsKey(PARAM_KEY_PIXEL_DENSITY)) {
             Object value = params.remove(PARAM_KEY_PIXEL_DENSITY);
             if (value != null) {
-                if (!(value instanceof PixelDensity))
+                if (!(value instanceof PixelDensity)) {
                     throw new ImageWriteException(
                             "Invalid pixel density parameter");
+                }
                 pcxParams.put(PARAM_KEY_PIXEL_DENSITY, (PixelDensity) value);
             }
         }
@@ -245,8 +253,9 @@ public class DcxImageParser extends Imag
         bos.write4Bytes(DcxHeader.DCX_ID);
         // Some apps may need a full 1024 entry table
         bos.write4Bytes(headerSize);
-        for (int i = 0; i < 1023; i++)
+        for (int i = 0; i < 1023; i++) {
             bos.write4Bytes(0);
+        }
         PcxImageParser pcxImageParser = new PcxImageParser();
         pcxImageParser.writeImage(src, bos, pcxParams);
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GenericGifBlock.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GenericGifBlock.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GenericGifBlock.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GenericGifBlock.java Thu Sep 27 05:42:25 2012
@@ -39,8 +39,9 @@ class GenericGifBlock extends GifBlock {
 
         for (int i = 0; i < subblocks.size(); i++) {
             byte subblock[] = subblocks.get(i);
-            if (includeLengths && i > 0)
+            if (includeLengths && i > 0) {
                 out.write(subblock.length);
+            }
             out.write(subblock);
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java Thu Sep 27 05:42:25 2012
@@ -100,12 +100,12 @@ public class GifImageParser extends Imag
             formatCompliance.compare("version", 97, version3);
         }
 
-        if (debug)
+        if (debug) {
             printCharQuad("identifier: ", ((identifier1 << 16)
                     | (identifier2 << 8) | (identifier3 << 0)));
-        if (debug)
             printCharQuad("version: ",
                     ((version1 << 16) | (version2 << 8) | (version3 << 0)));
+        }
 
         int logicalScreenWidth = read2Bytes("Logical Screen Width", is,
                 "Not a Valid GIF File");
@@ -126,28 +126,34 @@ public class GifImageParser extends Imag
         byte pixelAspectRatio = readByte("Pixel Aspect Ratio", is,
                 "Not a Valid GIF File");
 
-        if (debug)
+        if (debug) {
             printByteBits("PackedFields bits", packedFields);
+        }
 
         boolean globalColorTableFlag = ((packedFields & 128) > 0);
-        if (debug)
+        if (debug) {
             System.out.println("GlobalColorTableFlag: " + globalColorTableFlag);
+        }
         byte colorResolution = (byte) ((packedFields >> 4) & 7);
-        if (debug)
+        if (debug) {
             System.out.println("ColorResolution: " + colorResolution);
+        }
         boolean sortFlag = ((packedFields & 8) > 0);
-        if (debug)
+        if (debug) {
             System.out.println("SortFlag: " + sortFlag);
+        }
         byte sizeofGlobalColorTable = (byte) (packedFields & 7);
-        if (debug)
+        if (debug) {
             System.out.println("SizeofGlobalColorTable: "
                     + sizeofGlobalColorTable);
+        }
 
         if (formatCompliance != null) {
-            if (globalColorTableFlag && backgroundColorIndex != -1)
+            if (globalColorTableFlag && backgroundColorIndex != -1) {
                 formatCompliance.checkBounds("Background Color Index", 0,
                         convertColorTableSize(sizeofGlobalColorTable),
                         backgroundColorIndex);
+            }
         }
 
         return new GifHeaderInfo(identifier1, identifier2, identifier3,
@@ -194,13 +200,15 @@ public class GifImageParser extends Imag
             byte first[]) throws IOException {
         List<byte[]> subblocks = new ArrayList<byte[]>();
 
-        if (first != null)
+        if (first != null) {
             subblocks.add(first);
+        }
 
         while (true) {
             byte bytes[] = readSubBlock(is);
-            if (bytes.length < 1)
+            if (bytes.length < 1) {
                 break;
+            }
             subblocks.add(bytes);
         }
 
@@ -265,11 +273,12 @@ public class GifImageParser extends Imag
                 {
                     byte label[] = readSubBlock(is);
 
-                    if (formatCompliance != null)
+                    if (formatCompliance != null) {
                         formatCompliance.addComment(
                                 "Unknown Application Extension ("
                                         + new String(label, "US-ASCII") + ")",
                                 completeCode);
+                    }
 
                     // if (label == new String("ICCRGBG1"))
                     {
@@ -286,9 +295,10 @@ public class GifImageParser extends Imag
 
                 default: {
 
-                    if (formatCompliance != null)
+                    if (formatCompliance != null) {
                         formatCompliance.addComment("Unknown block",
                                 completeCode);
+                    }
 
                     GenericGifBlock block = readGenericGIFBlock(is,
                             completeCode);
@@ -335,28 +345,34 @@ public class GifImageParser extends Imag
                     ghi.logicalScreenHeight - imageHeight, ImageTopPosition);
         }
 
-        if (debug)
+        if (debug) {
             printByteBits("PackedFields bits", PackedFields);
+        }
 
         boolean LocalColorTableFlag = (((PackedFields >> 7) & 1) > 0);
-        if (debug)
+        if (debug) {
             System.out.println("LocalColorTableFlag: " + LocalColorTableFlag);
+        }
         boolean InterlaceFlag = (((PackedFields >> 6) & 1) > 0);
-        if (debug)
+        if (debug) {
             System.out.println("Interlace Flag: " + InterlaceFlag);
+        }
         boolean SortFlag = (((PackedFields >> 5) & 1) > 0);
-        if (debug)
+        if (debug) {
             System.out.println("Sort  Flag: " + SortFlag);
+        }
 
         byte SizeofLocalColorTable = (byte) (PackedFields & 7);
-        if (debug)
+        if (debug) {
             System.out.println("SizeofLocalColorTable: "
                     + SizeofLocalColorTable);
+        }
 
         byte LocalColorTable[] = null;
-        if (LocalColorTableFlag)
+        if (LocalColorTableFlag) {
             LocalColorTable = readColorTable(is, SizeofLocalColorTable,
                     formatCompliance);
+        }
 
         byte imageData[] = null;
         if (!stopBeforeImageData) {
@@ -372,8 +388,9 @@ public class GifImageParser extends Imag
             imageData = myLzwDecompressor.decompress(bais, size);
         } else {
             int LZWMinimumCodeSize = is.read();
-            if (debug)
+            if (debug) {
                 System.out.println("LZWMinimumCodeSize: " + LZWMinimumCodeSize);
+            }
 
             readGenericGIFBlock(is, -1);
         }
@@ -389,8 +406,9 @@ public class GifImageParser extends Imag
     private int simple_pow(int base, int power) {
         int result = 1;
 
-        for (int i = 0; i < power; i++)
+        for (int i = 0; i < power; i++) {
             result *= base;
+        }
 
         return result;
     }
@@ -432,8 +450,9 @@ public class GifImageParser extends Imag
     private GifBlock findBlock(List<GifBlock> v, int code) {
         for (int i = 0; i < v.size(); i++) {
             GifBlock gifBlock = v.get(i);
-            if (gifBlock.blockCode == code)
+            if (gifBlock.blockCode == code) {
                 return gifBlock;
+            }
         }
         return null;
     }
@@ -454,9 +473,10 @@ public class GifImageParser extends Imag
             GifHeaderInfo ghi = readHeader(is, formatCompliance);
 
             byte globalColorTable[] = null;
-            if (ghi.globalColorTableFlag)
+            if (ghi.globalColorTableFlag) {
                 globalColorTable = readColorTable(is,
                         ghi.sizeOfGlobalColorTable, formatCompliance);
+            }
 
             List<GifBlock> blocks = readBlocks(ghi, is, stopBeforeImageData,
                     formatCompliance);
@@ -488,17 +508,20 @@ public class GifImageParser extends Imag
             throws ImageReadException, IOException {
         ImageContents blocks = readFile(byteSource, false);
 
-        if (blocks == null)
+        if (blocks == null) {
             throw new ImageReadException("GIF: Couldn't read blocks");
+        }
 
         GifHeaderInfo bhi = blocks.gifHeaderInfo;
-        if (bhi == null)
+        if (bhi == null) {
             throw new ImageReadException("GIF: Couldn't read Header");
+        }
 
         ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks,
                 IMAGE_SEPARATOR);
-        if (id == null)
+        if (id == null) {
             throw new ImageReadException("GIF: Couldn't read ImageDescriptor");
+        }
 
         // Prefer the size information in the ImageDescriptor; it is more
         // reliable
@@ -541,17 +564,20 @@ public class GifImageParser extends Imag
             throws ImageReadException, IOException {
         ImageContents blocks = readFile(byteSource, false);
 
-        if (blocks == null)
+        if (blocks == null) {
             throw new ImageReadException("GIF: Couldn't read blocks");
+        }
 
         GifHeaderInfo bhi = blocks.gifHeaderInfo;
-        if (bhi == null)
+        if (bhi == null) {
             throw new ImageReadException("GIF: Couldn't read Header");
+        }
 
         ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks,
                 IMAGE_SEPARATOR);
-        if (id == null)
+        if (id == null) {
             throw new ImageReadException("GIF: Couldn't read ImageDescriptor");
+        }
 
         GraphicControlExtension gce = (GraphicControlExtension) findBlock(
                 blocks.blocks, GRAPHIC_CONTROL_EXTENSION);
@@ -585,8 +611,9 @@ public class GifImageParser extends Imag
                 + ((char) blocks.gifHeaderInfo.version3);
 
         boolean isTransparent = false;
-        if (gce != null && gce.transparency)
+        if (gce != null && gce.transparency) {
             isTransparent = true;
+        }
 
         boolean usesPalette = true;
         int colorType = ImageInfo.COLOR_TYPE_RGB;
@@ -607,8 +634,9 @@ public class GifImageParser extends Imag
         pw.println("gif.dumpImageFile");
 
         ImageInfo imageData = getImageInfo(byteSource);
-        if (imageData == null)
+        if (imageData == null) {
             return false;
+        }
 
         imageData.toString(pw, "");
         
@@ -628,9 +656,10 @@ public class GifImageParser extends Imag
     }
 
     private int[] getColorTable(byte bytes[]) throws ImageReadException {
-        if ((bytes.length % 3) != 0)
+        if ((bytes.length % 3) != 0) {
             throw new ImageReadException("Bad Color Table Length: "
                     + bytes.length);
+        }
         int length = bytes.length / 3;
 
         int result[] = new int[length];
@@ -665,17 +694,20 @@ public class GifImageParser extends Imag
             throws ImageReadException, IOException {
         ImageContents imageContents = readFile(byteSource, false);
 
-        if (imageContents == null)
+        if (imageContents == null) {
             throw new ImageReadException("GIF: Couldn't read blocks");
+        }
 
         GifHeaderInfo ghi = imageContents.gifHeaderInfo;
-        if (ghi == null)
+        if (ghi == null) {
             throw new ImageReadException("GIF: Couldn't read Header");
+        }
 
         ImageDescriptor id = (ImageDescriptor) findBlock(imageContents.blocks,
                 IMAGE_SEPARATOR);
-        if (id == null)
+        if (id == null) {
             throw new ImageReadException("GIF: Couldn't read Image Descriptor");
+        }
         GraphicControlExtension gce = (GraphicControlExtension) findBlock(
                 imageContents.blocks, GRAPHIC_CONTROL_EXTENSION);
 
@@ -686,69 +718,73 @@ public class GifImageParser extends Imag
         int height = id.imageHeight;
 
         boolean hasAlpha = false;
-        if (gce != null && gce.transparency)
+        if (gce != null && gce.transparency) {
             hasAlpha = true;
+        }
 
         ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha);
 
-        {
-            int colorTable[];
-            if (id.localColorTable != null)
-                colorTable = getColorTable(id.localColorTable);
-            else if (imageContents.globalColorTable != null)
-                colorTable = getColorTable(imageContents.globalColorTable);
-            else
-                throw new ImageReadException("Gif: No Color Table");
-
-            int transparentIndex = -1;
-            if (hasAlpha)
-                transparentIndex = gce.transparentColorIndex;
-
-            int counter = 0;
-
-            int rowsInPass1 = (height + 7) / 8;
-            int rowsInPass2 = (height + 3) / 8;
-            int rowsInPass3 = (height + 1) / 4;
-            int rowsInPass4 = (height) / 2;
-
-            for (int row = 0; row < height; row++) {
-                int y;
-                if (id.interlaceFlag) {
-                    int the_row = row;
-                    if (the_row < rowsInPass1)
-                        y = the_row * 8;
-                    else {
-                        the_row -= rowsInPass1;
-                        if (the_row < (rowsInPass2))
-                            y = 4 + (the_row * 8);
-                        else {
-                            the_row -= rowsInPass2;
-                            if (the_row < (rowsInPass3))
-                                y = 2 + (the_row * 4);
-                            else {
-                                the_row -= rowsInPass3;
-                                if (the_row < (rowsInPass4))
-                                    y = 1 + (the_row * 2);
-                                else
-                                    throw new ImageReadException(
-                                            "Gif: Strange Row");
+        int colorTable[];
+        if (id.localColorTable != null) {
+            colorTable = getColorTable(id.localColorTable);
+        } else if (imageContents.globalColorTable != null) {
+            colorTable = getColorTable(imageContents.globalColorTable);
+        } else {
+            throw new ImageReadException("Gif: No Color Table");
+        }
+
+        int transparentIndex = -1;
+        if (hasAlpha) {
+            transparentIndex = gce.transparentColorIndex;
+        }
+
+        int counter = 0;
+
+        int rowsInPass1 = (height + 7) / 8;
+        int rowsInPass2 = (height + 3) / 8;
+        int rowsInPass3 = (height + 1) / 4;
+        int rowsInPass4 = (height) / 2;
+
+        for (int row = 0; row < height; row++) {
+            int y;
+            if (id.interlaceFlag) {
+                int the_row = row;
+                if (the_row < rowsInPass1) {
+                    y = the_row * 8;
+                } else {
+                    the_row -= rowsInPass1;
+                    if (the_row < (rowsInPass2)) {
+                        y = 4 + (the_row * 8);
+                    } else {
+                        the_row -= rowsInPass2;
+                        if (the_row < (rowsInPass3)) {
+                            y = 2 + (the_row * 4);
+                        } else {
+                            the_row -= rowsInPass3;
+                            if (the_row < (rowsInPass4)) {
+                                y = 1 + (the_row * 2);
+                            } else {
+                                throw new ImageReadException(
+                                        "Gif: Strange Row");
                             }
                         }
                     }
-                } else
-                    y = row;
-
-                for (int x = 0; x < width; x++) {
-                    int index = 0xff & id.imageData[counter++];
-                    int rgb = colorTable[index];
+                }
+            } else {
+                y = row;
+            }
 
-                    if (transparentIndex == index)
-                        rgb = 0x00;
+            for (int x = 0; x < width; x++) {
+                int index = 0xff & id.imageData[counter++];
+                int rgb = colorTable[index];
 
-                    imageBuilder.setRGB(x, y, rgb);
+                if (transparentIndex == index) {
+                    rgb = 0x00;
                 }
 
+                imageBuilder.setRGB(x, y, rgb);
             }
+
         }
 
         return imageBuilder.getBufferedImage();
@@ -782,10 +818,12 @@ public class GifImageParser extends Imag
                 false);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        }
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
+        }
 
         String xmpXml = null;
         if (params.containsKey(PARAM_KEY_XMP_XML)) {
@@ -813,198 +851,202 @@ public class GifImageParser extends Imag
         if (palette2 == null) {
             palette2 = new PaletteFactory().makeQuantizedRgbPalette(src,
                     max_colors);
-            if (verbose)
+            if (verbose) {
                 System.out.println("quantizing");
-        } else if (verbose)
+            }
+        } else if (verbose) {
             System.out.println("exact palette");
+        }
 
-        if (palette2 == null)
+        if (palette2 == null) {
             throw new ImageWriteException(
                     "Gif: can't write images with more than 256 colors");
+        }
         int palette_size = palette2.length() + (hasAlpha ? 1 : 0);
 
         BinaryOutputStream bos = new BinaryOutputStream(os, BYTE_ORDER_LSB);
 
-        {
-            // write Header
-            os.write(0x47); // G magic numbers
-            os.write(0x49); // I
-            os.write(0x46); // F
-
-            os.write(0x38); // 8 version magic numbers
-            os.write(0x39); // 9
-            os.write(0x61); // a
-
-            // Logical Screen Descriptor.
-
-            bos.write2Bytes(width);
-            bos.write2Bytes(height);
-
-            int colorTableScaleLessOne = (palette_size > 128) ? 7
-                    : (palette_size > 64) ? 6 : (palette_size > 32) ? 5
-                            : (palette_size > 16) ? 4 : (palette_size > 8) ? 3
-                                    : (palette_size > 4) ? 2
-                                            : (palette_size > 2) ? 1 : 0;
-
-            int colorTableSizeInFormat = 1 << (colorTableScaleLessOne + 1);
-            {
-                byte colorResolution = (byte) colorTableScaleLessOne; // TODO:
+        // write Header
+        os.write(0x47); // G magic numbers
+        os.write(0x49); // I
+        os.write(0x46); // F
+
+        os.write(0x38); // 8 version magic numbers
+        os.write(0x39); // 9
+        os.write(0x61); // a
+
+        // Logical Screen Descriptor.
+
+        bos.write2Bytes(width);
+        bos.write2Bytes(height);
+
+        int colorTableScaleLessOne = (palette_size > 128) ? 7
+                : (palette_size > 64) ? 6 : (palette_size > 32) ? 5
+                        : (palette_size > 16) ? 4 : (palette_size > 8) ? 3
+                                : (palette_size > 4) ? 2
+                                        : (palette_size > 2) ? 1 : 0;
 
-                boolean globalColorTableFlag = false;
-                boolean sortFlag = false;
-                int globalColorTableFlagMask = 1 << 7;
-                int sortFlagMask = 8;
-                int sizeOfGlobalColorTable = 0;
+        int colorTableSizeInFormat = 1 << (colorTableScaleLessOne + 1);
+        {
+            byte colorResolution = (byte) colorTableScaleLessOne; // TODO:
 
-                int packedFields = ((globalColorTableFlag ? globalColorTableFlagMask
-                        : 0)
-                        | (sortFlag ? sortFlagMask : 0)
-                        | ((7 & colorResolution) << 4) | (7 & sizeOfGlobalColorTable));
-                bos.write(packedFields); // one byte
-            }
-            {
-                byte BackgroundColorIndex = 0;
-                bos.write(BackgroundColorIndex);
-            }
-            {
-                byte PixelAspectRatio = 0;
-                bos.write(PixelAspectRatio);
-            }
+            boolean globalColorTableFlag = false;
+            boolean sortFlag = false;
+            int globalColorTableFlagMask = 1 << 7;
+            int sortFlagMask = 8;
+            int sizeOfGlobalColorTable = 0;
+
+            int packedFields = ((globalColorTableFlag ? globalColorTableFlagMask
+                    : 0)
+                    | (sortFlag ? sortFlagMask : 0)
+                    | ((7 & colorResolution) << 4) | (7 & sizeOfGlobalColorTable));
+            bos.write(packedFields); // one byte
+        }
+        {
+            byte BackgroundColorIndex = 0;
+            bos.write(BackgroundColorIndex);
+        }
+        {
+            byte PixelAspectRatio = 0;
+            bos.write(PixelAspectRatio);
+        }
 
-            { // write Global Color Table.
+        { // write Global Color Table.
 
-            }
+        }
 
-            { // ALWAYS write GraphicControlExtension
-                bos.write(EXTENSION_CODE);
-                bos.write((byte) 0xf9);
-                // bos.write(0xff & (kGraphicControlExtension >> 8));
-                // bos.write(0xff & (kGraphicControlExtension >> 0));
+        { // ALWAYS write GraphicControlExtension
+            bos.write(EXTENSION_CODE);
+            bos.write((byte) 0xf9);
+            // bos.write(0xff & (kGraphicControlExtension >> 8));
+            // bos.write(0xff & (kGraphicControlExtension >> 0));
+
+            bos.write((byte) 4); // block size;
+            int packedFields = hasAlpha ? 1 : 0; // transparency flag
+            bos.write((byte) packedFields);
+            bos.write((byte) 0); // Delay Time
+            bos.write((byte) 0); // Delay Time
+            bos.write((byte) (hasAlpha ? palette2.length() : 0)); // Transparent
+            // Color
+            // Index
+            bos.write((byte) 0); // terminator
+        }
 
-                bos.write((byte) 4); // block size;
-                int packedFields = hasAlpha ? 1 : 0; // transparency flag
-                bos.write((byte) packedFields);
-                bos.write((byte) 0); // Delay Time
-                bos.write((byte) 0); // Delay Time
-                bos.write((byte) (hasAlpha ? palette2.length() : 0)); // Transparent
-                // Color
-                // Index
-                bos.write((byte) 0); // terminator
+        if (null != xmpXml) {
+            bos.write(EXTENSION_CODE);
+            bos.write(APPLICATION_EXTENSION_LABEL);
+
+            bos.write(XMP_APPLICATION_ID_AND_AUTH_CODE.length); // 0x0B
+            bos.write(XMP_APPLICATION_ID_AND_AUTH_CODE);
+
+            byte xmpXmlBytes[] = xmpXml.getBytes("utf-8");
+            bos.write(xmpXmlBytes);
+
+            // write "magic trailer"
+            for (int magic = 0; magic <= 0xff; magic++) {
+                bos.write(0xff - magic);
             }
 
-            if (null != xmpXml) {
-                bos.write(EXTENSION_CODE);
-                bos.write(APPLICATION_EXTENSION_LABEL);
+            bos.write((byte) 0); // terminator
 
-                bos.write(XMP_APPLICATION_ID_AND_AUTH_CODE.length); // 0x0B
-                bos.write(XMP_APPLICATION_ID_AND_AUTH_CODE);
+        }
 
-                byte xmpXmlBytes[] = xmpXml.getBytes("utf-8");
-                bos.write(xmpXmlBytes);
+        { // Image Descriptor.
+            bos.write(IMAGE_SEPARATOR);
+            bos.write2Bytes(0); // Image Left Position
+            bos.write2Bytes(0); // Image Top Position
+            bos.write2Bytes(width); // Image Width
+            bos.write2Bytes(height); // Image Height
 
-                // write "magic trailer"
-                for (int magic = 0; magic <= 0xff; magic++)
-                    bos.write(0xff - magic);
+            {
+                boolean LocalColorTableFlag = true;
+                // boolean LocalColorTableFlag = false;
+                boolean InterlaceFlag = false;
+                boolean SortFlag = false;
+                int SizeOfLocalColorTable = colorTableScaleLessOne;
 
-                bos.write((byte) 0); // terminator
+                // int SizeOfLocalColorTable = 0;
 
+                int PackedFields = ((LocalColorTableFlag ? LOCAL_COLOR_TABLE_FLAG_MASK
+                        : 0)
+                        | (InterlaceFlag ? INTERLACE_FLAG_MASK : 0)
+                        | (SortFlag ? SORT_FLAG_MASK : 0) | (7 & SizeOfLocalColorTable));
+                bos.write(PackedFields); // one byte
             }
+        }
 
-            { // Image Descriptor.
-                bos.write(IMAGE_SEPARATOR);
-                bos.write2Bytes(0); // Image Left Position
-                bos.write2Bytes(0); // Image Top Position
-                bos.write2Bytes(width); // Image Width
-                bos.write2Bytes(height); // Image Height
-
-                {
-                    boolean LocalColorTableFlag = true;
-                    // boolean LocalColorTableFlag = false;
-                    boolean InterlaceFlag = false;
-                    boolean SortFlag = false;
-                    int SizeOfLocalColorTable = colorTableScaleLessOne;
-
-                    // int SizeOfLocalColorTable = 0;
-
-                    int PackedFields = ((LocalColorTableFlag ? LOCAL_COLOR_TABLE_FLAG_MASK
-                            : 0)
-                            | (InterlaceFlag ? INTERLACE_FLAG_MASK : 0)
-                            | (SortFlag ? SORT_FLAG_MASK : 0) | (7 & SizeOfLocalColorTable));
-                    bos.write(PackedFields); // one byte
+        { // write Local Color Table.
+            for (int i = 0; i < colorTableSizeInFormat; i++) {
+                if (i < palette2.length()) {
+                    int rgb = palette2.getEntry(i);
+
+                    int red = 0xff & (rgb >> 16);
+                    int green = 0xff & (rgb >> 8);
+                    int blue = 0xff & (rgb >> 0);
+
+                    bos.write(red);
+                    bos.write(green);
+                    bos.write(blue);
+                } else {
+                    bos.write(0);
+                    bos.write(0);
+                    bos.write(0);
                 }
             }
+        }
 
-            { // write Local Color Table.
-                for (int i = 0; i < colorTableSizeInFormat; i++) {
-                    if (i < palette2.length()) {
-                        int rgb = palette2.getEntry(i);
-
-                        int red = 0xff & (rgb >> 16);
-                        int green = 0xff & (rgb >> 8);
-                        int blue = 0xff & (rgb >> 0);
-
-                        bos.write(red);
-                        bos.write(green);
-                        bos.write(blue);
-                    } else {
-                        bos.write(0);
-                        bos.write(0);
-                        bos.write(0);
-                    }
-                }
+        { // get Image Data.
+            int image_data_total = 0;
+
+            int LZWMinimumCodeSize = colorTableScaleLessOne + 1;
+            // LZWMinimumCodeSize = Math.max(8, LZWMinimumCodeSize);
+            if (LZWMinimumCodeSize < 2) {
+                LZWMinimumCodeSize = 2;
             }
 
-            { // get Image Data.
-                int image_data_total = 0;
+            // TODO:
+            // make
+            // better
+            // choice
+            // here.
+            bos.write(LZWMinimumCodeSize);
+
+            MyLzwCompressor compressor = new MyLzwCompressor(
+                    LZWMinimumCodeSize, BYTE_ORDER_LSB, false); // GIF
+            // Mode);
 
-                int LZWMinimumCodeSize = colorTableScaleLessOne + 1;
-                // LZWMinimumCodeSize = Math.max(8, LZWMinimumCodeSize);
-                if (LZWMinimumCodeSize < 2)
-                    LZWMinimumCodeSize = 2;
-
-                // TODO:
-                // make
-                // better
-                // choice
-                // here.
-                bos.write(LZWMinimumCodeSize);
-
-                MyLzwCompressor compressor = new MyLzwCompressor(
-                        LZWMinimumCodeSize, BYTE_ORDER_LSB, false); // GIF
-                // Mode);
-
-                byte imagedata[] = new byte[width * height];
-                for (int y = 0; y < height; y++) {
-                    for (int x = 0; x < width; x++) {
-                        int argb = src.getRGB(x, y);
-                        int rgb = 0xffffff & argb;
-                        int index;
-
-                        if (hasAlpha) {
-                            int alpha = 0xff & (argb >> 24);
-                            final int alphaThreshold = 255;
-                            if (alpha < alphaThreshold)
-                                index = palette2.length(); // is transparent
-                            else
-                                index = palette2.getPaletteIndex(rgb);
+            byte imagedata[] = new byte[width * height];
+            for (int y = 0; y < height; y++) {
+                for (int x = 0; x < width; x++) {
+                    int argb = src.getRGB(x, y);
+                    int rgb = 0xffffff & argb;
+                    int index;
+
+                    if (hasAlpha) {
+                        int alpha = 0xff & (argb >> 24);
+                        final int alphaThreshold = 255;
+                        if (alpha < alphaThreshold) {
+                            index = palette2.length(); // is transparent
                         } else {
                             index = palette2.getPaletteIndex(rgb);
                         }
-
-                        imagedata[y * width + x] = (byte) index;
+                    } else {
+                        index = palette2.getPaletteIndex(rgb);
                     }
-                }
 
-                byte compressed[] = compressor.compress(imagedata);
-                writeAsSubBlocks(bos, compressed);
-                image_data_total += compressed.length;
+                    imagedata[y * width + x] = (byte) index;
+                }
             }
 
-            // palette2.dump();
-
-            bos.write(TERMINATOR_BYTE);
+            byte compressed[] = compressor.compress(imagedata);
+            writeAsSubBlocks(bos, compressed);
+            image_data_total += compressed.length;
         }
 
+        // palette2.dump();
+
+        bos.write(TERMINATOR_BYTE);
+
         bos.close();
         os.close();
     }
@@ -1043,40 +1085,47 @@ public class GifImageParser extends Imag
             FormatCompliance formatCompliance = null;
             GifHeaderInfo ghi = readHeader(is, formatCompliance);
 
-            if (ghi.globalColorTableFlag)
+            if (ghi.globalColorTableFlag) {
                 readColorTable(is, ghi.sizeOfGlobalColorTable, formatCompliance);
+            }
 
             List<GifBlock> blocks = readBlocks(ghi, is, true, formatCompliance);
 
             List<String> result = new ArrayList<String>();
             for (int i = 0; i < blocks.size(); i++) {
                 GifBlock block = blocks.get(i);
-                if (block.blockCode != XMP_COMPLETE_CODE)
+                if (block.blockCode != XMP_COMPLETE_CODE) {
                     continue;
+                }
 
                 GenericGifBlock genericBlock = (GenericGifBlock) block;
 
                 byte blockBytes[] = genericBlock.appendSubBlocks(true);
-                if (blockBytes.length < XMP_APPLICATION_ID_AND_AUTH_CODE.length)
+                if (blockBytes.length < XMP_APPLICATION_ID_AND_AUTH_CODE.length) {
                     continue;
+                }
 
                 if (!compareByteArrays(blockBytes, 0,
                         XMP_APPLICATION_ID_AND_AUTH_CODE, 0,
-                        XMP_APPLICATION_ID_AND_AUTH_CODE.length))
+                        XMP_APPLICATION_ID_AND_AUTH_CODE.length)) {
                     continue;
+                }
 
                 byte GIF_MAGIC_TRAILER[] = new byte[256];
-                for (int magic = 0; magic <= 0xff; magic++)
+                for (int magic = 0; magic <= 0xff; magic++) {
                     GIF_MAGIC_TRAILER[magic] = (byte) (0xff - magic);
+                }
 
                 if (blockBytes.length < XMP_APPLICATION_ID_AND_AUTH_CODE.length
-                        + GIF_MAGIC_TRAILER.length)
+                        + GIF_MAGIC_TRAILER.length) {
                     continue;
+                }
                 if (!compareByteArrays(blockBytes, blockBytes.length
                         - GIF_MAGIC_TRAILER.length, GIF_MAGIC_TRAILER, 0,
-                        GIF_MAGIC_TRAILER.length))
+                        GIF_MAGIC_TRAILER.length)) {
                     throw new ImageReadException(
                             "XMP block in GIF missing magic trailer.");
+                }
 
                 try {
                     // XMP is UTF-8 encoded xml.
@@ -1092,10 +1141,12 @@ public class GifImageParser extends Imag
                 }
             }
 
-            if (result.size() < 1)
+            if (result.size() < 1) {
                 return null;
-            if (result.size() > 1)
+            }
+            if (result.size() > 1) {
                 throw new ImageReadException("More than one XMP Block in GIF.");
+            }
             return result.get(0);
 
         } finally {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java Thu Sep 27 05:42:25 2012
@@ -94,10 +94,11 @@ public class IcnsDecoder {
                     bitsLeft = 8;
                 }
                 int argb;
-                if ((value & 0x80) != 0)
+                if ((value & 0x80) != 0) {
                     argb = 0xff000000;
-                else
+                } else {
                     argb = 0xffffffff;
+                }
                 value <<= 1;
                 bitsLeft--;
                 image.setRGB(x, y, argb);
@@ -112,10 +113,11 @@ public class IcnsDecoder {
         for (int y = 0; y < imageType.getHeight(); y++) {
             for (int x = 0; x < imageType.getWidth(); x++) {
                 int index;
-                if (!visited)
+                if (!visited) {
                     index = 0xf & (imageData[i] >> 4);
-                else
+                } else {
                     index = 0xf & imageData[i++];
+                }
                 visited = !visited;
                 image.setRGB(x, y, palette_4bpp[index]);
             }
@@ -154,11 +156,12 @@ public class IcnsDecoder {
         // 1 bit icon types have image data followed by mask data in the same
         // entry
         int totalBytes = (image.getWidth() * image.getHeight() + 7) / 8;
-        if (maskData.length >= 2 * totalBytes)
+        if (maskData.length >= 2 * totalBytes) {
             position = totalBytes;
-        else
+        } else {
             throw new ImageReadException(
                     "1 BPP mask underrun parsing ICNS file");
+        }
 
         for (int y = 0; y < image.getHeight(); y++) {
             for (int x = 0; x < image.getWidth(); x++) {
@@ -167,10 +170,11 @@ public class IcnsDecoder {
                     bitsLeft = 8;
                 }
                 int alpha;
-                if ((value & 0x80) != 0)
+                if ((value & 0x80) != 0) {
                     alpha = 0xff;
-                else
+                } else {
                     alpha = 0x00;
+                }
                 value <<= 1;
                 bitsLeft--;
                 image.setRGB(x, y,
@@ -196,8 +200,9 @@ public class IcnsDecoder {
         for (int i = 0; i < icnsElements.length; i++) {
             IcnsImageParser.IcnsElement imageElement = icnsElements[i];
             IcnsType imageType = IcnsType.findImageType(imageElement.type);
-            if (imageType == null)
+            if (imageType == null) {
                 continue;
+            }
 
             IcnsType maskType = null;
             IcnsImageParser.IcnsElement maskElement = null;
@@ -229,8 +234,9 @@ public class IcnsDecoder {
 
             // FIXME: don't skip these when JPEG 2000 support is added:
             if (imageType == IcnsType.ICNS_256x256_32BIT_ARGB_IMAGE
-                    || imageType == IcnsType.ICNS_512x512_32BIT_ARGB_IMAGE)
+                    || imageType == IcnsType.ICNS_512x512_32BIT_ARGB_IMAGE) {
                 continue;
+            }
 
             int expectedSize = (imageType.getWidth() * imageType.getHeight()
                     * imageType.getBitsPerPixel() + 7) / 8;
@@ -240,11 +246,13 @@ public class IcnsDecoder {
                     imageData = Rle24Compression.decompress(
                             imageType.getWidth(), imageType.getHeight(),
                             imageElement.data);
-                } else
+                } else {
                     throw new ImageReadException(
                             "Short image data but not a 32 bit compressed type");
-            } else
+                }
+            } else {
                 imageData = imageElement.data;
+            }
 
             ImageBuilder imageBuilder = new ImageBuilder(imageType.getWidth(),
                     imageType.getHeight(), true);
@@ -267,13 +275,14 @@ public class IcnsDecoder {
             }
 
             if (maskElement != null) {
-                if (maskType.getBitsPerPixel() == 1)
+                if (maskType.getBitsPerPixel() == 1) {
                     apply1BPPMask(maskElement.data, imageBuilder);
-                else if (maskType.getBitsPerPixel() == 8)
+                } else if (maskType.getBitsPerPixel() == 8) {
                     apply8BPPMask(maskElement.data, imageBuilder);
-                else
+                } else {
                     throw new ImageReadException("Unsupport mask bit depth "
                             + maskType.getBitsPerPixel());
+                }
             }
 
             result.add(imageBuilder.getBufferedImage());

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java Thu Sep 27 05:42:25 2012
@@ -89,8 +89,9 @@ public class IcnsImageParser extends Ima
 
         ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);
 
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -100,8 +101,9 @@ public class IcnsImageParser extends Ima
         IcnsContents contents = readImage(byteSource);
         List<BufferedImage> images = IcnsDecoder
                 .decodeAllImages(contents.icnsElements);
-        if (images.isEmpty())
+        if (images.isEmpty()) {
             throw new ImageReadException("No icons in ICNS file");
+        }
         BufferedImage image0 = images.get(0);
         return new ImageInfo("Icns", 32, new ArrayList<String>(),
                 ImageFormat.IMAGE_FORMAT_ICNS, "ICNS Apple Icon Image",
@@ -119,8 +121,9 @@ public class IcnsImageParser extends Ima
 
         ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);
 
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -130,8 +133,9 @@ public class IcnsImageParser extends Ima
         IcnsContents contents = readImage(byteSource);
         List<BufferedImage> images = IcnsDecoder
                 .decodeAllImages(contents.icnsElements);
-        if (images.isEmpty())
+        if (images.isEmpty()) {
             throw new ImageReadException("No icons in ICNS file");
+        }
         BufferedImage image0 = images.get(0);
         return new Dimension(image0.getWidth(), image0.getHeight());
     }
@@ -165,9 +169,10 @@ public class IcnsImageParser extends Ima
         int Magic = read4Bytes("Magic", is, "Not a Valid ICNS File");
         int FileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File");
 
-        if (Magic != ICNS_MAGIC)
+        if (Magic != ICNS_MAGIC) {
             throw new ImageReadException("Not a Valid ICNS File: "
                     + "magic is 0x" + Integer.toHexString(Magic));
+        }
 
         return new IcnsHeader(Magic, FileSize);
     }
@@ -187,10 +192,11 @@ public class IcnsImageParser extends Ima
             pw.println("IcnsElement");
             IcnsType icnsType = IcnsType.findAnyType(type);
             String typeDescription;
-            if (icnsType == null)
+            if (icnsType == null) {
                 typeDescription = "";
-            else
+            } else {
                 typeDescription = " " + icnsType.toString();
+            }
             pw.println("Type: 0x" + Integer.toHexString(type) + " ("
                     + IcnsType.describeType(type) + ")" + typeDescription);
             pw.println("ElementSize: " + elementSize);
@@ -244,8 +250,9 @@ public class IcnsImageParser extends Ima
             }
 
             IcnsElement[] icnsElements = new IcnsElement[icnsElementList.size()];
-            for (int i = 0; i < icnsElements.length; i++)
+            for (int i = 0; i < icnsElements.length; i++) {
                 icnsElements[i] = icnsElementList.get(i);
+            }
 
             return new IcnsContents(icnsHeader, icnsElements);
         } finally {
@@ -262,8 +269,9 @@ public class IcnsImageParser extends Ima
             throws ImageReadException, IOException {
         IcnsContents icnsContents = readImage(byteSource);
         icnsContents.icnsHeader.dump(pw);
-        for (int i = 0; i < icnsContents.icnsElements.length; i++)
+        for (int i = 0; i < icnsContents.icnsElements.length; i++) {
             icnsContents.icnsElements[i].dump(pw);
+        }
         return true;
     }
 
@@ -273,10 +281,11 @@ public class IcnsImageParser extends Ima
         IcnsContents icnsContents = readImage(byteSource);
         List<BufferedImage> result = IcnsDecoder
                 .decodeAllImages(icnsContents.icnsElements);
-        if (result.size() > 0)
+        if (result.size() > 0) {
             return result.get(0);
-        else
+        } else {
             throw new ImageReadException("No icons in ICNS file");
+        }
     }
 
     @Override
@@ -293,8 +302,9 @@ public class IcnsImageParser extends Ima
         params = (params == null) ? new HashMap() : new HashMap(params);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -302,17 +312,18 @@ public class IcnsImageParser extends Ima
         }
 
         IcnsType imageType;
-        if (src.getWidth() == 16 && src.getHeight() == 16)
+        if (src.getWidth() == 16 && src.getHeight() == 16) {
             imageType = IcnsType.ICNS_16x16_32BIT_IMAGE;
-        else if (src.getWidth() == 32 && src.getHeight() == 32)
+        } else if (src.getWidth() == 32 && src.getHeight() == 32) {
             imageType = IcnsType.ICNS_32x32_32BIT_IMAGE;
-        else if (src.getWidth() == 48 && src.getHeight() == 48)
+        } else if (src.getWidth() == 48 && src.getHeight() == 48) {
             imageType = IcnsType.ICNS_48x48_32BIT_IMAGE;
-        else if (src.getWidth() == 128 && src.getHeight() == 128)
+        } else if (src.getWidth() == 128 && src.getHeight() == 128) {
             imageType = IcnsType.ICNS_128x128_32BIT_IMAGE;
-        else
+        } else {
             throw new ImageWriteException("Invalid/unsupported source width "
                     + src.getWidth() + " and height " + src.getHeight());
+        }
 
         BinaryOutputStream bos = new BinaryOutputStream(os,
                 BYTE_ORDER_BIG_ENDIAN);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java Thu Sep 27 05:42:25 2012
@@ -131,20 +131,23 @@ public class IcnsType {
 
     public static IcnsType findAnyType(int type) {
         for (int i = 0; i < allImageTypes.length; i++) {
-            if (allImageTypes[i].getType() == type)
+            if (allImageTypes[i].getType() == type) {
                 return allImageTypes[i];
+            }
         }
         for (int i = 0; i < allMaskTypes.length; i++) {
-            if (allMaskTypes[i].getType() == type)
+            if (allMaskTypes[i].getType() == type) {
                 return allMaskTypes[i];
+            }
         }
         return null;
     }
 
     public static IcnsType findImageType(int type) {
         for (int i = 0; i < allImageTypes.length; i++) {
-            if (allImageTypes[i].getType() == type)
+            if (allImageTypes[i].getType() == type) {
                 return allImageTypes[i];
+            }
         }
         return null;
     }
@@ -178,8 +181,9 @@ public class IcnsType {
         } catch (UnsupportedEncodingException cannotHappen) {
             throw new IllegalArgumentException("Your Java doesn't support US-ASCII");
         }
-        if (bytes.length != 4)
+        if (bytes.length != 4) {
             throw new IllegalArgumentException("Invalid ICNS type");
+        }
         return ((0xff & bytes[0]) << 24) | ((0xff & bytes[1]) << 16)
                 | ((0xff & bytes[2]) << 8) | (0xff & bytes[3]);
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java Thu Sep 27 05:42:25 2012
@@ -33,8 +33,9 @@ class Rle24Compression {
         // because they could encode valid pixels on smaller images.
         // So always skip on 128x128, and never skip on anything else.
         int dataPos = 0;
-        if (width >= 128 && height >= 128)
+        if (width >= 128 && height >= 128) {
             dataPos = 4;
+        }
 
         // argb, band by band in 3 passes, with no alpha
         for (int band = 1; band <= 3; band++) {
@@ -43,15 +44,17 @@ class Rle24Compression {
             while (remaining > 0) {
                 if ((data[dataPos] & 0x80) != 0) {
                     int count = (0xff & data[dataPos]) - 125;
-                    for (int i = 0; i < count; i++)
+                    for (int i = 0; i < count; i++) {
                         result[band + 4 * (resultPos++)] = data[dataPos + 1];
+                    }
                     dataPos += 2;
                     remaining -= count;
                 } else {
                     int count = (0xff & data[dataPos]) + 1;
                     dataPos++;
-                    for (int i = 0; i < count; i++)
+                    for (int i = 0; i < count; i++) {
                         result[band + 4 * (resultPos++)] = data[dataPos++];
+                    }
                     remaining -= count;
                 }
             }