commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1342971 [2/20] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/formats/bmp/ main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/ main/java/org/apache/commons/imaging/formats/bmp/writers/ main/java/org...
Date Sat, 26 May 2012 21:19:22 GMT
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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -40,99 +40,78 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.formats.pcx.PcxConstants;
 import org.apache.commons.imaging.formats.pcx.PcxImageParser;
 
-public class DcxImageParser extends ImageParser
-{
+public class DcxImageParser extends ImageParser {
     // See http://www.fileformat.info/format/pcx/egff.htm for documentation
 
-    public DcxImageParser()
-    {
+    public DcxImageParser() {
         super.setByteOrder(BYTE_ORDER_LSB);
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "Dcx-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
+
     private static final String DEFAULT_EXTENSION = ".dcx";
-    private static final String ACCEPTED_EXTENSIONS[] =
-    {
-        ".dcx",
-    };
+    private static final String ACCEPTED_EXTENSIONS[] = { ".dcx", };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
-        return new ImageFormat[]
-        {
-            ImageFormat.IMAGE_FORMAT_DCX, //
+    protected ImageFormat[] getAcceptedTypes() {
+        return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_DCX, //
         };
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[])
-    {
+    public boolean embedICCProfile(File src, File dst, byte profile[]) {
         return false;
     }
 
     @Override
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public Dimension getImageSize(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         return null;
     }
 
-    private static class DcxHeader
-    {
+    private static class DcxHeader {
 
         public static final int DCX_ID = 0x3ADE68B1;
         public final int id;
         public final int[] pageTable;
 
-        public DcxHeader(final int id,
-                int[] pageTable)
-        {
+        public DcxHeader(final int id, int[] pageTable) {
             this.id = id;
             this.pageTable = pageTable;
         }
 
-        public void dump(PrintWriter pw)
-        {
+        public void dump(PrintWriter pw) {
             pw.println("DcxHeader");
             pw.println("Id: 0x" + Integer.toHexString(id));
             pw.println("Pages: " + pageTable.length);
@@ -141,61 +120,53 @@ public class DcxImageParser extends Imag
     }
 
     private DcxHeader readDcxHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             int id = read4Bytes("Id", is, "Not a Valid DCX File");
             List<Integer> pageTable = new ArrayList<Integer>(1024);
-            for (int i = 0; i < 1024; i++)
-            {
-                int pageOffset = read4Bytes("PageTable", is, "Not a Valid DCX File");
+            for (int i = 0; i < 1024; i++) {
+                int pageOffset = read4Bytes("PageTable", is,
+                        "Not a Valid DCX File");
                 if (pageOffset == 0)
                     break;
                 pageTable.add(pageOffset);
             }
 
             if (id != DcxHeader.DCX_ID)
-                throw new ImageReadException("Not a Valid DCX File: file id incorrect");
+                throw new ImageReadException(
+                        "Not a Valid DCX File: file id incorrect");
             if (pageTable.size() == 1024)
-                throw new ImageReadException("DCX page table not terminated by zero entry");
-            
+                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++)
                 pages[i] = ((Integer) objects[i]).intValue();
 
             return new DcxHeader(id, pages);
-        }
-        finally
-        {
-            try
-            {
-                if (is != null)
-                {
+        } finally {
+            try {
+                if (is != null) {
                     is.close();
                 }
-            }
-            catch (IOException ignored)
-            {
+            } catch (IOException ignored) {
             }
         }
     }
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         readDcxHeader(byteSource).dump(pw);
         return true;
     }
 
     @Override
     public final BufferedImage getBufferedImage(ByteSource byteSource,
-            Map params) throws ImageReadException, IOException
-    {
+            Map params) throws ImageReadException, IOException {
         List<BufferedImage> list = getAllBufferedImages(byteSource);
         if (list.isEmpty())
             return null;
@@ -204,30 +175,24 @@ public class DcxImageParser extends Imag
 
     @Override
     public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         DcxHeader dcxHeader = readDcxHeader(byteSource);
         List<BufferedImage> images = new ArrayList<BufferedImage>();
         PcxImageParser pcxImageParser = new PcxImageParser();
-        for (int i = 0; i < dcxHeader.pageTable.length; i++)
-        {
+        for (int i = 0; i < dcxHeader.pageTable.length; i++) {
             InputStream stream = null;
-            try
-            {
+            try {
                 stream = byteSource.getInputStream(dcxHeader.pageTable[i]);
-                ByteSourceInputStream pcxSource = new ByteSourceInputStream(stream, null);
-                BufferedImage image = pcxImageParser.getBufferedImage(pcxSource, new HashMap());
+                ByteSourceInputStream pcxSource = new ByteSourceInputStream(
+                        stream, null);
+                BufferedImage image = pcxImageParser.getBufferedImage(
+                        pcxSource, new HashMap());
                 images.add(image);
-            }
-            finally
-            {
-                try
-                {
+            } finally {
+                try {
                     if (stream != null)
                         stream.close();
-                }
-                catch (IOException ignored)
-                {
+                } catch (IOException ignored) {
                 }
             }
         }
@@ -236,34 +201,32 @@ public class DcxImageParser extends Imag
 
     @Override
     public void writeImage(BufferedImage src, OutputStream os, Map params)
-            throws ImageWriteException, IOException
-    {
+            throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
         HashMap pcxParams = new HashMap();
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
-        {
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
         }
 
-        if (params.containsKey(PcxConstants.PARAM_KEY_PCX_COMPRESSION))
-        {
-            Object value = params.remove(PcxConstants.PARAM_KEY_PCX_COMPRESSION);
+        if (params.containsKey(PcxConstants.PARAM_KEY_PCX_COMPRESSION)) {
+            Object value = params
+                    .remove(PcxConstants.PARAM_KEY_PCX_COMPRESSION);
             pcxParams.put(PcxConstants.PARAM_KEY_PCX_COMPRESSION, value);
         }
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
 
         final int headerSize = 4 + 1024 * 4;
 
-        BinaryOutputStream bos = new BinaryOutputStream(os, BinaryOutputStream.BYTE_ORDER_LITTLE_ENDIAN);
+        BinaryOutputStream bos = new BinaryOutputStream(os,
+                BinaryOutputStream.BYTE_ORDER_LITTLE_ENDIAN);
         bos.write4Bytes(DcxHeader.DCX_ID);
         // Some apps may need a full 1024 entry table
         bos.write4Bytes(headerSize);
@@ -276,17 +239,16 @@ public class DcxImageParser extends Imag
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>
-     *
+     * 
      * @param byteSource
      *            File containing image data.
      * @param params
      *            Map of optional parameters, defined in SanselanConstants.
-     * @return Xmp Xml as String, if present.  Otherwise, returns null.
+     * @return Xmp Xml as String, if present. Otherwise, returns null.
      */
     @Override
     public String getXmpXml(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 }

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -20,31 +20,26 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.List;
 
-class GenericGifBlock extends GifBlock
-{
+class GenericGifBlock extends GifBlock {
     public final List<byte[]> subblocks;
 
-    public GenericGifBlock(int blockCode, List<byte[]> subblocks)
-    {
+    public GenericGifBlock(int blockCode, List<byte[]> subblocks) {
         super(blockCode);
 
         this.subblocks = subblocks;
 
     }
 
-    public byte[] appendSubBlocks() throws IOException
-    {
+    public byte[] appendSubBlocks() throws IOException {
         return appendSubBlocks(false);
     }
 
-    public byte[] appendSubBlocks(boolean includeLengths) throws IOException
-    {
+    public byte[] appendSubBlocks(boolean includeLengths) throws IOException {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        for (int i = 0; i < subblocks.size(); i++)
-        {
+        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);
         }
@@ -52,4 +47,4 @@ class GenericGifBlock extends GifBlock
         return out.toByteArray();
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifBlock.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifBlock.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifBlock.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifBlock.java Sat May 26 21:19:03 2012
@@ -16,12 +16,10 @@
  */
 package org.apache.commons.imaging.formats.gif;
 
-class GifBlock
-{
+class GifBlock {
     public final int blockCode;
 
-    public GifBlock(int blockCode)
-    {
+    public GifBlock(int blockCode) {
         this.blockCode = blockCode;
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java Sat May 26 21:19:03 2012
@@ -16,8 +16,7 @@
  */
 package org.apache.commons.imaging.formats.gif;
 
-class GifHeaderInfo
-{
+class GifHeaderInfo {
     public final byte identifier1;
     public final byte identifier2;
     public final byte identifier3;
@@ -40,8 +39,7 @@ class GifHeaderInfo
             int LogicalScreenWidth, int LogicalScreenHeight, byte PackedFields,
             byte BackgroundColorIndex, byte PixelAspectRatio,
             boolean GlobalColorTableFlag, byte ColorResolution,
-            boolean SortFlag, byte SizeofGlobalColorTable)
-    {
+            boolean SortFlag, byte SizeofGlobalColorTable) {
         this.identifier1 = Identifier1;
         this.identifier2 = Identifier2;
         this.identifier3 = Identifier3;
@@ -58,4 +56,4 @@ class GifHeaderInfo
         this.sortFlag = SortFlag;
         this.sizeOfGlobalColorTable = SizeofGlobalColorTable;
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -47,23 +47,19 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.ParamMap;
 
-public class GifImageParser extends ImageParser
-{
+public class GifImageParser extends ImageParser {
 
-    public GifImageParser()
-    {
+    public GifImageParser() {
         super.setByteOrder(BYTE_ORDER_LSB);
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "Gif-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
 
@@ -72,14 +68,12 @@ public class GifImageParser extends Imag
     private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
+    protected ImageFormat[] getAcceptedTypes() {
         return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_GIF, //
         };
     }
@@ -88,8 +82,7 @@ public class GifImageParser extends Imag
 
     private GifHeaderInfo readHeader(InputStream is,
             FormatCompliance formatCompliance) throws ImageReadException,
-            IOException
-    {
+            IOException {
         byte identifier1 = readByte("identifier1", is, "Not a Valid GIF File");
         byte identifier2 = readByte("identifier2", is, "Not a Valid GIF File");
         byte identifier3 = readByte("identifier3", is, "Not a Valid GIF File");
@@ -98,8 +91,7 @@ public class GifImageParser extends Imag
         byte version2 = readByte("version2", is, "Not a Valid GIF File");
         byte version3 = readByte("version3", is, "Not a Valid GIF File");
 
-        if (formatCompliance != null)
-        {
+        if (formatCompliance != null) {
             formatCompliance.compare_bytes("Signature", GIF_HEADER_SIGNATURE,
                     new byte[] { identifier1, identifier2, identifier3, });
             formatCompliance.compare("version", 56, version1);
@@ -120,8 +112,7 @@ public class GifImageParser extends Imag
         int logicalScreenHeight = read2Bytes("Logical Screen Height", is,
                 "Not a Valid GIF File");
 
-        if (formatCompliance != null)
-        {
+        if (formatCompliance != null) {
             formatCompliance.checkBounds("Width", 1, Integer.MAX_VALUE,
                     logicalScreenWidth);
             formatCompliance.checkBounds("Height", 1, Integer.MAX_VALUE,
@@ -152,8 +143,7 @@ public class GifImageParser extends Imag
             System.out.println("SizeofGlobalColorTable: "
                     + sizeofGlobalColorTable);
 
-        if (formatCompliance != null)
-        {
+        if (formatCompliance != null) {
             if (globalColorTableFlag && backgroundColorIndex != -1)
                 formatCompliance.checkBounds("Background Color Index", 0,
                         convertColorTableSize(sizeofGlobalColorTable),
@@ -168,8 +158,7 @@ public class GifImageParser extends Imag
     }
 
     private GraphicControlExtension readGraphicControlExtension(int code,
-            InputStream is) throws ImageReadException, IOException
-    {
+            InputStream is) throws ImageReadException, IOException {
         readByte("block_size", is, "GIF: corrupt GraphicControlExt");
         int packed = readByte("packed fields", is,
                 "GIF: corrupt GraphicControlExt");
@@ -187,8 +176,7 @@ public class GifImageParser extends Imag
                 delay, transparentColorIndex);
     }
 
-    private byte[] readSubBlock(InputStream is) throws IOException
-    {
+    private byte[] readSubBlock(InputStream is) throws IOException {
         int block_size = 0xff & readByte("block_size", is, "GIF: corrupt block");
 
         byte bytes[] = readByteArray("block", block_size, is,
@@ -198,21 +186,18 @@ public class GifImageParser extends Imag
     }
 
     protected GenericGifBlock readGenericGIFBlock(InputStream is, int code)
-            throws IOException
-    {
+            throws IOException {
         return readGenericGIFBlock(is, code, null);
     }
 
     protected GenericGifBlock readGenericGIFBlock(InputStream is, int code,
-            byte first[]) throws IOException
-    {
+            byte first[]) throws IOException {
         List<byte[]> subblocks = new ArrayList<byte[]>();
 
         if (first != null)
             subblocks.add(first);
 
-        while (true)
-        {
+        while (true) {
             byte bytes[] = readSubBlock(is);
             if (bytes.length < 1)
                 break;
@@ -234,17 +219,14 @@ public class GifImageParser extends Imag
             | XMP_EXTENSION;
 
     private List<GifBlock> readBlocks(GifHeaderInfo ghi, InputStream is,
-                                      boolean stopBeforeImageData, FormatCompliance formatCompliance)
-            throws ImageReadException, IOException
-    {
+            boolean stopBeforeImageData, FormatCompliance formatCompliance)
+            throws ImageReadException, IOException {
         List<GifBlock> result = new ArrayList<GifBlock>();
 
-        while (true)
-        {
+        while (true) {
             int code = is.read();
 
-            switch (code)
-            {
+            switch (code) {
             case -1:
                 throw new ImageReadException("GIF: unexpected end of data");
 
@@ -263,8 +245,7 @@ public class GifImageParser extends Imag
                 int completeCode = ((0xff & code) << 8)
                         | (0xff & extensionCode);
 
-                switch (extensionCode)
-                {
+                switch (extensionCode) {
                 case 0xf9:
                     GraphicControlExtension gce = readGraphicControlExtension(
                             completeCode, is);
@@ -285,17 +266,17 @@ public class GifImageParser extends Imag
                     byte label[] = readSubBlock(is);
 
                     if (formatCompliance != null)
-                        formatCompliance
-                                .addComment("Unknown Application Extension ("
-                                        + new String(label, "US-ASCII") + ")", completeCode);
+                        formatCompliance.addComment(
+                                "Unknown Application Extension ("
+                                        + new String(label, "US-ASCII") + ")",
+                                completeCode);
 
                     // if (label == new String("ICCRGBG1"))
                     {
                         // GIF's can have embedded ICC Profiles - who knew?
                     }
 
-                    if ((label != null) && (label.length > 0))
-                    {
+                    if ((label != null) && (label.length > 0)) {
                         GenericGifBlock block = readGenericGIFBlock(is,
                                 completeCode, label);
                         result.add(block);
@@ -333,8 +314,7 @@ public class GifImageParser extends Imag
     private ImageDescriptor readImageDescriptor(GifHeaderInfo ghi,
             int blockCode, InputStream is, boolean stopBeforeImageData,
             FormatCompliance formatCompliance) throws ImageReadException,
-            IOException
-    {
+            IOException {
         int ImageLeftPosition = read2Bytes("Image Left Position", is,
                 "Not a Valid GIF File");
         int ImageTopPosition = read2Bytes("Image Top Position", is,
@@ -344,8 +324,7 @@ public class GifImageParser extends Imag
         byte PackedFields = readByte("Packed Fields", is,
                 "Not a Valid GIF File");
 
-        if (formatCompliance != null)
-        {
+        if (formatCompliance != null) {
             formatCompliance.checkBounds("Width", 1, ghi.logicalScreenWidth,
                     imageWidth);
             formatCompliance.checkBounds("Height", 1, ghi.logicalScreenHeight,
@@ -380,8 +359,7 @@ public class GifImageParser extends Imag
                     formatCompliance);
 
         byte imageData[] = null;
-        if (!stopBeforeImageData)
-        {
+        if (!stopBeforeImageData) {
             int LZWMinimumCodeSize = is.read();
 
             GenericGifBlock block = readGenericGIFBlock(is, -1);
@@ -392,8 +370,7 @@ public class GifImageParser extends Imag
             MyLzwDecompressor myLzwDecompressor = new MyLzwDecompressor(
                     LZWMinimumCodeSize, BYTE_ORDER_LSB);
             imageData = myLzwDecompressor.decompress(bais, size);
-        } else
-        {
+        } else {
             int LZWMinimumCodeSize = is.read();
             if (debug)
                 System.out.println("LZWMinimumCodeSize: " + LZWMinimumCodeSize);
@@ -409,8 +386,7 @@ public class GifImageParser extends Imag
         return result;
     }
 
-    private int simple_pow(int base, int power)
-    {
+    private int simple_pow(int base, int power) {
         int result = 1;
 
         for (int i = 0; i < power; i++)
@@ -419,14 +395,12 @@ public class GifImageParser extends Imag
         return result;
     }
 
-    private int convertColorTableSize(int ct_size)
-    {
+    private int convertColorTableSize(int ct_size) {
         return 3 * simple_pow(2, ct_size + 1);
     }
 
     private byte[] readColorTable(InputStream is, int ct_size,
-            FormatCompliance formatCompliance) throws IOException
-    {
+            FormatCompliance formatCompliance) throws IOException {
         int actual_size = convertColorTableSize(ct_size);
 
         byte bytes[] = readByteArray("block", actual_size, is,
@@ -437,33 +411,26 @@ public class GifImageParser extends Imag
 
     // TODO - unused
     private GifHeaderInfo readHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
 
             return readHeader(is, FormatCompliance.getDefault());
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
 
         }
     }
 
-    private GifBlock findBlock(List<GifBlock> v, int code)
-    {
-        for (int i = 0; i < v.size(); i++)
-        {
+    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)
                 return gifBlock;
@@ -472,19 +439,16 @@ public class GifImageParser extends Imag
     }
 
     private ImageContents readFile(ByteSource byteSource,
-            boolean stopBeforeImageData) throws ImageReadException, IOException
-    {
-        return readFile(byteSource, stopBeforeImageData, FormatCompliance
-                .getDefault());
+            boolean stopBeforeImageData) throws ImageReadException, IOException {
+        return readFile(byteSource, stopBeforeImageData,
+                FormatCompliance.getDefault());
     }
 
     private ImageContents readFile(ByteSource byteSource,
             boolean stopBeforeImageData, FormatCompliance formatCompliance)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
 
             GifHeaderInfo ghi = readHeader(is, formatCompliance);
@@ -494,20 +458,19 @@ public class GifImageParser extends Imag
                 globalColorTable = readColorTable(is,
                         ghi.sizeOfGlobalColorTable, formatCompliance);
 
-            List<GifBlock> blocks = readBlocks(ghi, is, stopBeforeImageData, formatCompliance);
+            List<GifBlock> blocks = readBlocks(ghi, is, stopBeforeImageData,
+                    formatCompliance);
 
-            ImageContents result = new ImageContents(ghi, globalColorTable, blocks);
+            ImageContents result = new ImageContents(ghi, globalColorTable,
+                    blocks);
 
             return result;
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
 
@@ -516,15 +479,13 @@ public class GifImageParser extends Imag
 
     @Override
     public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
     public Dimension getImageSize(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         ImageContents blocks = readFile(byteSource, false);
 
         if (blocks == null)
@@ -534,43 +495,39 @@ public class GifImageParser extends Imag
         if (bhi == null)
             throw new ImageReadException("GIF: Couldn't read Header");
 
-        ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks, IMAGE_SEPARATOR);
+        ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks,
+                IMAGE_SEPARATOR);
         if (id == null)
             throw new ImageReadException("GIF: Couldn't read ImageDescriptor");
 
-        // Prefer the size information in the ImageDescriptor; it is more reliable
+        // Prefer the size information in the ImageDescriptor; it is more
+        // reliable
         // than the size information in the header.
         return new Dimension(id.imageWidth, id.imageHeight);
     }
 
-    public byte[] embedICCProfile(byte image[], byte profile[])
-    {
+    public byte[] embedICCProfile(byte image[], byte profile[]) {
         return null;
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[])
-    {
+    public boolean embedICCProfile(File src, File dst, byte profile[]) {
         return false;
     }
 
     @Override
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
-    private List<String> getComments(List<GifBlock> v) throws IOException
-    {
+    private List<String> getComments(List<GifBlock> v) throws IOException {
         List<String> result = new ArrayList<String>();
         int code = 0x21fe;
 
-        for (int i = 0; i < v.size(); i++)
-        {
+        for (int i = 0; i < v.size(); i++) {
             GifBlock block = v.get(i);
-            if (block.blockCode == code)
-            {
+            if (block.blockCode == code) {
                 byte bytes[] = ((GenericGifBlock) block).appendSubBlocks();
                 result.add(new String(bytes, "US-ASCII"));
             }
@@ -581,8 +538,7 @@ public class GifImageParser extends Imag
 
     @Override
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         ImageContents blocks = readFile(byteSource, false);
 
         if (blocks == null)
@@ -600,7 +556,8 @@ public class GifImageParser extends Imag
         GraphicControlExtension gce = (GraphicControlExtension) findBlock(
                 blocks.blocks, GRAPHIC_CONTROL_EXTENSION);
 
-        // Prefer the size information in the ImageDescriptor; it is more reliable
+        // Prefer the size information in the ImageDescriptor; it is more
+        // reliable
         // than the size information in the header.
         int height = id.imageWidth;
         int width = id.imageHeight;
@@ -646,8 +603,7 @@ public class GifImageParser extends Imag
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         pw.println("gif.dumpImageFile");
 
         {
@@ -664,8 +620,7 @@ public class GifImageParser extends Imag
                 return false;
 
             pw.println("gif.blocks: " + blocks.blocks.size());
-            for (int i = 0; i < blocks.blocks.size(); i++)
-            {
+            for (int i = 0; i < blocks.blocks.size(); i++) {
                 GifBlock gifBlock = blocks.blocks.get(i);
                 this.debugNumber(pw, "\t" + i + " ("
                         + gifBlock.getClass().getName() + ")",
@@ -679,8 +634,7 @@ public class GifImageParser extends Imag
         return true;
     }
 
-    private int[] getColorTable(byte bytes[]) throws ImageReadException
-    {
+    private int[] getColorTable(byte bytes[]) throws ImageReadException {
         if ((bytes.length % 3) != 0)
             throw new ImageReadException("Bad Color Table Length: "
                     + bytes.length);
@@ -688,8 +642,7 @@ public class GifImageParser extends Imag
 
         int result[] = new int[length];
 
-        for (int i = 0; i < length; i++)
-        {
+        for (int i = 0; i < length; i++) {
             int red = 0xff & bytes[(i * 3) + 0];
             int green = 0xff & bytes[(i * 3) + 1];
             int blue = 0xff & bytes[(i * 3) + 2];
@@ -705,10 +658,9 @@ public class GifImageParser extends Imag
 
     @Override
     public FormatCompliance getFormatCompliance(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
-        FormatCompliance result = new FormatCompliance(byteSource
-                .getDescription());
+            throws ImageReadException, IOException {
+        FormatCompliance result = new FormatCompliance(
+                byteSource.getDescription());
 
         readFile(byteSource, false, result);
 
@@ -717,8 +669,7 @@ public class GifImageParser extends Imag
 
     @Override
     public BufferedImage getBufferedImage(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         ImageContents imageContents = readFile(byteSource, false);
 
         if (imageContents == null)
@@ -735,7 +686,8 @@ public class GifImageParser extends Imag
         GraphicControlExtension gce = (GraphicControlExtension) findBlock(
                 imageContents.blocks, GRAPHIC_CONTROL_EXTENSION);
 
-        // Prefer the size information in the ImageDescriptor; it is more reliable
+        // Prefer the size information in the ImageDescriptor; it is more
+        // reliable
         // than the size information in the header.
         int width = id.imageWidth;
         int height = id.imageHeight;
@@ -766,26 +718,21 @@ public class GifImageParser extends Imag
             int rowsInPass3 = (height + 1) / 4;
             int rowsInPass4 = (height) / 2;
 
-            for (int row = 0; row < height; row++)
-            {
+            for (int row = 0; row < height; row++) {
                 int y;
-                if (id.interlaceFlag)
-                {
+                if (id.interlaceFlag) {
                     int the_row = row;
                     if (the_row < rowsInPass1)
                         y = the_row * 8;
-                    else
-                    {
+                    else {
                         the_row -= rowsInPass1;
                         if (the_row < (rowsInPass2))
                             y = 4 + (the_row * 8);
-                        else
-                        {
+                        else {
                             the_row -= rowsInPass2;
                             if (the_row < (rowsInPass3))
                                 y = 2 + (the_row * 4);
-                            else
-                            {
+                            else {
                                 the_row -= rowsInPass3;
                                 if (the_row < (rowsInPass4))
                                     y = 1 + (the_row * 2);
@@ -798,8 +745,7 @@ public class GifImageParser extends Imag
                 } else
                     y = row;
 
-                for (int x = 0; x < width; x++)
-                {
+                for (int x = 0; x < width; x++) {
                     int index = 0xff & id.imageData[counter++];
                     int rgb = colorTable[index];
 
@@ -817,12 +763,10 @@ public class GifImageParser extends Imag
     }
 
     private void writeAsSubBlocks(OutputStream os, byte bytes[])
-            throws IOException
-    {
+            throws IOException {
         int index = 0;
 
-        while (index < bytes.length)
-        {
+        while (index < bytes.length) {
             int block_size = Math.min(bytes.length - index, 255);
             os.write(block_size);
             os.write(bytes, index, block_size);
@@ -837,8 +781,7 @@ public class GifImageParser extends Imag
 
     @Override
     public void writeImage(BufferedImage src, OutputStream os, Map params)
-            throws ImageWriteException, IOException
-    {
+            throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = new HashMap(params);
 
@@ -852,14 +795,12 @@ public class GifImageParser extends Imag
             params.remove(PARAM_KEY_VERBOSE);
 
         String xmpXml = null;
-        if (params.containsKey(PARAM_KEY_XMP_XML))
-        {
+        if (params.containsKey(PARAM_KEY_XMP_XML)) {
             xmpXml = (String) params.get(PARAM_KEY_XMP_XML);
             params.remove(PARAM_KEY_XMP_XML);
         }
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
@@ -876,8 +817,7 @@ public class GifImageParser extends Imag
         // int palette[] = new PaletteFactory().makePaletteSimple(src, 256);
         // Map palette_map = paletteToMap(palette);
 
-        if (palette2 == null)
-        {
+        if (palette2 == null) {
             palette2 = new PaletteFactory().makePaletteQuantized(src,
                     max_colors);
             if (verbose)
@@ -960,8 +900,7 @@ public class GifImageParser extends Imag
                 bos.write((byte) 0); // terminator
             }
 
-            if (null != xmpXml)
-            {
+            if (null != xmpXml) {
                 bos.write(EXTENSION_CODE);
                 bos.write(APPLICATION_EXTENSION_LABEL);
 
@@ -1004,10 +943,8 @@ public class GifImageParser extends Imag
             }
 
             { // write Local Color Table.
-                for (int i = 0; i < colorTableSizeInFormat; i++)
-                {
-                    if (i < palette2.length())
-                    {
+                for (int i = 0; i < colorTableSizeInFormat; i++) {
+                    if (i < palette2.length()) {
                         int rgb = palette2.getEntry(i);
 
                         int red = 0xff & (rgb >> 16);
@@ -1017,8 +954,7 @@ public class GifImageParser extends Imag
                         bos.write(red);
                         bos.write(green);
                         bos.write(blue);
-                    } else
-                    {
+                    } else {
                         bos.write(0);
                         bos.write(0);
                         bos.write(0);
@@ -1030,7 +966,7 @@ public class GifImageParser extends Imag
                 int image_data_total = 0;
 
                 int LZWMinimumCodeSize = colorTableScaleLessOne + 1;
-//                LZWMinimumCodeSize = Math.max(8, LZWMinimumCodeSize);
+                // LZWMinimumCodeSize = Math.max(8, LZWMinimumCodeSize);
                 if (LZWMinimumCodeSize < 2)
                     LZWMinimumCodeSize = 2;
 
@@ -1046,24 +982,20 @@ public class GifImageParser extends Imag
                 // Mode);
 
                 byte imagedata[] = new byte[width * height];
-                for (int y = 0; y < height; y++)
-                {
-                    for (int x = 0; x < width; x++)
-                    {
+                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)
-                        {
+                        if (hasAlpha) {
                             int alpha = 0xff & (argb >> 24);
                             final int alphaThreshold = 255;
                             if (alpha < alphaThreshold)
                                 index = palette2.length(); // is transparent
                             else
                                 index = palette2.getPaletteIndex(rgb);
-                        } else
-                        {
+                        } else {
                             index = palette2.getPaletteIndex(rgb);
                         }
 
@@ -1101,7 +1033,7 @@ public class GifImageParser extends Imag
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>
-     *
+     * 
      * @param byteSource
      *            File containing image data.
      * @param params
@@ -1110,12 +1042,10 @@ public class GifImageParser extends Imag
      */
     @Override
     public String getXmpXml(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
 
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
 
             FormatCompliance formatCompliance = null;
@@ -1127,8 +1057,7 @@ public class GifImageParser extends Imag
             List<GifBlock> blocks = readBlocks(ghi, is, true, formatCompliance);
 
             List<String> result = new ArrayList<String>();
-            for (int i = 0; i < blocks.size(); i++)
-            {
+            for (int i = 0; i < blocks.size(); i++) {
                 GifBlock block = blocks.get(i);
                 if (block.blockCode != XMP_COMPLETE_CODE)
                     continue;
@@ -1157,8 +1086,7 @@ public class GifImageParser extends Imag
                     throw new ImageReadException(
                             "XMP block in GIF missing magic trailer.");
 
-                try
-                {
+                try {
                     // XMP is UTF-8 encoded xml.
                     String xml = new String(
                             blockBytes,
@@ -1167,8 +1095,7 @@ public class GifImageParser extends Imag
                                     - (XMP_APPLICATION_ID_AND_AUTH_CODE.length + GIF_MAGIC_TRAILER.length),
                             "utf-8");
                     result.add(xml);
-                } catch (UnsupportedEncodingException e)
-                {
+                } catch (UnsupportedEncodingException e) {
                     throw new ImageReadException("Invalid XMP Block in GIF.");
                 }
             }
@@ -1179,15 +1106,12 @@ public class GifImageParser extends Imag
                 throw new ImageReadException("More than one XMP Block in GIF.");
             return result.get(0);
 
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GraphicControlExtension.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GraphicControlExtension.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GraphicControlExtension.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GraphicControlExtension.java Sat May 26 21:19:03 2012
@@ -16,8 +16,7 @@
  */
 package org.apache.commons.imaging.formats.gif;
 
-class GraphicControlExtension extends GifBlock
-{
+class GraphicControlExtension extends GifBlock {
 
     public final int packed;
     public final int dispose;
@@ -26,8 +25,7 @@ class GraphicControlExtension extends Gi
     public final int transparentColorIndex;
 
     public GraphicControlExtension(int blockCode, int packed, int dispose,
-            boolean transparency, int delay, int transparentColorIndex)
-    {
+            boolean transparency, int delay, int transparentColorIndex) {
         super(blockCode);
 
         this.packed = packed;
@@ -38,4 +36,4 @@ class GraphicControlExtension extends Gi
 
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageContents.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageContents.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageContents.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageContents.java Sat May 26 21:19:03 2012
@@ -18,17 +18,16 @@ package org.apache.commons.imaging.forma
 
 import java.util.List;
 
-class ImageContents
-{
+class ImageContents {
     public final GifHeaderInfo gifHeaderInfo;
 
     public final List<GifBlock> blocks;
     public final byte globalColorTable[];
 
-    public ImageContents(GifHeaderInfo gifHeaderInfo, byte globalColorTable[], List<GifBlock> blocks)
-    {
+    public ImageContents(GifHeaderInfo gifHeaderInfo, byte globalColorTable[],
+            List<GifBlock> blocks) {
         this.gifHeaderInfo = gifHeaderInfo;
         this.globalColorTable = globalColorTable;
         this.blocks = blocks;
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageDescriptor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageDescriptor.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageDescriptor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/ImageDescriptor.java Sat May 26 21:19:03 2012
@@ -16,8 +16,7 @@
  */
 package org.apache.commons.imaging.formats.gif;
 
-public class ImageDescriptor extends GifBlock
-{
+public class ImageDescriptor extends GifBlock {
 
     public final int imageLeftPosition;
     public final int imageTopPosition;
@@ -37,8 +36,7 @@ public class ImageDescriptor extends Gif
             byte PackedFields, boolean LocalColorTableFlag,
             boolean InterlaceFlag, boolean SortFlag,
             byte SizeofLocalColorTable, byte LocalColorTable[],
-            byte ImageData[])
-    {
+            byte ImageData[]) {
         super(blockCode);
 
         this.imageLeftPosition = ImageLeftPosition;
@@ -54,4 +52,4 @@ public class ImageDescriptor extends Gif
         this.localColorTable = LocalColorTable;
         this.imageData = ImageData;
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -23,300 +23,73 @@ import java.util.List;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.ImageBuilder;
 
-public class IcnsDecoder
-{
-    private static final int[] palette_4bpp =
-    {
-        0xffffffff,
-        0xfffcf305,
-        0xffff6402,
-        0xffdd0806,
-        0xfff20884,
-        0xff4600a5,
-        0xff0000d4,
-        0xff02abea,
-        0xff1fb714,
-        0xff006411,
-        0xff562c05,
-        0xff90713a,
-        0xffc0c0c0,
-        0xff808080,
-        0xff404040,
-        0xff000000
-    };
-
-    private static final int[] palette_8bpp =
-    {
-        0xFFFFFFFF,
-        0xFFFFFFCC,
-        0xFFFFFF99,
-        0xFFFFFF66,
-        0xFFFFFF33,
-        0xFFFFFF00,
-        0xFFFFCCFF,
-        0xFFFFCCCC,
-        0xFFFFCC99,
-        0xFFFFCC66,
-        0xFFFFCC33,
-        0xFFFFCC00,
-        0xFFFF99FF,
-        0xFFFF99CC,
-        0xFFFF9999,
-        0xFFFF9966,
-        0xFFFF9933,
-        0xFFFF9900,
-        0xFFFF66FF,
-        0xFFFF66CC,
-        0xFFFF6699,
-        0xFFFF6666,
-        0xFFFF6633,
-        0xFFFF6600,
-        0xFFFF33FF,
-        0xFFFF33CC,
-        0xFFFF3399,
-        0xFFFF3366,
-        0xFFFF3333,
-        0xFFFF3300,
-        0xFFFF00FF,
-        0xFFFF00CC,
-        0xFFFF0099,
-        0xFFFF0066,
-        0xFFFF0033,
-        0xFFFF0000,
-        0xFFCCFFFF,
-        0xFFCCFFCC,
-        0xFFCCFF99,
-        0xFFCCFF66,
-        0xFFCCFF33,
-        0xFFCCFF00,
-        0xFFCCCCFF,
-        0xFFCCCCCC,
-        0xFFCCCC99,
-        0xFFCCCC66,
-        0xFFCCCC33,
-        0xFFCCCC00,
-        0xFFCC99FF,
-        0xFFCC99CC,
-        0xFFCC9999,
-        0xFFCC9966,
-        0xFFCC9933,
-        0xFFCC9900,
-        0xFFCC66FF,
-        0xFFCC66CC,
-        0xFFCC6699,
-        0xFFCC6666,
-        0xFFCC6633,
-        0xFFCC6600,
-        0xFFCC33FF,
-        0xFFCC33CC,
-        0xFFCC3399,
-        0xFFCC3366,
-        0xFFCC3333,
-        0xFFCC3300,
-        0xFFCC00FF,
-        0xFFCC00CC,
-        0xFFCC0099,
-        0xFFCC0066,
-        0xFFCC0033,
-        0xFFCC0000,
-        0xFF99FFFF,
-        0xFF99FFCC,
-        0xFF99FF99,
-        0xFF99FF66,
-        0xFF99FF33,
-        0xFF99FF00,
-        0xFF99CCFF,
-        0xFF99CCCC,
-        0xFF99CC99,
-        0xFF99CC66,
-        0xFF99CC33,
-        0xFF99CC00,
-        0xFF9999FF,
-        0xFF9999CC,
-        0xFF999999,
-        0xFF999966,
-        0xFF999933,
-        0xFF999900,
-        0xFF9966FF,
-        0xFF9966CC,
-        0xFF996699,
-        0xFF996666,
-        0xFF996633,
-        0xFF996600,
-        0xFF9933FF,
-        0xFF9933CC,
-        0xFF993399,
-        0xFF993366,
-        0xFF993333,
-        0xFF993300,
-        0xFF9900FF,
-        0xFF9900CC,
-        0xFF990099,
-        0xFF990066,
-        0xFF990033,
-        0xFF990000,
-        0xFF66FFFF,
-        0xFF66FFCC,
-        0xFF66FF99,
-        0xFF66FF66,
-        0xFF66FF33,
-        0xFF66FF00,
-        0xFF66CCFF,
-        0xFF66CCCC,
-        0xFF66CC99,
-        0xFF66CC66,
-        0xFF66CC33,
-        0xFF66CC00,
-        0xFF6699FF,
-        0xFF6699CC,
-        0xFF669999,
-        0xFF669966,
-        0xFF669933,
-        0xFF669900,
-        0xFF6666FF,
-        0xFF6666CC,
-        0xFF666699,
-        0xFF666666,
-        0xFF666633,
-        0xFF666600,
-        0xFF6633FF,
-        0xFF6633CC,
-        0xFF663399,
-        0xFF663366,
-        0xFF663333,
-        0xFF663300,
-        0xFF6600FF,
-        0xFF6600CC,
-        0xFF660099,
-        0xFF660066,
-        0xFF660033,
-        0xFF660000,
-        0xFF33FFFF,
-        0xFF33FFCC,
-        0xFF33FF99,
-        0xFF33FF66,
-        0xFF33FF33,
-        0xFF33FF00,
-        0xFF33CCFF,
-        0xFF33CCCC,
-        0xFF33CC99,
-        0xFF33CC66,
-        0xFF33CC33,
-        0xFF33CC00,
-        0xFF3399FF,
-        0xFF3399CC,
-        0xFF339999,
-        0xFF339966,
-        0xFF339933,
-        0xFF339900,
-        0xFF3366FF,
-        0xFF3366CC,
-        0xFF336699,
-        0xFF336666,
-        0xFF336633,
-        0xFF336600,
-        0xFF3333FF,
-        0xFF3333CC,
-        0xFF333399,
-        0xFF333366,
-        0xFF333333,
-        0xFF333300,
-        0xFF3300FF,
-        0xFF3300CC,
-        0xFF330099,
-        0xFF330066,
-        0xFF330033,
-        0xFF330000,
-        0xFF00FFFF,
-        0xFF00FFCC,
-        0xFF00FF99,
-        0xFF00FF66,
-        0xFF00FF33,
-        0xFF00FF00,
-        0xFF00CCFF,
-        0xFF00CCCC,
-        0xFF00CC99,
-        0xFF00CC66,
-        0xFF00CC33,
-        0xFF00CC00,
-        0xFF0099FF,
-        0xFF0099CC,
-        0xFF009999,
-        0xFF009966,
-        0xFF009933,
-        0xFF009900,
-        0xFF0066FF,
-        0xFF0066CC,
-        0xFF006699,
-        0xFF006666,
-        0xFF006633,
-        0xFF006600,
-        0xFF0033FF,
-        0xFF0033CC,
-        0xFF003399,
-        0xFF003366,
-        0xFF003333,
-        0xFF003300,
-        0xFF0000FF,
-        0xFF0000CC,
-        0xFF000099,
-        0xFF000066,
-        0xFF000033,
-        0xFFEE0000,
-        0xFFDD0000,
-        0xFFBB0000,
-        0xFFAA0000,
-        0xFF880000,
-        0xFF770000,
-        0xFF550000,
-        0xFF440000,
-        0xFF220000,
-        0xFF110000,
-        0xFF00EE00,
-        0xFF00DD00,
-        0xFF00BB00,
-        0xFF00AA00,
-        0xFF008800,
-        0xFF007700,
-        0xFF005500,
-        0xFF004400,
-        0xFF002200,
-        0xFF001100,
-        0xFF0000EE,
-        0xFF0000DD,
-        0xFF0000BB,
-        0xFF0000AA,
-        0xFF000088,
-        0xFF000077,
-        0xFF000055,
-        0xFF000044,
-        0xFF000022,
-        0xFF000011,
-        0xFFEEEEEE,
-        0xFFDDDDDD,
-        0xFFBBBBBB,
-        0xFFAAAAAA,
-        0xFF888888,
-        0xFF777777,
-        0xFF555555,
-        0xFF444444,
-        0xFF222222,
-        0xFF111111,
-        0xFF000000
-    };
+public class IcnsDecoder {
+    private static final int[] palette_4bpp = { 0xffffffff, 0xfffcf305,
+            0xffff6402, 0xffdd0806, 0xfff20884, 0xff4600a5, 0xff0000d4,
+            0xff02abea, 0xff1fb714, 0xff006411, 0xff562c05, 0xff90713a,
+            0xffc0c0c0, 0xff808080, 0xff404040, 0xff000000 };
+
+    private static final int[] palette_8bpp = { 0xFFFFFFFF, 0xFFFFFFCC,
+            0xFFFFFF99, 0xFFFFFF66, 0xFFFFFF33, 0xFFFFFF00, 0xFFFFCCFF,
+            0xFFFFCCCC, 0xFFFFCC99, 0xFFFFCC66, 0xFFFFCC33, 0xFFFFCC00,
+            0xFFFF99FF, 0xFFFF99CC, 0xFFFF9999, 0xFFFF9966, 0xFFFF9933,
+            0xFFFF9900, 0xFFFF66FF, 0xFFFF66CC, 0xFFFF6699, 0xFFFF6666,
+            0xFFFF6633, 0xFFFF6600, 0xFFFF33FF, 0xFFFF33CC, 0xFFFF3399,
+            0xFFFF3366, 0xFFFF3333, 0xFFFF3300, 0xFFFF00FF, 0xFFFF00CC,
+            0xFFFF0099, 0xFFFF0066, 0xFFFF0033, 0xFFFF0000, 0xFFCCFFFF,
+            0xFFCCFFCC, 0xFFCCFF99, 0xFFCCFF66, 0xFFCCFF33, 0xFFCCFF00,
+            0xFFCCCCFF, 0xFFCCCCCC, 0xFFCCCC99, 0xFFCCCC66, 0xFFCCCC33,
+            0xFFCCCC00, 0xFFCC99FF, 0xFFCC99CC, 0xFFCC9999, 0xFFCC9966,
+            0xFFCC9933, 0xFFCC9900, 0xFFCC66FF, 0xFFCC66CC, 0xFFCC6699,
+            0xFFCC6666, 0xFFCC6633, 0xFFCC6600, 0xFFCC33FF, 0xFFCC33CC,
+            0xFFCC3399, 0xFFCC3366, 0xFFCC3333, 0xFFCC3300, 0xFFCC00FF,
+            0xFFCC00CC, 0xFFCC0099, 0xFFCC0066, 0xFFCC0033, 0xFFCC0000,
+            0xFF99FFFF, 0xFF99FFCC, 0xFF99FF99, 0xFF99FF66, 0xFF99FF33,
+            0xFF99FF00, 0xFF99CCFF, 0xFF99CCCC, 0xFF99CC99, 0xFF99CC66,
+            0xFF99CC33, 0xFF99CC00, 0xFF9999FF, 0xFF9999CC, 0xFF999999,
+            0xFF999966, 0xFF999933, 0xFF999900, 0xFF9966FF, 0xFF9966CC,
+            0xFF996699, 0xFF996666, 0xFF996633, 0xFF996600, 0xFF9933FF,
+            0xFF9933CC, 0xFF993399, 0xFF993366, 0xFF993333, 0xFF993300,
+            0xFF9900FF, 0xFF9900CC, 0xFF990099, 0xFF990066, 0xFF990033,
+            0xFF990000, 0xFF66FFFF, 0xFF66FFCC, 0xFF66FF99, 0xFF66FF66,
+            0xFF66FF33, 0xFF66FF00, 0xFF66CCFF, 0xFF66CCCC, 0xFF66CC99,
+            0xFF66CC66, 0xFF66CC33, 0xFF66CC00, 0xFF6699FF, 0xFF6699CC,
+            0xFF669999, 0xFF669966, 0xFF669933, 0xFF669900, 0xFF6666FF,
+            0xFF6666CC, 0xFF666699, 0xFF666666, 0xFF666633, 0xFF666600,
+            0xFF6633FF, 0xFF6633CC, 0xFF663399, 0xFF663366, 0xFF663333,
+            0xFF663300, 0xFF6600FF, 0xFF6600CC, 0xFF660099, 0xFF660066,
+            0xFF660033, 0xFF660000, 0xFF33FFFF, 0xFF33FFCC, 0xFF33FF99,
+            0xFF33FF66, 0xFF33FF33, 0xFF33FF00, 0xFF33CCFF, 0xFF33CCCC,
+            0xFF33CC99, 0xFF33CC66, 0xFF33CC33, 0xFF33CC00, 0xFF3399FF,
+            0xFF3399CC, 0xFF339999, 0xFF339966, 0xFF339933, 0xFF339900,
+            0xFF3366FF, 0xFF3366CC, 0xFF336699, 0xFF336666, 0xFF336633,
+            0xFF336600, 0xFF3333FF, 0xFF3333CC, 0xFF333399, 0xFF333366,
+            0xFF333333, 0xFF333300, 0xFF3300FF, 0xFF3300CC, 0xFF330099,
+            0xFF330066, 0xFF330033, 0xFF330000, 0xFF00FFFF, 0xFF00FFCC,
+            0xFF00FF99, 0xFF00FF66, 0xFF00FF33, 0xFF00FF00, 0xFF00CCFF,
+            0xFF00CCCC, 0xFF00CC99, 0xFF00CC66, 0xFF00CC33, 0xFF00CC00,
+            0xFF0099FF, 0xFF0099CC, 0xFF009999, 0xFF009966, 0xFF009933,
+            0xFF009900, 0xFF0066FF, 0xFF0066CC, 0xFF006699, 0xFF006666,
+            0xFF006633, 0xFF006600, 0xFF0033FF, 0xFF0033CC, 0xFF003399,
+            0xFF003366, 0xFF003333, 0xFF003300, 0xFF0000FF, 0xFF0000CC,
+            0xFF000099, 0xFF000066, 0xFF000033, 0xFFEE0000, 0xFFDD0000,
+            0xFFBB0000, 0xFFAA0000, 0xFF880000, 0xFF770000, 0xFF550000,
+            0xFF440000, 0xFF220000, 0xFF110000, 0xFF00EE00, 0xFF00DD00,
+            0xFF00BB00, 0xFF00AA00, 0xFF008800, 0xFF007700, 0xFF005500,
+            0xFF004400, 0xFF002200, 0xFF001100, 0xFF0000EE, 0xFF0000DD,
+            0xFF0000BB, 0xFF0000AA, 0xFF000088, 0xFF000077, 0xFF000055,
+            0xFF000044, 0xFF000022, 0xFF000011, 0xFFEEEEEE, 0xFFDDDDDD,
+            0xFFBBBBBB, 0xFFAAAAAA, 0xFF888888, 0xFF777777, 0xFF555555,
+            0xFF444444, 0xFF222222, 0xFF111111, 0xFF000000 };
 
     private static void decode1BPPImage(IcnsType imageType, byte[] imageData,
-            ImageBuilder image)
-    {
+            ImageBuilder image) {
         int position = 0;
         int bitsLeft = 0;
         int value = 0;
-        for (int y = 0; y < imageType.getHeight(); y++)
-        {
-            for (int x = 0; x < imageType.getWidth(); x++)
-            {
-                if (bitsLeft == 0)
-                {
+        for (int y = 0; y < imageType.getHeight(); y++) {
+            for (int x = 0; x < imageType.getWidth(); x++) {
+                if (bitsLeft == 0) {
                     value = 0xff & imageData[position++];
                     bitsLeft = 8;
                 }
@@ -333,14 +106,11 @@ public class IcnsDecoder
     }
 
     private static void decode4BPPImage(IcnsType imageType, byte[] imageData,
-            ImageBuilder image)
-    {
+            ImageBuilder image) {
         int i = 0;
         boolean visited = false;
-        for (int y = 0; y < imageType.getHeight(); y++)
-        {
-            for (int x = 0; x < imageType.getWidth(); x++)
-            {
+        for (int y = 0; y < imageType.getHeight(); y++) {
+            for (int x = 0; x < imageType.getWidth(); x++) {
                 int index;
                 if (!visited)
                     index = 0xf & (imageData[i] >> 4);
@@ -353,53 +123,46 @@ public class IcnsDecoder
     }
 
     private static void decode8BPPImage(IcnsType imageType, byte[] imageData,
-            ImageBuilder image)
-    {
-        for (int y = 0; y < imageType.getHeight(); y++)
-        {
-            for (int x = 0; x < imageType.getWidth(); x++)
-            {
-                int index = 0xff & imageData[y*imageType.getWidth() + x];
+            ImageBuilder image) {
+        for (int y = 0; y < imageType.getHeight(); y++) {
+            for (int x = 0; x < imageType.getWidth(); x++) {
+                int index = 0xff & imageData[y * imageType.getWidth() + x];
                 image.setRGB(x, y, palette_8bpp[index]);
             }
         }
     }
 
     private static void decode32BPPImage(IcnsType imageType, byte[] imageData,
-            ImageBuilder image)
-    {
-        for (int y = 0; y < imageType.getHeight(); y++)
-        {
-            for (int x = 0; x < imageType.getWidth(); x++)
-            {
-                int argb = 0xff000000 /* the "alpha" is ignored */ |
-                        ((0xff & imageData[4*(y*imageType.getWidth() + x) + 1]) << 16) |
-                        ((0xff & imageData[4*(y*imageType.getWidth() + x) + 2]) << 8) |
-                        (0xff & imageData[4*(y*imageType.getWidth() + x) + 3]);
+            ImageBuilder image) {
+        for (int y = 0; y < imageType.getHeight(); y++) {
+            for (int x = 0; x < imageType.getWidth(); x++) {
+                int argb = 0xff000000 /* the "alpha" is ignored */
+                        | ((0xff & imageData[4 * (y * imageType.getWidth() + x) + 1]) << 16)
+                        | ((0xff & imageData[4 * (y * imageType.getWidth() + x) + 2]) << 8)
+                        | (0xff & imageData[4 * (y * imageType.getWidth() + x) + 3]);
                 image.setRGB(x, y, argb);
             }
         }
     }
 
-    private static void apply1BPPMask(byte[] maskData, ImageBuilder image) throws ImageReadException
-    {
+    private static void apply1BPPMask(byte[] maskData, ImageBuilder image)
+            throws ImageReadException {
         int position = 0;
         int bitsLeft = 0;
         int value = 0;
 
-        // 1 bit icon types have image data followed by mask data in the same entry
+        // 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
-            throw new ImageReadException("1 BPP mask underrun parsing ICNS file");
+            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++)
-            {
-                if (bitsLeft == 0)
-                {
+        for (int y = 0; y < image.getHeight(); y++) {
+            for (int x = 0; x < image.getWidth(); x++) {
+                if (bitsLeft == 0) {
                     value = 0xff & maskData[position++];
                     bitsLeft = 8;
                 }
@@ -410,31 +173,27 @@ public class IcnsDecoder
                     alpha = 0x00;
                 value <<= 1;
                 bitsLeft--;
-                image.setRGB(x, y, (alpha << 24) |
-                    (0xffffff & image.getRGB(x, y)));
+                image.setRGB(x, y,
+                        (alpha << 24) | (0xffffff & image.getRGB(x, y)));
             }
         }
     }
 
-    private static void apply8BPPMask(byte[] maskData, ImageBuilder image)
-    {
-        for (int y = 0; y < image.getHeight(); y++)
-        {
-            for (int x = 0; x < image.getWidth(); x++)
-            {
-                int alpha = 0xff & maskData[y*image.getWidth() + x];
-                image.setRGB(x, y, (alpha << 24) |
-                    (0xffffff & image.getRGB(x, y)));
+    private static void apply8BPPMask(byte[] maskData, ImageBuilder image) {
+        for (int y = 0; y < image.getHeight(); y++) {
+            for (int x = 0; x < image.getWidth(); x++) {
+                int alpha = 0xff & maskData[y * image.getWidth() + x];
+                image.setRGB(x, y,
+                        (alpha << 24) | (0xffffff & image.getRGB(x, y)));
             }
         }
     }
 
-    public static List<BufferedImage> decodeAllImages(IcnsImageParser.IcnsElement[] icnsElements)
-            throws ImageReadException
-    {
+    public static List<BufferedImage> decodeAllImages(
+            IcnsImageParser.IcnsElement[] icnsElements)
+            throws ImageReadException {
         List<BufferedImage> result = new ArrayList<BufferedImage>();
-        for (int i = 0; i < icnsElements.length; i++)
-        {
+        for (int i = 0; i < icnsElements.length; i++) {
             IcnsImageParser.IcnsElement imageElement = icnsElements[i];
             IcnsType imageType = IcnsType.findImageType(imageElement.type);
             if (imageType == null)
@@ -442,34 +201,24 @@ public class IcnsDecoder
 
             IcnsType maskType = null;
             IcnsImageParser.IcnsElement maskElement = null;
-            if (imageType.hasMask())
-            {
+            if (imageType.hasMask()) {
                 maskType = imageType;
                 maskElement = imageElement;
-            }
-            else
-            {
+            } else {
                 maskType = IcnsType.find8BPPMaskType(imageType);
-                if (maskType != null)
-                {
-                    for (int j = 0; j < icnsElements.length; j++)
-                    {
-                        if (icnsElements[j].type == maskType.getType())
-                        {
+                if (maskType != null) {
+                    for (int j = 0; j < icnsElements.length; j++) {
+                        if (icnsElements[j].type == maskType.getType()) {
                             maskElement = icnsElements[j];
                             break;
                         }
                     }
                 }
-                if (maskElement == null)
-                {
+                if (maskElement == null) {
                     maskType = IcnsType.find1BPPMaskType(imageType);
-                    if (maskType != null)
-                    {
-                        for (int j = 0; j < icnsElements.length; j++)
-                        {
-                            if (icnsElements[j].type == maskType.getType())
-                            {
+                    if (maskType != null) {
+                        for (int j = 0; j < icnsElements.length; j++) {
+                            if (icnsElements[j].type == maskType.getType()) {
                                 maskElement = icnsElements[j];
                                 break;
                             }
@@ -479,61 +228,56 @@ 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)
+            if (imageType == IcnsType.ICNS_256x256_32BIT_ARGB_IMAGE
+                    || imageType == IcnsType.ICNS_512x512_32BIT_ARGB_IMAGE)
                 continue;
 
-            int expectedSize = (imageType.getWidth()*imageType.getHeight()*
-                    imageType.getBitsPerPixel() + 7) / 8;
+            int expectedSize = (imageType.getWidth() * imageType.getHeight()
+                    * imageType.getBitsPerPixel() + 7) / 8;
             byte[] imageData;
-            if (imageElement.data.length < expectedSize)
-            {
-                if (imageType.getBitsPerPixel() == 32)
-                {
-                    imageData = Rle24Compression.decompress(imageType.getWidth(),
-                            imageType.getHeight(), imageElement.data);
-                }
-                else
+            if (imageElement.data.length < expectedSize) {
+                if (imageType.getBitsPerPixel() == 32) {
+                    imageData = Rle24Compression.decompress(
+                            imageType.getWidth(), imageType.getHeight(),
+                            imageElement.data);
+                } 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);
-            switch (imageType.getBitsPerPixel())
-            {
-                case 1:
-                    decode1BPPImage(imageType, imageData, imageBuilder);
-                    break;
-                case 4:
-                    decode4BPPImage(imageType, imageData, imageBuilder);
-                    break;
-                case 8:
-                    decode8BPPImage(imageType, imageData, imageBuilder);
-                    break;
-                case 32:
-                    decode32BPPImage(imageType, imageData, imageBuilder);
-                    break;
-                default:
-                    throw new ImageReadException(
-                        "Unsupported bit depth " + imageType.getBitsPerPixel());
+            switch (imageType.getBitsPerPixel()) {
+            case 1:
+                decode1BPPImage(imageType, imageData, imageBuilder);
+                break;
+            case 4:
+                decode4BPPImage(imageType, imageData, imageBuilder);
+                break;
+            case 8:
+                decode8BPPImage(imageType, imageData, imageBuilder);
+                break;
+            case 32:
+                decode32BPPImage(imageType, imageData, imageBuilder);
+                break;
+            default:
+                throw new ImageReadException("Unsupported bit depth "
+                        + imageType.getBitsPerPixel());
             }
 
-            if (maskElement != null)
-            {
+            if (maskElement != null) {
                 if (maskType.getBitsPerPixel() == 1)
                     apply1BPPMask(maskElement.data, imageBuilder);
                 else if (maskType.getBitsPerPixel() == 8)
                     apply8BPPMask(maskElement.data, imageBuilder);
                 else
-                    throw new ImageReadException("Unsupport mask bit depth " +
-                            maskType.getBitsPerPixel());
+                    throw new ImageReadException("Unsupport mask bit depth "
+                            + maskType.getBitsPerPixel());
             }
 
             result.add(imageBuilder.getBufferedImage());
         }
         return result;
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -39,64 +39,51 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.ParamMap;
 
-public class IcnsImageParser extends ImageParser
-{
+public class IcnsImageParser extends ImageParser {
     public static final int ICNS_MAGIC = IcnsType.typeAsInt("icns");
 
-    public IcnsImageParser()
-    {
+    public IcnsImageParser() {
         super.setByteOrder(BYTE_ORDER_MSB);
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "icns-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
 
     private static final String DEFAULT_EXTENSION = ".icns";
 
-    private static final String ACCEPTED_EXTENSIONS[] = {
-            ".icns",
-    };
+    private static final String ACCEPTED_EXTENSIONS[] = { ".icns", };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
-        return new ImageFormat[]{
-            ImageFormat.IMAGE_FORMAT_ICNS
-        };
+    protected ImageFormat[] getAcceptedTypes() {
+        return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_ICNS };
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[])
-    {
+    public boolean embedICCProfile(File src, File dst, byte profile[]) {
         return false;
     }
 
     @Override
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
@@ -106,28 +93,28 @@ public class IcnsImageParser extends Ima
         if (params.containsKey(PARAM_KEY_VERBOSE))
             params.remove(PARAM_KEY_VERBOSE);
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageReadException("Unknown parameter: " + firstKey);
         }
 
         IcnsContents contents = readImage(byteSource);
-        List<BufferedImage> images = IcnsDecoder.decodeAllImages(contents.icnsElements);
+        List<BufferedImage> images = IcnsDecoder
+                .decodeAllImages(contents.icnsElements);
         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", image0.getHeight(), "image/x-icns", images.size(),
-                0, 0, 0, 0, image0.getWidth(), false, true, false, ImageInfo.COLOR_TYPE_RGB,
+        return new ImageInfo("Icns", 32, new ArrayList<String>(),
+                ImageFormat.IMAGE_FORMAT_ICNS, "ICNS Apple Icon Image",
+                image0.getHeight(), "image/x-icns", images.size(), 0, 0, 0, 0,
+                image0.getWidth(), false, true, false,
+                ImageInfo.COLOR_TYPE_RGB,
                 ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN);
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public Dimension getImageSize(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
@@ -137,14 +124,14 @@ public class IcnsImageParser extends Ima
         if (params.containsKey(PARAM_KEY_VERBOSE))
             params.remove(PARAM_KEY_VERBOSE);
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageReadException("Unknown parameter: " + firstKey);
         }
 
         IcnsContents contents = readImage(byteSource);
-        List<BufferedImage> images = IcnsDecoder.decodeAllImages(contents.icnsElements);
+        List<BufferedImage> images = IcnsDecoder
+                .decodeAllImages(contents.icnsElements);
         if (images.isEmpty())
             throw new ImageReadException("No icons in ICNS file");
         BufferedImage image0 = images.get(0);
@@ -152,62 +139,53 @@ public class IcnsImageParser extends Ima
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         return null;
     }
 
-    private static class IcnsHeader
-    {
+    private static class IcnsHeader {
         public final int magic; // Magic literal (4 bytes), always "icns"
         public final int fileSize; // Length of file (4 bytes), in bytes.
 
-        public IcnsHeader(final int magic, final int fileSize)
-        {
+        public IcnsHeader(final int magic, final int fileSize) {
             this.magic = magic;
             this.fileSize = fileSize;
         }
 
-        public void dump(PrintWriter pw)
-        {
+        public void dump(PrintWriter pw) {
             pw.println("IcnsHeader");
-            pw.println("Magic: 0x" + Integer.toHexString(magic) +
-                    " (" + IcnsType.describeType(magic) + ")");
+            pw.println("Magic: 0x" + Integer.toHexString(magic) + " ("
+                    + IcnsType.describeType(magic) + ")");
             pw.println("FileSize: " + fileSize);
             pw.println("");
         }
     }
 
     private IcnsHeader readIcnsHeader(InputStream is)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         int Magic = read4Bytes("Magic", is, "Not a Valid ICNS File");
         int FileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File");
 
         if (Magic != ICNS_MAGIC)
-            throw new ImageReadException("Not a Valid ICNS File: " +
-                    "magic is 0x" + Integer.toHexString(Magic));
+            throw new ImageReadException("Not a Valid ICNS File: "
+                    + "magic is 0x" + Integer.toHexString(Magic));
 
         return new IcnsHeader(Magic, FileSize);
     }
 
-    public static class IcnsElement
-    {
+    public static class IcnsElement {
         public final int type;
         public final int elementSize;
         public final byte[] data;
 
-        public IcnsElement(final int type, final int elementSize, byte[] data)
-        {
+        public IcnsElement(final int type, final int elementSize, byte[] data) {
             this.type = type;
             this.elementSize = elementSize;
             this.data = data;
         }
 
-        public void dump(PrintWriter pw)
-        {
+        public void dump(PrintWriter pw) {
             pw.println("IcnsElement");
             IcnsType icnsType = IcnsType.findAnyType(type);
             String typeDescription;
@@ -215,31 +193,38 @@ public class IcnsImageParser extends Ima
                 typeDescription = "";
             else
                 typeDescription = " " + icnsType.toString();
-            pw.println("Type: 0x" + Integer.toHexString(type) +
-                    " (" + IcnsType.describeType(type) + ")" +
-                    typeDescription);
+            pw.println("Type: 0x" + Integer.toHexString(type) + " ("
+                    + IcnsType.describeType(type) + ")" + typeDescription);
             pw.println("ElementSize: " + elementSize);
             pw.println("");
         }
     }
 
-    private IcnsElement readIcnsElement(InputStream is) throws IOException
-    {
-        int type = read4Bytes("Type", is, "Not a Valid ICNS File"); // Icon type (4 bytes)
-        int elementSize = read4Bytes("ElementSize", is, "Not a Valid ICNS File"); // Length of data (4 bytes), in bytes, including this header
-        byte[] data = readByteArray("Data", elementSize - 8, is, "Not a Valid ICNS File");
+    private IcnsElement readIcnsElement(InputStream is) throws IOException {
+        int type = read4Bytes("Type", is, "Not a Valid ICNS File"); // Icon type
+                                                                    // (4 bytes)
+        int elementSize = read4Bytes("ElementSize", is, "Not a Valid ICNS File"); // Length
+                                                                                  // of
+                                                                                  // data
+                                                                                  // (4
+                                                                                  // bytes),
+                                                                                  // in
+                                                                                  // bytes,
+                                                                                  // including
+                                                                                  // this
+                                                                                  // header
+        byte[] data = readByteArray("Data", elementSize - 8, is,
+                "Not a Valid ICNS File");
 
         return new IcnsElement(type, elementSize, data);
     }
 
-    private static class IcnsContents
-    {
+    private static class IcnsContents {
         public final IcnsHeader icnsHeader;
         public final IcnsElement icnsElements[];
 
         public IcnsContents(final IcnsHeader icnsHeader,
-                final IcnsElement[] icnsElements)
-        {
+                final IcnsElement[] icnsElements) {
             super();
             this.icnsHeader = icnsHeader;
             this.icnsElements = icnsElements;
@@ -247,18 +232,14 @@ public class IcnsImageParser extends Ima
     }
 
     private IcnsContents readImage(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             IcnsHeader icnsHeader = readIcnsHeader(is);
 
             List<IcnsElement> icnsElementList = new ArrayList<IcnsElement>();
-            for (int remainingSize = icnsHeader.fileSize - 8;
-                remainingSize > 0; )
-            {
+            for (int remainingSize = icnsHeader.fileSize - 8; remainingSize > 0;) {
                 IcnsElement icnsElement = readIcnsElement(is);
                 icnsElementList.add(icnsElement);
                 remainingSize -= icnsElement.elementSize;
@@ -269,15 +250,10 @@ public class IcnsImageParser extends Ima
                 icnsElements[i] = icnsElementList.get(i);
 
             return new IcnsContents(icnsHeader, icnsElements);
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 is.close();
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
         }
@@ -285,8 +261,7 @@ public class IcnsImageParser extends Ima
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         IcnsContents icnsContents = readImage(byteSource);
         icnsContents.icnsHeader.dump(pw);
         for (int i = 0; i < icnsContents.icnsElements.length; i++)
@@ -296,10 +271,10 @@ public class IcnsImageParser extends Ima
 
     @Override
     public final BufferedImage getBufferedImage(ByteSource byteSource,
-            Map params) throws ImageReadException, IOException
-    {
+            Map params) throws ImageReadException, IOException {
         IcnsContents icnsContents = readImage(byteSource);
-        List<BufferedImage> result = IcnsDecoder.decodeAllImages(icnsContents.icnsElements);
+        List<BufferedImage> result = IcnsDecoder
+                .decodeAllImages(icnsContents.icnsElements);
         if (result.size() > 0)
             return result.get(0);
         else
@@ -308,16 +283,14 @@ public class IcnsImageParser extends Ima
 
     @Override
     public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         IcnsContents icnsContents = readImage(byteSource);
         return IcnsDecoder.decodeAllImages(icnsContents.icnsElements);
     }
 
     @Override
     public void writeImage(BufferedImage src, OutputStream os, Map params)
-            throws ImageWriteException, IOException
-    {
+            throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
@@ -325,8 +298,7 @@ public class IcnsImageParser extends Ima
         if (params.containsKey(PARAM_KEY_FORMAT))
             params.remove(PARAM_KEY_FORMAT);
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
@@ -341,20 +313,21 @@ public class IcnsImageParser extends Ima
         else if (src.getWidth() == 128 && src.getHeight() == 128)
             imageType = IcnsType.ICNS_128x128_32BIT_IMAGE;
         else
-            throw new ImageWriteException("Invalid/unsupported source width " +
-                    src.getWidth() + " and height " + src.getHeight());
+            throw new ImageWriteException("Invalid/unsupported source width "
+                    + src.getWidth() + " and height " + src.getHeight());
 
-        BinaryOutputStream bos = new BinaryOutputStream(os, BYTE_ORDER_BIG_ENDIAN);
+        BinaryOutputStream bos = new BinaryOutputStream(os,
+                BYTE_ORDER_BIG_ENDIAN);
         bos.write4Bytes(ICNS_MAGIC);
-        bos.write4Bytes(4 + 4 + 4 + 4 + 4*imageType.getWidth()*imageType.getHeight() +
-                4 + 4 + imageType.getWidth()*imageType.getHeight());
+        bos.write4Bytes(4 + 4 + 4 + 4 + 4 * imageType.getWidth()
+                * imageType.getHeight() + 4 + 4 + imageType.getWidth()
+                * imageType.getHeight());
 
         bos.write4Bytes(imageType.getType());
-        bos.write4Bytes(4 + 4 + 4*imageType.getWidth()*imageType.getHeight());
-        for (int y = 0; y < src.getHeight(); y++)
-        {
-            for (int x = 0; x < src.getWidth(); x++)
-            {
+        bos.write4Bytes(4 + 4 + 4 * imageType.getWidth()
+                * imageType.getHeight());
+        for (int y = 0; y < src.getHeight(); y++) {
+            for (int x = 0; x < src.getWidth(); x++) {
                 int argb = src.getRGB(x, y);
                 bos.write(0);
                 bos.write(argb >> 16);
@@ -365,11 +338,9 @@ public class IcnsImageParser extends Ima
 
         IcnsType maskType = IcnsType.find8BPPMaskType(imageType);
         bos.write4Bytes(maskType.getType());
-        bos.write4Bytes(4 + 4 + imageType.getWidth()*imageType.getWidth());
-        for (int y = 0; y < src.getHeight(); y++)
-        {
-            for (int x = 0; x < src.getWidth(); x++)
-            {
+        bos.write4Bytes(4 + 4 + imageType.getWidth() * imageType.getWidth());
+        for (int y = 0; y < src.getHeight(); y++) {
+            for (int x = 0; x < src.getWidth(); x++) {
                 int argb = src.getRGB(x, y);
                 bos.write(argb >> 24);
             }
@@ -379,17 +350,16 @@ public class IcnsImageParser extends Ima
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>
-     *
+     * 
      * @param byteSource
      *            File containing image data.
      * @param params
      *            Map of optional parameters, defined in SanselanConstants.
-     * @return Xmp Xml as String, if present.  Otherwise, returns null.
+     * @return Xmp Xml as String, if present. Otherwise, returns null.
      */
     @Override
     public String getXmpXml(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 }



Mime
View raw message