commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1391156 [1/4] - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: formats/pcx/ formats/png/ formats/png/chunks/ formats/png/scanlinefilters/ formats/pnm/ formats/psd/ formats/psd/dataparsers/ formats/psd/datareader...
Date Thu, 27 Sep 2012 18:22:40 GMT
Author: damjan
Date: Thu Sep 27 18:22:37 2012
New Revision: 1391156

URL: http://svn.apache.org/viewvc?rev=1391156&view=rev
Log:
Finish adding braces for all main classes.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmFileInfo.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmFileInfo.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceType.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffHeader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoXpString.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossy.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterGrayscale.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterIndexedColor.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterTrueColor.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorSpaceSubset.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/QuantizedPalette.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/ParamMap.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/UnicodeUtils.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java Thu Sep 27 18:22:37 2012
@@ -129,11 +129,13 @@ public class PcxImageParser extends Imag
             throws ImageReadException, IOException {
         PcxHeader pcxHeader = readPcxHeader(byteSource);
         int xSize = pcxHeader.xMax - pcxHeader.xMin + 1;
-        if (xSize < 0)
+        if (xSize < 0) {
             throw new ImageReadException("Image width is negative");
+        }
         int ySize = pcxHeader.yMax - pcxHeader.yMin + 1;
-        if (ySize < 0)
+        if (ySize < 0) {
             throw new ImageReadException("Image height is negative");
+        }
         return new Dimension(xSize, ySize);
     }
 
@@ -216,8 +218,9 @@ public class PcxImageParser extends Imag
             pw.println("vDpi: " + vDpi);
             pw.print("ColorMap: ");
             for (int i = 0; i < colormap.length; i++) {
-                if (i > 0)
+                if (i > 0) {
                     pw.print(",");
+                }
                 pw.print("(" + (0xff & (colormap[i] >> 16)) + ","
                         + (0xff & (colormap[i] >> 8)) + ","
                         + (0xff & colormap[i]) + ")");
@@ -241,8 +244,9 @@ public class PcxImageParser extends Imag
             return readPcxHeader(is, false);
         } finally {
             try {
-                if (is != null)
+                if (is != null) {
                     is.close();
+                }
             } catch (IOException ignored) {
             }
         }
@@ -286,15 +290,17 @@ public class PcxImageParser extends Imag
         int vScreenSize = convertByteArrayToShort("vScreenSize", 72,
                 pcxHeaderBytes, BYTE_ORDER_LSB);
 
-        if (manufacturer != 10)
+        if (manufacturer != 10) {
             throw new ImageReadException(
                     "Not a Valid PCX File: manufacturer is " + manufacturer);
+        }
         if (isStrict) {
             // Note that reserved is sometimes set to a non-zero value
             // by Paintbrush itself, so it shouldn't be enforced.
-            if (bytesPerLine % 2 != 0)
+            if (bytesPerLine % 2 != 0) {
                 throw new ImageReadException(
                         "Not a Valid PCX File: bytesPerLine is odd");
+            }
         }
 
         return new PcxHeader(manufacturer, version, encoding, bitsPerPixel,
@@ -315,9 +321,10 @@ public class PcxImageParser extends Imag
             int r;
             for (int bytesRead = 0; bytesRead < samples.length; bytesRead += r) {
                 r = is.read(samples, bytesRead, samples.length - bytesRead);
-                if (r < 0)
+                if (r < 0) {
                     throw new ImageReadException(
                             "Premature end of file reading image data");
+                }
             }
         } else {
             if (pcxHeader.encoding == PcxHeader.ENCODING_RLE) {
@@ -333,21 +340,24 @@ public class PcxImageParser extends Imag
                         count = 1;
                         sample = b;
                     }
-                    for (int i = 0; i < count && bytesRead + i < samples.length; i++)
+                    for (int i = 0; i < count && bytesRead + i < samples.length; i++) {
                         samples[bytesRead + i] = sample;
+                    }
                     bytesRead += count;
                 }
-            } else
+            } else {
                 throw new ImageReadException("Invalid PCX encoding "
                         + pcxHeader.encoding);
+            }
         }
     }
 
     private int[] read256ColorPalette(InputStream stream) throws IOException {
         byte[] paletteBytes = readByteArray("Palette", 769, stream,
                 "Error reading palette");
-        if (paletteBytes[0] != 12)
+        if (paletteBytes[0] != 12) {
             return null;
+        }
         int[] palette = new int[256];
         for (int i = 0; i < palette.length; i++) {
             palette[i] = ((0xff & paletteBytes[1 + 3 * i]) << 16)
@@ -367,8 +377,9 @@ public class PcxImageParser extends Imag
             return read256ColorPalette(stream);
         } finally {
             try {
-                if (stream != null)
+                if (stream != null) {
                     stream.close();
+                }
             } catch (IOException closeException) {
             }
         }
@@ -377,11 +388,13 @@ public class PcxImageParser extends Imag
     private BufferedImage readImage(PcxHeader pcxHeader, InputStream is,
             ByteSource byteSource) throws ImageReadException, IOException {
         int xSize = pcxHeader.xMax - pcxHeader.xMin + 1;
-        if (xSize < 0)
+        if (xSize < 0) {
             throw new ImageReadException("Image width is negative");
+        }
         int ySize = pcxHeader.yMax - pcxHeader.yMin + 1;
-        if (ySize < 0)
+        if (ySize < 0) {
             throw new ImageReadException("Image height is negative");
+        }
 
         int scanlineLength = pcxHeader.bytesPerLine * pcxHeader.nPlanes;
         byte[] scanline = new byte[scanlineLength];
@@ -397,9 +410,9 @@ public class PcxImageParser extends Imag
             }
             DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
             int[] palette;
-            if (pcxHeader.bitsPerPixel == 1)
+            if (pcxHeader.bitsPerPixel == 1) {
                 palette = new int[] { 0x000000, 0xffffff };
-            else if (pcxHeader.bitsPerPixel == 8) {
+            } else if (pcxHeader.bitsPerPixel == 8) {
                 // Normally the palette is read 769 bytes from the end of the
                 // file.
                 // However DCX files have multiple PCX images in one file, so
@@ -407,13 +420,16 @@ public class PcxImageParser extends Imag
                 // palette
                 // immediately after the image data first.
                 palette = read256ColorPalette(is);
-                if (palette == null)
+                if (palette == null) {
                     palette = read256ColorPaletteFromEndOfFile(byteSource);
-                if (palette == null)
+                }
+                if (palette == null) {
                     throw new ImageReadException(
                             "No 256 color palette found in image that needs it");
-            } else
+                }
+            } else {
                 palette = pcxHeader.colormap;
+            }
             WritableRaster raster;
             if (pcxHeader.bitsPerPixel == 8) {
                 raster = WritableRaster.createInterleavedRaster(dataBuffer,
@@ -443,8 +459,9 @@ public class PcxImageParser extends Imag
                 for (int plane = 0; plane < pcxHeader.nPlanes; plane++) {
                     for (int i = 0; i < pcxHeader.bytesPerLine; i++) {
                         int b = 0xff & scanline[nextByte++];
-                        for (int j = 0; j < 8 && 8 * i + j < unpacked.length; j++)
+                        for (int j = 0; j < 8 && 8 * i + j < unpacked.length; j++) {
                             unpacked[8 * i + j] |= (byte) (((b >> (7 - j)) & 0x1) << plane);
+                        }
                     }
                 }
                 image.getRaster().setDataElements(0, y, xSize, 1, unpacked);
@@ -479,10 +496,10 @@ public class PcxImageParser extends Imag
             byte[] image = new byte[rowLength * ySize];
             for (int y = 0; y < ySize; y++) {
                 readScanLine(pcxHeader, is, scanline);
-                if (pcxHeader.bitsPerPixel == 24)
+                if (pcxHeader.bitsPerPixel == 24) {
                     System.arraycopy(scanline, 0, image, y * rowLength,
                             rowLength);
-                else {
+                } else {
                     for (int x = 0; x < xSize; x++) {
                         image[y * rowLength + 3 * x] = scanline[4 * x];
                         image[y * rowLength + 3 * x + 1] = scanline[4 * x + 1];
@@ -513,8 +530,9 @@ public class PcxImageParser extends Imag
         params = (params == null) ? new HashMap() : new HashMap(params);
         boolean isStrict = false;
         Object strictness = params.get(PARAM_KEY_STRICT);
-        if (strictness != null)
+        if (strictness != null) {
             isStrict = ((Boolean) strictness).booleanValue();
+        }
 
         InputStream is = null;
         try {
@@ -523,8 +541,9 @@ public class PcxImageParser extends Imag
             return readImage(pcxHeader, is, byteSource);
         } finally {
             try {
-                if (is != null)
+                if (is != null) {
                     is.close();
+                }
             } catch (IOException ignored) {
             }
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java Thu Sep 27 18:22:37 2012
@@ -38,8 +38,9 @@ public class PcxWriter implements PcxCon
         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);
+        }
 
         // uncompressed PCX files are not even documented in ZSoft's spec,
         // let alone supported by most image viewers
@@ -47,21 +48,24 @@ public class PcxWriter implements PcxCon
         if (params.containsKey(PARAM_KEY_PCX_COMPRESSION)) {
             Object value = params.remove(PARAM_KEY_PCX_COMPRESSION);
             if (value != null) {
-                if (!(value instanceof Number))
+                if (!(value instanceof Number)) {
                     throw new ImageWriteException(
                             "Invalid compression parameter: " + value);
+                }
                 int compression = ((Number) value).intValue();
-                if (compression == PCX_COMPRESSION_UNCOMPRESSED)
+                if (compression == PCX_COMPRESSION_UNCOMPRESSED) {
                     encoding = PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED;
+                }
             }
         }
 
         if (params.containsKey(PARAM_KEY_PCX_BIT_DEPTH)) {
             Object value = params.remove(PARAM_KEY_PCX_BIT_DEPTH);
             if (value != null) {
-                if (!(value instanceof Number))
+                if (!(value instanceof Number)) {
                     throw new ImageWriteException(
                             "Invalid bit depth parameter: " + value);
+                }
                 bitDepth = ((Number) value).intValue();
             }
         }
@@ -69,9 +73,10 @@ public class PcxWriter implements PcxCon
         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");
+                }
                 pixelDensity = (PixelDensity) value;
             }
         }
@@ -88,22 +93,22 @@ public class PcxWriter implements PcxCon
 
     private void writeScanLine(BinaryOutputStream bos, byte[] scanline)
             throws IOException, ImageWriteException {
-        if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED)
+        if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED) {
             bos.writeByteArray(scanline);
-        else {
+        } else {
             if (encoding == PcxImageParser.PcxHeader.ENCODING_RLE) {
                 int previousByte = -1;
                 int repeatCount = 0;
                 for (int i = 0; i < scanline.length; i++) {
                     if ((scanline[i] & 0xff) == previousByte
-                            && repeatCount < 63)
+                            && repeatCount < 63) {
                         ++repeatCount;
-                    else {
+                    } else {
                         if (repeatCount > 0) {
                             if (repeatCount == 1
-                                    && (previousByte & 0xc0) != 0xc0)
+                                    && (previousByte & 0xc0) != 0xc0) {
                                 bos.write(previousByte);
-                            else {
+                            } else {
                                 bos.write(0xc0 | repeatCount);
                                 bos.write(previousByte);
                             }
@@ -113,16 +118,17 @@ public class PcxWriter implements PcxCon
                     }
                 }
                 if (repeatCount > 0) {
-                    if (repeatCount == 1 && (previousByte & 0xc0) != 0xc0)
+                    if (repeatCount == 1 && (previousByte & 0xc0) != 0xc0) {
                         bos.write(previousByte);
-                    else {
+                    } else {
                         bos.write(0xc0 | repeatCount);
                         bos.write(previousByte);
                     }
                 }
-            } else
+            } else {
                 throw new ImageWriteException("Invalid PCX encoding "
                         + encoding);
+            }
         }
     }
 
@@ -134,30 +140,34 @@ public class PcxWriter implements PcxCon
         BinaryOutputStream bos = new BinaryOutputStream(os,
                 BinaryOutputStream.BYTE_ORDER_INTEL);
         if (palette == null || bitDepth == 24 || bitDepth == 32) {
-            if (bitDepth == 32)
+            if (bitDepth == 32) {
                 write32BppPCX(src, bos);
-            else
+            } else {
                 write24BppPCX(src, bos);
-        } else if (palette.length() > 16 || bitDepth == 8)
+            }
+        } else if (palette.length() > 16 || bitDepth == 8) {
             write256ColorPCX(src, palette, bos);
-        else if (palette.length() > 2 || bitDepth == 4)
+        } else if (palette.length() > 2 || bitDepth == 4) {
             write16ColorPCX(src, palette, bos);
-        else {
+        } else {
             boolean onlyBlackAndWhite = true;
             if (palette.length() >= 1) {
                 int rgb = palette.getEntry(0);
-                if (rgb != 0 && rgb != 0xffffff)
+                if (rgb != 0 && rgb != 0xffffff) {
                     onlyBlackAndWhite = false;
+                }
             }
             if (palette.length() == 2) {
                 int rgb = palette.getEntry(1);
-                if (rgb != 0 && rgb != 0xffffff)
+                if (rgb != 0 && rgb != 0xffffff) {
                     onlyBlackAndWhite = false;
+                }
             }
-            if (onlyBlackAndWhite)
+            if (onlyBlackAndWhite) {
                 writeBlackAndWhitePCX(src, palette, bos);
-            else
+            } else {
                 write16ColorPCX(src, palette, bos);
+            }
         }
     }
 
@@ -244,8 +254,9 @@ public class PcxWriter implements PcxCon
             SimplePalette palette, BinaryOutputStream bos)
             throws ImageWriteException, IOException {
         int bytesPerLine = (src.getWidth() + 7) / 8;
-        if (bytesPerLine % 2 != 0)
+        if (bytesPerLine % 2 != 0) {
             ++bytesPerLine;
+        }
 
         // PCX header
         bos.write(10); // manufacturer
@@ -275,13 +286,14 @@ public class PcxWriter implements PcxCon
             for (int x = 0; x < src.getWidth(); x++) {
                 int rgb = 0xffffff & src.getRGB(x, y);
                 int bit;
-                if (rgb == 0x000000)
+                if (rgb == 0x000000) {
                     bit = 0;
-                else if (rgb == 0xffffff)
+                } else if (rgb == 0xffffff) {
                     bit = 1;
-                else
+                } else {
                     throw new ImageWriteException(
                             "Pixel neither black nor white");
+                }
                 row[x / 8] |= (bit << (7 - (x % 8)));
             }
             writeScanLine(bos, row);
@@ -291,16 +303,18 @@ public class PcxWriter implements PcxCon
     private void write16ColorPCX(BufferedImage src, SimplePalette palette,
             BinaryOutputStream bos) throws ImageWriteException, IOException {
         int bytesPerLine = (src.getWidth() + 1) / 2;
-        if (bytesPerLine % 2 != 0)
+        if (bytesPerLine % 2 != 0) {
             ++bytesPerLine;
+        }
 
         byte[] palette16 = new byte[16 * 3];
         for (int i = 0; i < 16; i++) {
             int rgb;
-            if (i < palette.length())
+            if (i < palette.length()) {
                 rgb = palette.getEntry(i);
-            else
+            } else {
                 rgb = 0;
+            }
             palette16[3 * i + 0] = (byte) (0xff & (rgb >> 16));
             palette16[3 * i + 1] = (byte) (0xff & (rgb >> 8));
             palette16[3 * i + 2] = (byte) (0xff & rgb);
@@ -378,10 +392,11 @@ public class PcxWriter implements PcxCon
         bos.write(12);
         for (int i = 0; i < 256; i++) {
             int rgb;
-            if (i < palette.length())
+            if (i < palette.length()) {
                 rgb = palette.getEntry(i);
-            else
+            } else {
                 rgb = 0;
+            }
             bos.write((rgb >> 16) & 0xff);
             bos.write((rgb >> 8) & 0xff);
             bos.write(rgb & 0xff);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/BitParser.java Thu Sep 27 18:22:37 2012
@@ -35,9 +35,9 @@ public class BitParser {
         int sampleIndexBits = pixelIndexBits + (sampleIndex * bitDepth);
         int sampleIndexBytes = sampleIndexBits >> 3;
 
-        if (bitDepth == 8)
+        if (bitDepth == 8) {
             return 0xff & bytes[sampleIndexBytes];
-        else if (bitDepth < 8) {
+        } else if (bitDepth < 8) {
             int b = 0xff & bytes[sampleIndexBytes];
             int bitsToShift = 8 - ((pixelIndexBits & 7) + bitDepth);
             b >>= bitsToShift;
@@ -56,10 +56,11 @@ public class BitParser {
         int sample = getSample(pixelIndexInScanline, sampleIndex);
 
         int rot = 8 - bitDepth;
-        if (rot > 0)
+        if (rot > 0) {
             sample = sample * 255 / ((1 << bitDepth) - 1);
-        else if (rot < 0)
+        } else if (rot < 0) {
             sample >>= -rot;
+        }
 
         return 0xff & sample;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngCrc.java Thu Sep 27 18:22:37 2012
@@ -32,11 +32,11 @@ public class PngCrc {
         for (n = 0; n < 256; n++) {
             c = n;
             for (k = 0; k < 8; k++) {
-                if ((c & 1) != 0)
-
+                if ((c & 1) != 0) {
                     c = 0xedb88320L ^ (c >> 1);
-                else
+                } else {
                     c = c >> 1;
+                }
             }
             crc_table[n] = c;
         }
@@ -53,8 +53,9 @@ public class PngCrc {
         long c = crc;
         int n;
 
-        if (!crc_table_computed)
+        if (!crc_table_computed) {
             make_crc_table();
+        }
         for (n = 0; n < buf.length; n++) {
             // Debug.debug("crc[" + n + "]", c + " (" + Long.toHexString(c) +
             // ")");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Thu Sep 27 18:22:37 2012
@@ -143,12 +143,14 @@ public class PngImageParser extends Imag
 
     private boolean keepChunk(int ChunkType, int chunkTypes[]) {
         // System.out.println("keepChunk: ");
-        if (chunkTypes == null)
+        if (chunkTypes == null) {
             return true;
+        }
 
         for (int i = 0; i < chunkTypes.length; i++) {
-            if (chunkTypes[i] == ChunkType)
+            if (chunkTypes[i] == ChunkType) {
                 return true;
+            }
         }
         return false;
     }
@@ -158,8 +160,9 @@ public class PngImageParser extends Imag
         List<PngChunk> result = new ArrayList<PngChunk>();
 
         while (true) {
-            if (debug)
+            if (debug) {
                 System.out.println("");
+            }
 
             int length = read4Bytes("Length", is, "Not a Valid PNG File");
             int chunkType = read4Bytes("ChunkType", is, "Not a Valid PNG File");
@@ -174,43 +177,49 @@ public class PngImageParser extends Imag
             if (keep) {
                 bytes = readByteArray("Chunk Data", length, is,
                         "Not a Valid PNG File: Couldn't read Chunk Data.");
-            } else
+            } else {
                 skipBytes(is, length, "Not a Valid PNG File");
+            }
 
-            if (debug)
-                if (bytes != null)
+            if (debug) {
+                if (bytes != null) {
                     debugNumber("bytes", bytes.length, 4);
+                }
+            }
 
             int CRC = read4Bytes("CRC", is, "Not a Valid PNG File");
 
             if (keep) {
-                if (chunkType == iCCP)
+                if (chunkType == iCCP) {
                     result.add(new PngChunkIccp(length, chunkType, CRC, bytes));
-                else if (chunkType == tEXt)
+                } else if (chunkType == tEXt) {
                     result.add(new PngChunkText(length, chunkType, CRC, bytes));
-                else if (chunkType == zTXt)
+                } else if (chunkType == zTXt) {
                     result.add(new PngChunkZtxt(length, chunkType, CRC, bytes));
-                else if (chunkType == IHDR)
+                } else if (chunkType == IHDR) {
                     result.add(new PngChunkIhdr(length, chunkType, CRC, bytes));
-                else if (chunkType == PLTE)
+                } else if (chunkType == PLTE) {
                     result.add(new PngChunkPlte(length, chunkType, CRC, bytes));
-                else if (chunkType == pHYs)
+                } else if (chunkType == pHYs) {
                     result.add(new PngChunkPhys(length, chunkType, CRC, bytes));
-                else if (chunkType == IDAT)
+                } else if (chunkType == IDAT) {
                     result.add(new PngChunkIdat(length, chunkType, CRC, bytes));
-                else if (chunkType == gAMA)
+                } else if (chunkType == gAMA) {
                     result.add(new PngChunkGama(length, chunkType, CRC, bytes));
-                else if (chunkType == iTXt)
+                } else if (chunkType == iTXt) {
                     result.add(new PngChunkItxt(length, chunkType, CRC, bytes));
-                else
+                } else { 
                     result.add(new PngChunk(length, chunkType, CRC, bytes));
+                }
 
-                if (returnAfterFirst)
+                if (returnAfterFirst) {
                     return result;
+                }
             }
 
-            if (chunkType == IEND)
+            if (chunkType == IEND) {
                 break;
+            }
 
         }
 
@@ -257,9 +266,10 @@ public class PngImageParser extends Imag
             return null;
         }
 
-        if (chunks.size() > 1)
+        if (chunks.size() > 1) {
             throw new ImageReadException(
                     "PNG contains more than one ICC Profile ");
+        }
 
         PngChunkIccp pngChunkiCCP = (PngChunkIccp) chunks.get(0);
         byte bytes[] = pngChunkiCCP.UncompressedProfile;
@@ -273,11 +283,13 @@ public class PngImageParser extends Imag
         List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, },
                 true);
 
-        if ((chunks == null) || (chunks.size() < 1))
+        if ((chunks == null) || (chunks.size() < 1)) {
             throw new ImageReadException("Png: No chunks");
+        }
 
-        if (chunks.size() > 1)
+        if (chunks.size() > 1) {
             throw new ImageReadException("PNG contains more than one Header");
+        }
 
         PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) chunks.get(0);
 
@@ -299,8 +311,9 @@ public class PngImageParser extends Imag
         List<PngChunk> chunks = readChunks(byteSource,
                 new int[] { tEXt, zTXt, }, true);
 
-        if ((chunks == null) || (chunks.size() < 1))
+        if ((chunks == null) || (chunks.size() < 1)) {
             return null;
+        }
 
         ImageMetadata result = new ImageMetadata();
 
@@ -410,8 +423,9 @@ public class PngImageParser extends Imag
 
         for (int i = 0; i < v.size(); i++) {
             PngChunk chunk = v.get(i);
-            if (chunk.chunkType == type)
+            if (chunk.chunkType == type) {
                 result.add(chunk);
+            }
         }
 
         return result;
@@ -496,12 +510,14 @@ public class PngImageParser extends Imag
         // if(chunks!=null)
         // System.out.println("chunks: " + chunks.size());
 
-        if ((chunks == null) || (chunks.size() < 1))
+        if ((chunks == null) || (chunks.size() < 1)) {
             throw new ImageReadException("PNG: no chunks");
+        }
 
         List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
-        if (IHDRs.size() != 1)
+        if (IHDRs.size() != 1) {
             throw new ImageReadException("PNG contains more than one Header");
+        }
 
         PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
 
@@ -519,112 +535,111 @@ public class PngImageParser extends Imag
         PngChunkPhys pngChunkpHYs = null;
 
         List<PngChunk> pHYss = filterChunks(chunks, pHYs);
-        if (pHYss.size() > 1)
+        if (pHYss.size() > 1) {
             throw new ImageReadException("PNG contains more than one pHYs: "
                     + pHYss.size());
-        else if (pHYss.size() == 1)
+        } else if (pHYss.size() == 1) {
             pngChunkpHYs = (PngChunkPhys) pHYss.get(0);
+        }
 
         List<PngChunk> tEXts = filterChunks(chunks, tEXt);
         List<PngChunk> zTXts = filterChunks(chunks, zTXt);
         List<PngChunk> iTXts = filterChunks(chunks, iTXt);
 
-        {
-            List<String> comments = new ArrayList<String>();
-            List<PngText> textChunks = new ArrayList<PngText>();
+        List<String> comments = new ArrayList<String>();
+        List<PngText> textChunks = new ArrayList<PngText>();
 
-            for (int i = 0; i < tEXts.size(); i++) {
-                PngChunkText pngChunktEXt = (PngChunkText) tEXts.get(i);
-                comments.add(pngChunktEXt.keyword + ": " + pngChunktEXt.text);
-                textChunks.add(pngChunktEXt.getContents());
-            }
-            for (int i = 0; i < zTXts.size(); i++) {
-                PngChunkZtxt pngChunkzTXt = (PngChunkZtxt) zTXts.get(i);
-                comments.add(pngChunkzTXt.keyword + ": " + pngChunkzTXt.text);
-                textChunks.add(pngChunkzTXt.getContents());
-            }
-            for (int i = 0; i < iTXts.size(); i++) {
-                PngChunkItxt pngChunkiTXt = (PngChunkItxt) iTXts.get(i);
-                comments.add(pngChunkiTXt.keyword + ": " + pngChunkiTXt.text);
-                textChunks.add(pngChunkiTXt.getContents());
-            }
-
-            int BitsPerPixel = pngChunkIHDR.bitDepth
-                    * samplesPerPixel(pngChunkIHDR.colorType);
-            ImageFormat Format = ImageFormat.IMAGE_FORMAT_PNG;
-            String FormatName = "PNG Portable Network Graphics";
-            int Height = pngChunkIHDR.height;
-            String MimeType = "image/png";
-            int NumberOfImages = 1;
-            int Width = pngChunkIHDR.width;
-            boolean isProgressive = (pngChunkIHDR.interlaceMethod != 0);
-
-            int PhysicalHeightDpi = -1;
-            float PhysicalHeightInch = -1;
-            int PhysicalWidthDpi = -1;
-            float PhysicalWidthInch = -1;
-
-            // if (pngChunkpHYs != null)
-            // {
-            // System.out.println("\t" + "pngChunkpHYs.UnitSpecifier: " +
-            // pngChunkpHYs.UnitSpecifier );
-            // System.out.println("\t" + "pngChunkpHYs.PixelsPerUnitYAxis: " +
-            // pngChunkpHYs.PixelsPerUnitYAxis );
-            // System.out.println("\t" + "pngChunkpHYs.PixelsPerUnitXAxis: " +
-            // pngChunkpHYs.PixelsPerUnitXAxis );
-            // }
-            if ((pngChunkpHYs != null) && (pngChunkpHYs.UnitSpecifier == 1)) // meters
-            {
-                double meters_per_inch = 0.0254;
-
-                PhysicalWidthDpi = (int) Math
-                        .round(pngChunkpHYs.PixelsPerUnitXAxis
-                                * meters_per_inch);
-                PhysicalWidthInch = (float) ((double) Width / ((double) pngChunkpHYs.PixelsPerUnitXAxis * meters_per_inch));
-                PhysicalHeightDpi = (int) Math
-                        .round(pngChunkpHYs.PixelsPerUnitYAxis
-                                * meters_per_inch);
-                PhysicalHeightInch = (float) ((double) Height / ((double) pngChunkpHYs.PixelsPerUnitYAxis * meters_per_inch));
-            }
-
-            String FormatDetails = "Png";
-
-            boolean usesPalette = false;
-
-            List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
-            if (PLTEs.size() > 1)
-                usesPalette = true;
-
-            int ColorType;
-            switch (pngChunkIHDR.colorType) {
-            case COLOR_TYPE_GREYSCALE: // 1,2,4,8,16 Each pixel is a grayscale
-                // sample.
-            case COLOR_TYPE_GREYSCALE_WITH_ALPHA: // 8,16 Each pixel is a
-                // grayscale sample,
-                // followed by an alpha sample.
-                ColorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
-                break;
-            case COLOR_TYPE_TRUE_COLOR: // 8,16 Each pixel is an R,G,B triple.
-            case COLOR_TYPE_INDEXED_COLOR: // 1,2,4,8 Each pixel is a palette
-                // index;
-            case COLOR_TYPE_TRUE_COLOR_WITH_ALPHA: // 8,16 Each pixel is an
-                // R,G,B triple,
-                // followed by an alpha sample.
-                ColorType = ImageInfo.COLOR_TYPE_RGB;
-                break;
-            default:
-                throw new ImageReadException("Png: Unknown ColorType: "
-                        + pngChunkIHDR.colorType);
-            }
+        for (int i = 0; i < tEXts.size(); i++) {
+            PngChunkText pngChunktEXt = (PngChunkText) tEXts.get(i);
+            comments.add(pngChunktEXt.keyword + ": " + pngChunktEXt.text);
+            textChunks.add(pngChunktEXt.getContents());
+        }
+        for (int i = 0; i < zTXts.size(); i++) {
+            PngChunkZtxt pngChunkzTXt = (PngChunkZtxt) zTXts.get(i);
+            comments.add(pngChunkzTXt.keyword + ": " + pngChunkzTXt.text);
+            textChunks.add(pngChunkzTXt.getContents());
+        }
+        for (int i = 0; i < iTXts.size(); i++) {
+            PngChunkItxt pngChunkiTXt = (PngChunkItxt) iTXts.get(i);
+            comments.add(pngChunkiTXt.keyword + ": " + pngChunkiTXt.text);
+            textChunks.add(pngChunkiTXt.getContents());
+        }
+
+        int BitsPerPixel = pngChunkIHDR.bitDepth
+                * samplesPerPixel(pngChunkIHDR.colorType);
+        ImageFormat Format = ImageFormat.IMAGE_FORMAT_PNG;
+        String FormatName = "PNG Portable Network Graphics";
+        int Height = pngChunkIHDR.height;
+        String MimeType = "image/png";
+        int NumberOfImages = 1;
+        int Width = pngChunkIHDR.width;
+        boolean isProgressive = (pngChunkIHDR.interlaceMethod != 0);
+
+        int PhysicalHeightDpi = -1;
+        float PhysicalHeightInch = -1;
+        int PhysicalWidthDpi = -1;
+        float PhysicalWidthInch = -1;
+
+        // if (pngChunkpHYs != null)
+        // {
+        // System.out.println("\t" + "pngChunkpHYs.UnitSpecifier: " +
+        // pngChunkpHYs.UnitSpecifier );
+        // System.out.println("\t" + "pngChunkpHYs.PixelsPerUnitYAxis: " +
+        // pngChunkpHYs.PixelsPerUnitYAxis );
+        // System.out.println("\t" + "pngChunkpHYs.PixelsPerUnitXAxis: " +
+        // pngChunkpHYs.PixelsPerUnitXAxis );
+        // }
+        if ((pngChunkpHYs != null) && (pngChunkpHYs.UnitSpecifier == 1)) { // meters
+            double meters_per_inch = 0.0254;
+
+            PhysicalWidthDpi = (int) Math
+                    .round(pngChunkpHYs.PixelsPerUnitXAxis
+                            * meters_per_inch);
+            PhysicalWidthInch = (float) ((double) Width / ((double) pngChunkpHYs.PixelsPerUnitXAxis * meters_per_inch));
+            PhysicalHeightDpi = (int) Math
+                    .round(pngChunkpHYs.PixelsPerUnitYAxis
+                            * meters_per_inch);
+            PhysicalHeightInch = (float) ((double) Height / ((double) pngChunkpHYs.PixelsPerUnitYAxis * meters_per_inch));
+        }
 
-            String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_PNG_FILTER;
-
-            return new PngImageInfo(FormatDetails, BitsPerPixel, comments,
-                    Format, FormatName, Height, MimeType, NumberOfImages,
-                    PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
-                    PhysicalWidthInch, Width, isProgressive, isTransparent,
-                    usesPalette, ColorType, compressionAlgorithm, textChunks);
+        String FormatDetails = "Png";
+
+        boolean usesPalette = false;
+
+        List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
+        if (PLTEs.size() > 1) {
+            usesPalette = true;
+        }
+
+        int ColorType;
+        switch (pngChunkIHDR.colorType) {
+        case COLOR_TYPE_GREYSCALE: // 1,2,4,8,16 Each pixel is a grayscale
+            // sample.
+        case COLOR_TYPE_GREYSCALE_WITH_ALPHA: // 8,16 Each pixel is a
+            // grayscale sample,
+            // followed by an alpha sample.
+            ColorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
+            break;
+        case COLOR_TYPE_TRUE_COLOR: // 8,16 Each pixel is an R,G,B triple.
+        case COLOR_TYPE_INDEXED_COLOR: // 1,2,4,8 Each pixel is a palette
+            // index;
+        case COLOR_TYPE_TRUE_COLOR_WITH_ALPHA: // 8,16 Each pixel is an
+            // R,G,B triple,
+            // followed by an alpha sample.
+            ColorType = ImageInfo.COLOR_TYPE_RGB;
+            break;
+        default:
+            throw new ImageReadException("Png: Unknown ColorType: "
+                    + pngChunkIHDR.colorType);
         }
+
+        String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_PNG_FILTER;
+
+        return new PngImageInfo(FormatDetails, BitsPerPixel, comments,
+                Format, FormatName, Height, MimeType, NumberOfImages,
+                PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
+                PhysicalWidthInch, Width, isProgressive, isTransparent,
+                usesPalette, ColorType, compressionAlgorithm, textChunks);
     }
 
     @Override
@@ -632,8 +647,9 @@ public class PngImageParser extends Imag
             throws ImageReadException, IOException {
         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();
@@ -643,28 +659,33 @@ public class PngImageParser extends Imag
         List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, PLTE,
                 IDAT, tRNS, iCCP, gAMA, sRGB, }, false);
 
-        if ((chunks == null) || (chunks.size() < 1))
+        if ((chunks == null) || (chunks.size() < 1)) {
             throw new ImageReadException("PNG: no chunks");
+        }
 
         List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
-        if (IHDRs.size() != 1)
+        if (IHDRs.size() != 1) {
             throw new ImageReadException("PNG contains more than one Header");
+        }
 
         PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
 
         List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
-        if (PLTEs.size() > 1)
+        if (PLTEs.size() > 1) {
             throw new ImageReadException("PNG contains more than one Palette");
+        }
 
         PngChunkPlte pngChunkPLTE = null;
-        if (PLTEs.size() == 1)
+        if (PLTEs.size() == 1) {
             pngChunkPLTE = (PngChunkPlte) PLTEs.get(0);
+        }
 
         // -----
 
         List<PngChunk> IDATs = filterChunks(chunks, IDAT);
-        if (IDATs.size() < 1)
+        if (IDATs.size() < 1) {
             throw new ImageReadException("PNG missing image data");
+        }
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         for (int i = 0; i < IDATs.size(); i++) {
@@ -693,20 +714,25 @@ public class PngImageParser extends Imag
             List<PngChunk> sRGBs = filterChunks(chunks, sRGB);
             List<PngChunk> gAMAs = filterChunks(chunks, gAMA);
             List<PngChunk> iCCPs = filterChunks(chunks, iCCP);
-            if (sRGBs.size() > 1)
+            if (sRGBs.size() > 1) {
                 throw new ImageReadException("PNG: unexpected sRGB chunk");
-            if (gAMAs.size() > 1)
+            }
+            if (gAMAs.size() > 1) {
                 throw new ImageReadException("PNG: unexpected gAMA chunk");
-            if (iCCPs.size() > 1)
+            }
+            if (iCCPs.size() > 1) {
                 throw new ImageReadException("PNG: unexpected iCCP chunk");
+            }
 
             if (sRGBs.size() == 1) {
                 // no color management neccesary.
-                if (debug)
+                if (debug) {
                     System.out.println("sRGB, no color management neccesary.");
+                }
             } else if (iCCPs.size() == 1) {
-                if (debug)
+                if (debug) {
                     System.out.println("iCCP.");
+                }
 
                 PngChunkIccp pngChunkiCCP = (PngChunkIccp) iCCPs.get(0);
                 byte bytes[] = pngChunkiCCP.UncompressedProfile;
@@ -720,12 +746,15 @@ public class PngImageParser extends Imag
                 // double targetGamma = 2.2;
                 double targetGamma = 1.0;
                 double diff = Math.abs(targetGamma - gamma);
-                if (diff >= 0.5)
+                if (diff >= 0.5) {
                     gammaCorrection = new GammaCorrection(gamma, targetGamma);
+                }
 
-                if (gammaCorrection != null)
-                    if (pngChunkPLTE != null)
+                if (gammaCorrection != null) {
+                    if (pngChunkPLTE != null) {
                         pngChunkPLTE.correct(gammaCorrection);
+                    }
+                }
 
             }
         }
@@ -738,9 +767,10 @@ public class PngImageParser extends Imag
 
             int bitsPerSample = bitDepth;
 
-            if (pngChunkIHDR.filterMethod != 0)
+            if (pngChunkIHDR.filterMethod != 0) {
                 throw new ImageReadException("PNG: unknown FilterMethod: "
                         + pngChunkIHDR.filterMethod);
+            }
 
             int samplesPerPixel = samplesPerPixel(pngChunkIHDR.colorType);
             boolean isGrayscale = isGrayscale(pngChunkIHDR.colorType);
@@ -751,29 +781,31 @@ public class PngImageParser extends Imag
                     || colorType == COLOR_TYPE_TRUE_COLOR_WITH_ALPHA;
 
             BufferedImage result;
-            if (isGrayscale)
+            if (isGrayscale) {
                 result = getBufferedImageFactory(params)
                         .getGrayscaleBufferedImage(width, height, hasAlpha);
-            else
+            } else {
                 result = getBufferedImageFactory(params).getColorBufferedImage(
                         width, height, hasAlpha);
+            }
 
             ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
             InflaterInputStream iis = new InflaterInputStream(bais);
 
             ScanExpediter scanExpediter;
 
-            if (pngChunkIHDR.interlaceMethod == 0)
+            if (pngChunkIHDR.interlaceMethod == 0) {
                 scanExpediter = new ScanExpediterSimple(width, height, iis,
                         result, colorType, bitDepth, bitsPerPixel,
                         pngChunkPLTE, gammaCorrection, transparencyFilter);
-            else if (pngChunkIHDR.interlaceMethod == 1)
+            } else if (pngChunkIHDR.interlaceMethod == 1) {
                 scanExpediter = new ScanExpediterInterlaced(width, height, iis,
                         result, colorType, bitDepth, bitsPerPixel,
                         pngChunkPLTE, gammaCorrection, transparencyFilter);
-            else
+            } else {
                 throw new ImageReadException("Unknown InterlaceMethod: "
                         + pngChunkIHDR.interlaceMethod);
+            }
 
             scanExpediter.drive();
 
@@ -800,34 +832,33 @@ public class PngImageParser extends Imag
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
             throws ImageReadException, IOException {
         ImageInfo imageInfo = getImageInfo(byteSource);
-        if (imageInfo == null)
+        if (imageInfo == null) {
             return false;
+        }
 
         imageInfo.toString(pw, "");
 
-        {
-            List<PngChunk> chunks = readChunks(byteSource, null, false);
-            {
-                List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
-                if (IHDRs.size() != 1) {
-                    if (debug)
-                        System.out.println("PNG contains more than one Header");
-                    return false;
-                }
-                PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
-                pw.println("Color: "
-                        + getColorTypeDescription(pngChunkIHDR.colorType));
+        List<PngChunk> chunks = readChunks(byteSource, null, false);
+        List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
+        if (IHDRs.size() != 1) {
+            if (debug) {
+                System.out.println("PNG contains more than one Header");
             }
+            return false;
+        }
+        PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
+        pw.println("Color: "
+                + getColorTypeDescription(pngChunkIHDR.colorType));
 
-            pw.println("chunks: " + chunks.size());
+        pw.println("chunks: " + chunks.size());
 
-            if ((chunks.size() < 1))
-                return false;
+        if ((chunks.size() < 1)) {
+            return false;
+        }
 
-            for (int i = 0; i < chunks.size(); i++) {
-                PngChunk chunk = chunks.get(i);
-                printCharQuad(pw, "\t" + i + ": ", chunk.chunkType);
-            }
+        for (int i = 0; i < chunks.size(); i++) {
+            PngChunk chunk = chunks.get(i);
+            printCharQuad(pw, "\t" + i + ": ", chunk.chunkType);
         }
 
         pw.println("");
@@ -860,22 +891,26 @@ public class PngImageParser extends Imag
         List<PngChunk> chunks = readChunks(byteSource, new int[] { iTXt, },
                 false);
 
-        if ((chunks == null) || (chunks.size() < 1))
+        if ((chunks == null) || (chunks.size() < 1)) {
             return null;
+        }
 
         List<PngChunkItxt> xmpChunks = new ArrayList<PngChunkItxt>();
         for (int i = 0; i < chunks.size(); i++) {
             PngChunkItxt chunk = (PngChunkItxt) chunks.get(i);
-            if (!chunk.getKeyword().equals(XMP_KEYWORD))
+            if (!chunk.getKeyword().equals(XMP_KEYWORD)) {
                 continue;
+            }
             xmpChunks.add(chunk);
         }
 
-        if (xmpChunks.size() < 1)
+        if (xmpChunks.size() < 1) {
             return null;
-        if (xmpChunks.size() > 1)
+        }
+        if (xmpChunks.size() > 1) {
             throw new ImageReadException(
                     "PNG contains more than one XMP chunk.");
+        }
 
         PngChunkItxt chunk = xmpChunks.get(0);
         return chunk.getText();

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java Thu Sep 27 18:22:37 2012
@@ -76,8 +76,9 @@ public class PngWriter implements PngCon
         int dataLength = data == null ? 0 : data.length;
         writeInt(os, dataLength);
         os.write(chunkType);
-        if (data != null)
+        if (data != null) {
             os.write(data);
+        }
 
         // Debug.debug("writeChunk chunkType", chunkType);
         // Debug.debug("writeChunk data", data);
@@ -142,13 +143,15 @@ public class PngWriter implements PngCon
 
     private void writeChunkiTXt(OutputStream os, PngText.Itxt text)
             throws IOException, ImageWriteException {
-        if (!UnicodeUtils.isValidISO_8859_1(text.keyword))
+        if (!UnicodeUtils.isValidISO_8859_1(text.keyword)) {
             throw new ImageWriteException(
                     "Png tEXt chunk keyword is not ISO-8859-1: " + text.keyword);
-        if (!UnicodeUtils.isValidISO_8859_1(text.languageTag))
+        }
+        if (!UnicodeUtils.isValidISO_8859_1(text.languageTag)) {
             throw new ImageWriteException(
                     "Png tEXt chunk language tag is not ISO-8859-1: "
                             + text.languageTag);
+        }
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
@@ -174,12 +177,14 @@ public class PngWriter implements PngCon
 
     private void writeChunkzTXt(OutputStream os, PngText.Ztxt text)
             throws IOException, ImageWriteException {
-        if (!UnicodeUtils.isValidISO_8859_1(text.keyword))
+        if (!UnicodeUtils.isValidISO_8859_1(text.keyword)) {
             throw new ImageWriteException(
                     "Png zTXt chunk keyword is not ISO-8859-1: " + text.keyword);
-        if (!UnicodeUtils.isValidISO_8859_1(text.text))
+        }
+        if (!UnicodeUtils.isValidISO_8859_1(text.text)) {
             throw new ImageWriteException(
                     "Png zTXt chunk text is not ISO-8859-1: " + text.text);
+        }
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
@@ -198,12 +203,14 @@ public class PngWriter implements PngCon
 
     private void writeChunktEXt(OutputStream os, PngText.Text text)
             throws IOException, ImageWriteException {
-        if (!UnicodeUtils.isValidISO_8859_1(text.keyword))
+        if (!UnicodeUtils.isValidISO_8859_1(text.keyword)) {
             throw new ImageWriteException(
                     "Png tEXt chunk keyword is not ISO-8859-1: " + text.keyword);
-        if (!UnicodeUtils.isValidISO_8859_1(text.text))
+        }
+        if (!UnicodeUtils.isValidISO_8859_1(text.text)) {
             throw new ImageWriteException(
                     "Png tEXt chunk text is not ISO-8859-1: " + text.text);
+        }
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
@@ -287,17 +294,19 @@ public class PngWriter implements PngCon
 
         boolean index = false; // charles
 
-        if (index)
+        if (index) {
             result = COLOR_TYPE_INDEXED_COLOR;
-        else if (isGrayscale) {
-            if (hasAlpha)
+        } else if (isGrayscale) {
+            if (hasAlpha) {
                 result = COLOR_TYPE_GREYSCALE_WITH_ALPHA;
-            else
+            } else {
                 result = COLOR_TYPE_GREYSCALE;
-        } else if (hasAlpha)
+            }
+        } else if (hasAlpha) {
             result = COLOR_TYPE_TRUE_COLOR_WITH_ALPHA;
-        else
+        } else {
             result = COLOR_TYPE_TRUE_COLOR;
+        }
 
         return result;
     }
@@ -360,23 +369,30 @@ public class PngWriter implements PngCon
         params = new HashMap(params);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
+        }
         // clear verbose key.
-        if (params.containsKey(PARAM_KEY_VERBOSE))
+        if (params.containsKey(PARAM_KEY_VERBOSE)) {
             params.remove(PARAM_KEY_VERBOSE);
+        }
 
         Map rawParams = new HashMap(params);
-        if (params.containsKey(PARAM_KEY_PNG_FORCE_TRUE_COLOR))
+        if (params.containsKey(PARAM_KEY_PNG_FORCE_TRUE_COLOR)) {
             params.remove(PARAM_KEY_PNG_FORCE_TRUE_COLOR);
-        if (params.containsKey(PARAM_KEY_PNG_FORCE_INDEXED_COLOR))
+        }
+        if (params.containsKey(PARAM_KEY_PNG_FORCE_INDEXED_COLOR)) {
             params.remove(PARAM_KEY_PNG_FORCE_INDEXED_COLOR);
-        if (params.containsKey(PARAM_KEY_PNG_BIT_DEPTH))
+        }
+        if (params.containsKey(PARAM_KEY_PNG_BIT_DEPTH)) {
             params.remove(PARAM_KEY_PNG_BIT_DEPTH);
-        if (params.containsKey(PARAM_KEY_XMP_XML))
+        }
+        if (params.containsKey(PARAM_KEY_XMP_XML)) {
             params.remove(PARAM_KEY_XMP_XML);
-        if (params.containsKey(PARAM_KEY_PNG_TEXT_CHUNKS))
+        }
+        if (params.containsKey(PARAM_KEY_PNG_TEXT_CHUNKS)) {
             params.remove(PARAM_KEY_PNG_TEXT_CHUNKS);
+        }
         params.remove(PARAM_KEY_PIXEL_DENSITY);
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -388,13 +404,15 @@ public class PngWriter implements PngCon
         int height = src.getHeight();
 
         boolean hasAlpha = new PaletteFactory().hasTransparency(src);
-        if (verbose)
+        if (verbose) {
             Debug.debug("hasAlpha", hasAlpha);
+        }
         // int transparency = new PaletteFactory().getTransparency(src);
 
         boolean isGrayscale = new PaletteFactory().isGrayscale(src);
-        if (verbose)
+        if (verbose) {
             Debug.debug("isGrayscale", isGrayscale);
+        }
 
         byte colorType;
         {
@@ -403,32 +421,37 @@ public class PngWriter implements PngCon
             boolean forceTrueColor = ParamMap.getParamBoolean(params,
                     PARAM_KEY_PNG_FORCE_TRUE_COLOR, false);
 
-            if (forceIndexedColor && forceTrueColor)
+            if (forceIndexedColor && forceTrueColor) {
                 throw new ImageWriteException(
                         "Params: Cannot force both indexed and true color modes");
-            else if (forceIndexedColor) {
+            } else if (forceIndexedColor) {
                 colorType = COLOR_TYPE_INDEXED_COLOR;
             } else if (forceTrueColor) {
                 colorType = (byte) (hasAlpha ? COLOR_TYPE_TRUE_COLOR_WITH_ALPHA
                         : COLOR_TYPE_TRUE_COLOR);
                 isGrayscale = false;
-            } else
+            } else {
                 colorType = getColourType(hasAlpha, isGrayscale);
-            if (verbose)
+            }
+            if (verbose) {
                 Debug.debug("colorType", colorType);
+            }
         }
 
         byte bitDepth = getBitDepth(colorType, params);
-        if (verbose)
+        if (verbose) {
             Debug.debug("bit_depth", bitDepth);
+        }
 
         int sampleDepth;
-        if (colorType == COLOR_TYPE_INDEXED_COLOR)
+        if (colorType == COLOR_TYPE_INDEXED_COLOR) {
             sampleDepth = 8;
-        else
+        } else {
             sampleDepth = bitDepth;
-        if (verbose)
+        }
+        if (verbose) {
             Debug.debug("sample_depth", sampleDepth);
+        }
 
         {
             PNG_Signature.writeTo(os);
@@ -495,15 +518,16 @@ public class PngWriter implements PngCon
                     .get(PARAM_KEY_PNG_TEXT_CHUNKS);
             for (int i = 0; i < outputTexts.size(); i++) {
                 PngText text = outputTexts.get(i);
-                if (text instanceof PngText.Text)
+                if (text instanceof PngText.Text) {
                     writeChunktEXt(os, (PngText.Text) text);
-                else if (text instanceof PngText.Ztxt)
+                } else if (text instanceof PngText.Ztxt) {
                     writeChunkzTXt(os, (PngText.Ztxt) text);
-                else if (text instanceof PngText.Itxt)
+                } else if (text instanceof PngText.Itxt) {
                     writeChunkiTXt(os, (PngText.Itxt) text);
-                else
+                } else {
                     throw new ImageWriteException(
                             "Unknown text to embed in PNG: " + text);
+                }
             }
         }
 
@@ -558,8 +582,9 @@ public class PngWriter implements PngCon
                                 baos.write(green);
                                 baos.write(blue);
                             }
-                            if (useAlpha)
+                            if (useAlpha) {
                                 baos.write(alpha);
+                            }
                         }
                     }
                 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java Thu Sep 27 18:22:37 2012
@@ -65,8 +65,9 @@ public abstract class ScanExpediter exte
 
     protected int getBitsToBytesRoundingUp(int bits) {
         int bytes = bits / 8;
-        if ((bits % 8 > 0))
+        if ((bits % 8 > 0)) {
             bytes++;
+        }
         return bytes;
     }
 
@@ -87,8 +88,8 @@ public abstract class ScanExpediter exte
             throws ImageReadException, IOException {
 
         switch (colorType) {
-        case 0: // 1,2,4,8,16 Each pixel is a grayscale sample.
-        {
+        case 0: {
+            // 1,2,4,8,16 Each pixel is a grayscale sample.
             int sample = bitParser.getSampleAsByte(pixelIndexInScanline, 0);
 
             if (gammaCorrection != null) {
@@ -97,22 +98,24 @@ public abstract class ScanExpediter exte
 
             int rgb = getPixelRGB(sample, sample, sample);
 
-            if (transparencyFilter != null)
+            if (transparencyFilter != null) {
                 rgb = transparencyFilter.filter(rgb, sample);
+            }
 
             return rgb;
 
         }
-        case 2: // 8,16 Each pixel is an R,G,B triple.
-        {
+        case 2: {
+            // 8,16 Each pixel is an R,G,B triple.
             int red = bitParser.getSampleAsByte(pixelIndexInScanline, 0);
             int green = bitParser.getSampleAsByte(pixelIndexInScanline, 1);
             int blue = bitParser.getSampleAsByte(pixelIndexInScanline, 2);
 
             int rgb = getPixelRGB(red, green, blue);
 
-            if (transparencyFilter != null)
+            if (transparencyFilter != null) {
                 rgb = transparencyFilter.filter(rgb, -1);
+            }
 
             if (gammaCorrection != null) {
                 int alpha = (0xff000000 & rgb) >> 24; // make sure to preserve
@@ -126,33 +129,35 @@ public abstract class ScanExpediter exte
             return rgb;
         }
         //
-        case 3: // 1,2,4,8 Each pixel is a palette index;
+        case 3: {
+            // 1,2,4,8 Each pixel is a palette index;
             // a PLTE chunk must appear.
-        {
             int index = bitParser.getSample(pixelIndexInScanline, 0);
 
             int rgb = pngChunkPLTE.getRGB(index);
 
-            if (transparencyFilter != null)
+            if (transparencyFilter != null) {
                 rgb = transparencyFilter.filter(rgb, index);
+            }
 
             return rgb;
         }
-        case 4: // 8,16 Each pixel is a grayscale sample,
+        case 4: {
+            // 8,16 Each pixel is a grayscale sample,
             // followed by an alpha sample.
-        {
             int sample = bitParser.getSampleAsByte(pixelIndexInScanline, 0);
             int alpha = bitParser.getSampleAsByte(pixelIndexInScanline, 1);
 
-            if (gammaCorrection != null)
+            if (gammaCorrection != null) {
                 sample = gammaCorrection.correctSample(sample);
+            }
 
             int rgb = getPixelARGB(alpha, sample, sample, sample);
             return rgb;
 
         }
-        case 6: // 8,16 Each pixel is an R,G,B triple,
-        {
+        case 6: {
+            // 8,16 Each pixel is an R,G,B triple,
             int red = bitParser.getSampleAsByte(pixelIndexInScanline, 0);
             int green = bitParser.getSampleAsByte(pixelIndexInScanline, 1);
             int blue = bitParser.getSampleAsByte(pixelIndexInScanline, 2);
@@ -219,8 +224,9 @@ public abstract class ScanExpediter exte
     protected byte[] getNextScanline(InputStream is, int length, byte prev[],
             int BytesPerPixel) throws ImageReadException, IOException {
         int filterType = is.read();
-        if (filterType < 0)
+        if (filterType < 0) {
             throw new ImageReadException("PNG: missing filter type");
+        }
 
         byte scanline[] = this.readByteArray("scanline", length, is,
                 "PNG: missing image data");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java Thu Sep 27 18:22:37 2012
@@ -35,39 +35,37 @@ public class PngChunkIccp extends PngChu
         super(Length, ChunkType, CRC, bytes);
         // this.parser = parser;
 
-        {
-            int index = findNull(bytes);
-            if (index < 0)
-                throw new ImageReadException("PngChunkIccp: No Profile Name");
-            byte name_bytes[] = new byte[index];
-            System.arraycopy(bytes, 0, name_bytes, 0, index);
-            ProfileName = new String(name_bytes, "ISO-8859-1");
-
-            CompressionMethod = bytes[index + 1];
-
-            int CompressedProfileLength = bytes.length - (index + 1 + 1);
-            CompressedProfile = new byte[CompressedProfileLength];
-            System.arraycopy(bytes, index + 1 + 1, CompressedProfile, 0,
-                    CompressedProfileLength);
-
-            if (getDebug()) {
-                System.out.println("ProfileName: " + ProfileName);
-                System.out.println("ProfileName.length(): "
-                        + ProfileName.length());
-                System.out.println("CompressionMethod: " + CompressionMethod);
-                System.out.println("CompressedProfileLength: "
-                        + CompressedProfileLength);
-                System.out.println("bytes.length: " + bytes.length);
-            }
-
-            UncompressedProfile = new ZLibUtils().inflate(CompressedProfile);
-
-            if (getDebug()) {
-                System.out.println("UncompressedProfile: "
-                        + ((UncompressedProfile == null) ? "null" : ""
-                                + bytes.length));
-            }
+        int index = findNull(bytes);
+        if (index < 0) {
+            throw new ImageReadException("PngChunkIccp: No Profile Name");
+        }
+        byte name_bytes[] = new byte[index];
+        System.arraycopy(bytes, 0, name_bytes, 0, index);
+        ProfileName = new String(name_bytes, "ISO-8859-1");
+
+        CompressionMethod = bytes[index + 1];
+
+        int CompressedProfileLength = bytes.length - (index + 1 + 1);
+        CompressedProfile = new byte[CompressedProfileLength];
+        System.arraycopy(bytes, index + 1 + 1, CompressedProfile, 0,
+                CompressedProfileLength);
+
+        if (getDebug()) {
+            System.out.println("ProfileName: " + ProfileName);
+            System.out.println("ProfileName.length(): "
+                    + ProfileName.length());
+            System.out.println("CompressionMethod: " + CompressionMethod);
+            System.out.println("CompressedProfileLength: "
+                    + CompressedProfileLength);
+            System.out.println("bytes.length: " + bytes.length);
+        }
+
+        UncompressedProfile = new ZLibUtils().inflate(CompressedProfile);
 
+        if (getDebug()) {
+            System.out.println("UncompressedProfile: "
+                    + ((UncompressedProfile == null) ? "null" : ""
+                            + bytes.length));
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkItxt.java Thu Sep 27 18:22:37 2012
@@ -42,64 +42,69 @@ public class PngChunkItxt extends PngTex
     public PngChunkItxt(int length, int chunkType, int crc, byte bytes[])
             throws ImageReadException, IOException {
         super(length, chunkType, crc, bytes);
-        {
-            int terminator = findNull(bytes);
-            if (terminator < 0)
-                throw new ImageReadException(
-                        "PNG iTXt chunk keyword is not terminated.");
-
-            keyword = new String(bytes, 0, terminator, "ISO-8859-1");
-            int index = terminator + 1;
+        int terminator = findNull(bytes);
+        if (terminator < 0) {
+            throw new ImageReadException(
+                    "PNG iTXt chunk keyword is not terminated.");
+        }
 
-            int compressionFlag = bytes[index++];
-            if (compressionFlag != 0 && compressionFlag != 1)
-                throw new ImageReadException(
-                        "PNG iTXt chunk has invalid compression flag: "
-                                + compressionFlag);
+        keyword = new String(bytes, 0, terminator, "ISO-8859-1");
+        int index = terminator + 1;
 
-            boolean compressed = compressionFlag == 1;
+        int compressionFlag = bytes[index++];
+        if (compressionFlag != 0 && compressionFlag != 1) {
+            throw new ImageReadException(
+                    "PNG iTXt chunk has invalid compression flag: "
+                            + compressionFlag);
+        }
 
-            int compressionMethod = bytes[index++];
-            if (compressed)
-                if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE)
-                    throw new ImageReadException(
-                            "PNG iTXt chunk has unexpected compression method: "
-                                    + compressionMethod);
-                else if (compressionMethod != 0)
-                    throw new ImageReadException(
-                            "PNG iTXt chunk has unexpected compression method: "
-                                    + compressionMethod);
+        boolean compressed = compressionFlag == 1;
 
-            terminator = findNull(bytes, index);
-            if (terminator < 0)
+        int compressionMethod = bytes[index++];
+        if (compressed) {
+            if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE) {
                 throw new ImageReadException(
-                        "PNG iTXt chunk language tag is not terminated.");
-
-            languageTag = new String(bytes, index, terminator - index,
-                    "ISO-8859-1");
-            index = terminator + 1;
-
-            terminator = findNull(bytes, index);
-            if (terminator < 0)
+                        "PNG iTXt chunk has unexpected compression method: "
+                                + compressionMethod);
+            } else if (compressionMethod != 0) {
                 throw new ImageReadException(
-                        "PNG iTXt chunk translated keyword is not terminated.");
+                        "PNG iTXt chunk has unexpected compression method: "
+                                + compressionMethod);
+            }
+        }
 
-            translatedKeyword = new String(bytes, index, terminator - index,
-                    "utf-8");
-            index = terminator + 1;
+        terminator = findNull(bytes, index);
+        if (terminator < 0) {
+            throw new ImageReadException(
+                    "PNG iTXt chunk language tag is not terminated.");
+        }
 
-            if (compressed) {
-                int compressedTextLength = bytes.length - index;
+        languageTag = new String(bytes, index, terminator - index,
+                "ISO-8859-1");
+        index = terminator + 1;
+
+        terminator = findNull(bytes, index);
+        if (terminator < 0) {
+            throw new ImageReadException(
+                    "PNG iTXt chunk translated keyword is not terminated.");
+        }
 
-                byte compressedText[] = new byte[compressedTextLength];
-                System.arraycopy(bytes, index, compressedText, 0,
-                        compressedTextLength);
+        translatedKeyword = new String(bytes, index, terminator - index,
+                "utf-8");
+        index = terminator + 1;
+
+        if (compressed) {
+            int compressedTextLength = bytes.length - index;
+
+            byte compressedText[] = new byte[compressedTextLength];
+            System.arraycopy(bytes, index, compressedText, 0,
+                    compressedTextLength);
 
-                text = new String(new ZLibUtils().inflate(compressedText),
-                        "utf-8");
+            text = new String(new ZLibUtils().inflate(compressedText),
+                    "utf-8");
 
-            } else
-                text = new String(bytes, index, bytes.length - index, "utf-8");
+        } else {
+            text = new String(bytes, index, bytes.length - index, "utf-8");
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java Thu Sep 27 18:22:37 2012
@@ -31,8 +31,9 @@ public class PngChunkPlte extends PngChu
 
         ByteArrayInputStream is = new ByteArrayInputStream(bytes);
 
-        if ((length % 3) != 0)
+        if ((length % 3) != 0) {
             throw new ImageReadException("PLTE: wrong length: " + length);
+        }
 
         int count = length / 3;
 
@@ -51,9 +52,10 @@ public class PngChunkPlte extends PngChu
     }
 
     public int getRGB(int index) throws ImageReadException {
-        if ((index < 0) || (index >= rgb.length))
+        if ((index < 0) || (index >= rgb.length)) {
             throw new ImageReadException("PNG: unknown Palette reference: "
                     + index);
+        }
         return rgb[index];
     }
 
@@ -69,8 +71,9 @@ public class PngChunkPlte extends PngChu
     // }
 
     public void correct(GammaCorrection gammaCorrection) {
-        for (int i = 0; i < rgb.length; i++)
+        for (int i = 0; i < rgb.length; i++) {
             rgb[i] = gammaCorrection.correctARGB(rgb[i]);
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java Thu Sep 27 18:22:37 2012
@@ -27,22 +27,20 @@ public class PngChunkText extends PngTex
     public PngChunkText(int length, int chunkType, int crc, byte bytes[])
             throws ImageReadException, IOException {
         super(length, chunkType, crc, bytes);
-        {
-            int index = findNull(bytes);
-            if (index < 0)
-                throw new ImageReadException(
-                        "PNG tEXt chunk keyword is not terminated.");
-
-            keyword = new String(bytes, 0, index, "ISO-8859-1");
-
-            int textLength = bytes.length - (index + 1);
-            text = new String(bytes, index + 1, textLength, "ISO-8859-1");
-
-            if (getDebug()) {
-                System.out.println("Keyword: " + keyword);
-                System.out.println("Text: " + text);
-            }
+        int index = findNull(bytes);
+        if (index < 0) {
+            throw new ImageReadException(
+                    "PNG tEXt chunk keyword is not terminated.");
+        }
+
+        keyword = new String(bytes, 0, index, "ISO-8859-1");
+
+        int textLength = bytes.length - (index + 1);
+        text = new String(bytes, index + 1, textLength, "ISO-8859-1");
 
+        if (getDebug()) {
+            System.out.println("Keyword: " + keyword);
+            System.out.println("Text: " + text);
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkZtxt.java Thu Sep 27 18:22:37 2012
@@ -31,29 +31,29 @@ public class PngChunkZtxt extends PngTex
             throws ImageReadException, IOException {
         super(length, chunkType, crc, bytes);
 
-        {
-            int index = findNull(bytes);
-            if (index < 0)
-                throw new ImageReadException(
-                        "PNG zTXt chunk keyword is unterminated.");
-
-            keyword = new String(bytes, 0, index, "ISO-8859-1");
-            index++;
-
-            int compressionMethod = bytes[index++];
-            if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE)
-                throw new ImageReadException(
-                        "PNG zTXt chunk has unexpected compression method: "
-                                + compressionMethod);
-
-            int compressedTextLength = bytes.length - index;
-            byte compressedText[] = new byte[compressedTextLength];
-            System.arraycopy(bytes, index, compressedText, 0,
-                    compressedTextLength);
+        int index = findNull(bytes);
+        if (index < 0) {
+            throw new ImageReadException(
+                    "PNG zTXt chunk keyword is unterminated.");
+        }
+
+        keyword = new String(bytes, 0, index, "ISO-8859-1");
+        index++;
 
-            text = new String(new ZLibUtils().inflate(compressedText),
-                    "ISO-8859-1");
+        int compressionMethod = bytes[index++];
+        if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE) {
+            throw new ImageReadException(
+                    "PNG zTXt chunk has unexpected compression method: "
+                            + compressionMethod);
         }
+
+        int compressedTextLength = bytes.length - index;
+        byte compressedText[] = new byte[compressedTextLength];
+        System.arraycopy(bytes, index, compressedText, 0,
+                compressedTextLength);
+
+        text = new String(new ZLibUtils().inflate(compressedText),
+                "ISO-8859-1");
     }
 
     /**

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java Thu Sep 27 18:22:37 2012
@@ -33,12 +33,14 @@ public class ScanlineFilterAverage exten
         for (int i = 0; i < src.length; i++) {
             int Raw = 0;
             int prev_index = i - BytesPerPixel;
-            if (prev_index >= 0)
+            if (prev_index >= 0) {
                 Raw = dst[prev_index];
+            }
 
             int Prior = 0;
-            if (up != null)
+            if (up != null) {
                 Prior = up[i];
+            }
 
             int Average = ((0xff & Raw) + (0xff & Prior)) / 2;
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java Thu Sep 27 18:22:37 2012
@@ -35,12 +35,13 @@ public class ScanlineFilterPaeth extends
         int pc = Math.abs(p - c);
         // ; return nearest of a,b,c,
         // ; breaking ties in order a,b,c.
-        if ((pa <= pb) && (pa <= pc))
+        if ((pa <= pb) && (pa <= pc)) {
             return a;
-        else if (pb <= pc)
+        } else if (pb <= pc) {
             return b;
-        else
+        } else {
             return c;
+        }
     }
 
     @Override
@@ -49,17 +50,20 @@ public class ScanlineFilterPaeth extends
         for (int i = 0; i < src.length; i++) {
             int left = 0;
             int prev_index = i - BytesPerPixel;
-            if (prev_index >= 0)
+            if (prev_index >= 0) {
                 left = dst[prev_index];
+            }
 
             int above = 0;
-            if (up != null)
+            if (up != null) {
                 above = up[i];
+            }
             // above = 255;
 
             int upperleft = 0;
-            if ((prev_index >= 0) && (up != null))
+            if ((prev_index >= 0) && (up != null)) {
                 upperleft = up[prev_index];
+            }
             // upperleft = 255;
 
             int PaethPredictor = PaethPredictor(0xff & left, 0xff & above,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java Thu Sep 27 18:22:37 2012
@@ -32,11 +32,12 @@ public class ScanlineFilterSub extends S
             throws ImageReadException, IOException {
         for (int i = 0; i < src.length; i++) {
             int prev_index = i - BytesPerPixel;
-            if (prev_index >= 0)
+            if (prev_index >= 0) {
                 dst[i] = (byte) ((src[i] + dst[prev_index]) % 256);
             // dst[i] = 0xff & (src[i] + src[prev_index]);
-            else
+            } else {
                 dst[i] = src[i];
+            }
 
             // if(i<10)
             // System.out.println("\t" + i + ": " + dst[i] + " (" + src[i] +



Mime
View raw message