Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E7CE1D2E8 for ; Thu, 27 Sep 2012 18:23:31 +0000 (UTC) Received: (qmail 24476 invoked by uid 500); 27 Sep 2012 18:23:31 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 24405 invoked by uid 500); 27 Sep 2012 18:23:31 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 24397 invoked by uid 99); 27 Sep 2012 18:23:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2012 18:23:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2012 18:23:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 91D2623889FD for ; Thu, 27 Sep 2012 18:22:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1391156 [2/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 -0000 To: commits@commons.apache.org From: damjan@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120927182244.91D2623889FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUp.java Thu Sep 27 18:22:37 2012 @@ -33,10 +33,11 @@ public class ScanlineFilterUp extends Sc for (int i = 0; i < src.length; i++) { // byte b; - if (up != null) + if (up != null) { dst[i] = (byte) ((src[i] + up[i]) % 256); - else + } else { dst[i] = src[i]; + } // if(i<10) // System.out.println("\t" + i + ": " + dst[i]); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java Thu Sep 27 18:22:37 2012 @@ -70,8 +70,9 @@ public class PbmFileInfo extends FileInf public int getRGB(InputStream is) throws IOException { if (bits_in_cache < 1) { int bits = is.read(); - if (bits < 0) + if (bits < 0) { throw new IOException("PBM: Unexpected EOF"); + } bitcache = 0xff & bits; bits_in_cache += 8; } @@ -80,20 +81,24 @@ public class PbmFileInfo extends FileInf bitcache <<= 1; bits_in_cache--; - if (bit == 0) + if (bit == 0) { return 0xffffffff; - if (bit == 1) + } + if (bit == 1) { return 0xff000000; + } throw new IOException("PBM: bad bit: " + bit); } @Override public int getRGB(WhiteSpaceReader wsr) throws IOException { int bit = Integer.parseInt(wsr.readtoWhiteSpace()); - if (bit == 0) + if (bit == 0) { return 0xff000000; - if (bit == 1) + } + if (bit == 1) { return 0xffffffff; + } throw new IOException("PBM: bad bit: " + bit); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java Thu Sep 27 18:22:37 2012 @@ -54,10 +54,11 @@ public class PbmWriter extends PnmWriter int green = 0xff & (argb >> 8); int blue = 0xff & (argb >> 0); int sample = (red + green + blue) / 3; - if (sample > 127) + if (sample > 127) { sample = 0; - else + } else { sample = 1; + } if (RAWBITS) { bitcache = (bitcache << 1) | (0x1 & sample); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmFileInfo.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmFileInfo.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmFileInfo.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmFileInfo.java Thu Sep 27 18:22:37 2012 @@ -64,8 +64,9 @@ public class PgmFileInfo extends FileInf @Override public int getRGB(InputStream is) throws IOException { int sample = is.read(); - if (sample < 0) + if (sample < 0) { throw new IOException("PGM: Unexpected EOF"); + } int alpha = 0xff; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java Thu Sep 27 18:22:37 2012 @@ -49,7 +49,7 @@ public class PgmWriter extends PnmWriter os.write(("" + 255).getBytes("US-ASCII")); // max component value os.write(PNM_NEWLINE); - for (int y = 0; y < height; y++) + for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int argb = src.getRGB(x, y); int red = 0xff & (argb >> 16); @@ -66,6 +66,7 @@ public class PgmWriter extends PnmWriter os.write(PNM_SEPARATOR); } } + } } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java Thu Sep 27 18:22:37 2012 @@ -90,14 +90,15 @@ public class PnmImageParser extends Imag // System.out.println("((width*height+7)/8): " // + ((width * height + 7) / 8)); - if (identifier1 != PNM_PREFIX_BYTE) + if (identifier1 != PNM_PREFIX_BYTE) { throw new ImageReadException("PNM file has invalid header."); + } - if (identifier2 == PBM_TEXT_CODE) + if (identifier2 == PBM_TEXT_CODE) { return new PbmFileInfo(width, height, false); - else if (identifier2 == PBM_RAW_CODE) + } else if (identifier2 == PBM_RAW_CODE) { return new PbmFileInfo(width, height, true); - else if (identifier2 == PGM_TEXT_CODE) { + } else if (identifier2 == PGM_TEXT_CODE) { int maxgray = Integer.parseInt(wsr.readtoWhiteSpace()); return new PgmFileInfo(width, height, false, maxgray); } else if (identifier2 == PGM_RAW_CODE) { @@ -110,8 +111,9 @@ public class PnmImageParser extends Imag int max = Integer.parseInt(wsr.readtoWhiteSpace()); // System.out.println("max: " + max); return new PpmFileInfo(width, height, true, max); - } else + } else { throw new ImageReadException("PNM file has invalid header."); + } } private FileInfo readHeader(ByteSource byteSource) @@ -144,8 +146,9 @@ public class PnmImageParser extends Imag throws ImageReadException, IOException { FileInfo info = readHeader(byteSource); - if (info == null) + if (info == null) { throw new ImageReadException("PNM: Couldn't read Header"); + } return new Dimension(info.width, info.height); } @@ -170,8 +173,9 @@ public class PnmImageParser extends Imag throws ImageReadException, IOException { FileInfo info = readHeader(byteSource); - if (info == null) + if (info == null) { throw new ImageReadException("PNM: Couldn't read Header"); + } List Comments = new ArrayList(); @@ -211,23 +215,23 @@ public class PnmImageParser extends Imag throws ImageReadException, IOException { pw.println("pnm.dumpImageFile"); - { - ImageInfo imageData = getImageInfo(byteSource); - if (imageData == null) - return false; - - imageData.toString(pw, ""); + ImageInfo imageData = getImageInfo(byteSource); + if (imageData == null) { + return false; } + imageData.toString(pw, ""); + pw.println(""); return true; } private int[] getColorTable(byte bytes[]) throws ImageReadException { - if ((bytes.length % 3) != 0) + if ((bytes.length % 3) != 0) { throw new ImageReadException("Bad Color Table Length: " + bytes.length); + } int length = bytes.length / 3; int result[] = new int[length]; @@ -289,23 +293,26 @@ public class PnmImageParser extends Imag if (params != null) { Object useRawbitsParam = params.get(PARAM_KEY_PNM_RAWBITS); if (useRawbitsParam != null) { - if (useRawbitsParam.equals(PARAM_VALUE_PNM_RAWBITS_NO)) + if (useRawbitsParam.equals(PARAM_VALUE_PNM_RAWBITS_NO)) { useRawbits = false; + } } Object subtype = params.get(PARAM_KEY_FORMAT); if (subtype != null) { - if (subtype.equals(ImageFormat.IMAGE_FORMAT_PBM)) + if (subtype.equals(ImageFormat.IMAGE_FORMAT_PBM)) { writer = new PbmWriter(useRawbits); - else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PGM)) + } else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PGM)) { writer = new PgmWriter(useRawbits); - else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PPM)) + } else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PPM)) { writer = new PpmWriter(useRawbits); + } } } - if (writer == null) + if (writer == null) { writer = new PpmWriter(useRawbits); + } // make copy of params; we'll clear keys as we consume them. if (params != null) { @@ -315,8 +322,9 @@ public class PnmImageParser extends Imag } // clear format key. - if (params.containsKey(PARAM_KEY_FORMAT)) + if (params.containsKey(PARAM_KEY_FORMAT)) { params.remove(PARAM_KEY_FORMAT); + } if (params.size() > 0) { Object firstKey = params.keySet().iterator().next(); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmFileInfo.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmFileInfo.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmFileInfo.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmFileInfo.java Thu Sep 27 18:22:37 2012 @@ -67,8 +67,9 @@ public class PpmFileInfo extends FileInf int green = is.read(); int blue = is.read(); - if ((red < 0) || (green < 0) || (blue < 0)) + if ((red < 0) || (green < 0) || (blue < 0)) { throw new IOException("PPM: Unexpected EOF"); + } int alpha = 0xff; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java Thu Sep 27 18:22:37 2012 @@ -49,7 +49,7 @@ public class PpmWriter extends PnmWriter os.write(("" + 255).getBytes("US-ASCII")); // max component value os.write(PNM_NEWLINE); - for (int y = 0; y < height; y++) + for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int argb = src.getRGB(x, y); int red = 0xff & (argb >> 16); @@ -73,5 +73,6 @@ public class PpmWriter extends PnmWriter os.write(PNM_SEPARATOR); } } + } } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java Thu Sep 27 18:22:37 2012 @@ -28,8 +28,9 @@ class WhiteSpaceReader { private char read() throws IOException { int result = is.read(); - if (result < 0) + if (result < 0) { throw new IOException("PNM: Unexpected EOF"); + } return (char) result; } @@ -47,8 +48,9 @@ class WhiteSpaceReader { public String readtoWhiteSpace() throws IOException { char c = nextChar(); - while (Character.isWhitespace(c)) + while (Character.isWhitespace(c)) { c = nextChar(); + } StringBuilder buffer = new StringBuilder(); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceType.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceType.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceType.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceType.java Thu Sep 27 18:22:37 2012 @@ -30,8 +30,9 @@ public class ImageResourceType { public ImageResourceType(int ID, int ID2, String Description) throws ImageReadException { this(ID, Description); - if (ID != ID2) + if (ID != ID2) { throw new ImageReadException("Mismatch ID: " + ID + " ID2: " + ID2); + } } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java Thu Sep 27 18:22:37 2012 @@ -23,8 +23,9 @@ public class PsdConstants { public String getDescription(int id) { for (int i = 0; i < fImageResourceTypes.length; i++) { - if (fImageResourceTypes[i].ID == id) + if (fImageResourceTypes[i].ID == id) { return fImageResourceTypes[i].Description; + } } return "Unknown"; } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java Thu Sep 27 18:22:37 2012 @@ -172,12 +172,15 @@ public class PsdImageParser extends Imag } private boolean keepImageResourceBlock(int ID, int imageResourceIDs[]) { - if (imageResourceIDs == null) + if (imageResourceIDs == null) { return true; + } - for (int i = 0; i < imageResourceIDs.length; i++) - if (ID == imageResourceIDs[i]) + for (int i = 0; i < imageResourceIDs.length; i++) { + if (ID == imageResourceIDs[i]) { return true; + } + } return false; } @@ -227,8 +230,9 @@ public class PsdImageParser extends Imag result.add(new ImageResourceBlock(id, nameBytes, Data)); if ((maxBlocksToRead >= 0) - && (result.size() >= maxBlocksToRead)) + && (result.size() >= maxBlocksToRead)) { return result; + } } // debugNumber("ID", ID, 2); @@ -283,8 +287,9 @@ public class PsdImageParser extends Imag try { is = byteSource.getInputStream(); - if (section == PSD_SECTION_HEADER) + if (section == PSD_SECTION_HEADER) { return is; + } skipBytes(is, PSD_HEADER_LENGTH); // is.skip(kHeaderLength); @@ -292,8 +297,9 @@ public class PsdImageParser extends Imag int ColorModeDataLength = read4Bytes("ColorModeDataLength", is, "Not a Valid PSD File"); - if (section == PSD_SECTION_COLOR_MODE) + if (section == PSD_SECTION_COLOR_MODE) { return is; + } skipBytes(is, ColorModeDataLength); // byte ColorModeData[] = readByteArray("ColorModeData", @@ -302,8 +308,9 @@ public class PsdImageParser extends Imag int ImageResourcesLength = read4Bytes("ImageResourcesLength", is, "Not a Valid PSD File"); - if (section == PSD_SECTION_IMAGE_RESOURCES) + if (section == PSD_SECTION_IMAGE_RESOURCES) { return is; + } skipBytes(is, ImageResourcesLength); // byte ImageResources[] = readByteArray("ImageResources", @@ -312,8 +319,9 @@ public class PsdImageParser extends Imag int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength", is, "Not a Valid PSD File"); - if (section == PSD_SECTION_LAYER_AND_MASK_DATA) + if (section == PSD_SECTION_LAYER_AND_MASK_DATA) { return is; + } skipBytes(is, LayerAndMaskDataLength); // byte LayerAndMaskData[] = readByteArray("LayerAndMaskData", @@ -324,8 +332,9 @@ public class PsdImageParser extends Imag // byte ImageData[] = readByteArray("ImageData", // LayerAndMaskDataLength, is, "Not a Valid PSD File"); - if (section == PSD_SECTION_IMAGE_DATA) + if (section == PSD_SECTION_IMAGE_DATA) { return is; + } notFound = true; } finally { if (notFound && is != null) { @@ -347,17 +356,19 @@ public class PsdImageParser extends Imag is = byteSource.getInputStream(); // PsdHeaderInfo header = readHeader(is); - if (section == PSD_SECTION_HEADER) + if (section == PSD_SECTION_HEADER) { return readByteArray("Header", PSD_HEADER_LENGTH, is, "Not a Valid PSD File"); + } skipBytes(is, PSD_HEADER_LENGTH); int ColorModeDataLength = read4Bytes("ColorModeDataLength", is, "Not a Valid PSD File"); - if (section == PSD_SECTION_COLOR_MODE) + if (section == PSD_SECTION_COLOR_MODE) { return readByteArray("ColorModeData", ColorModeDataLength, is, "Not a Valid PSD File"); + } skipBytes(is, ColorModeDataLength); // byte ColorModeData[] = readByteArray("ColorModeData", @@ -366,9 +377,10 @@ public class PsdImageParser extends Imag int ImageResourcesLength = read4Bytes("ImageResourcesLength", is, "Not a Valid PSD File"); - if (section == PSD_SECTION_IMAGE_RESOURCES) + if (section == PSD_SECTION_IMAGE_RESOURCES) { return readByteArray("ImageResources", ImageResourcesLength, is, "Not a Valid PSD File"); + } skipBytes(is, ImageResourcesLength); // byte ImageResources[] = readByteArray("ImageResources", @@ -377,9 +389,10 @@ public class PsdImageParser extends Imag int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength", is, "Not a Valid PSD File"); - if (section == PSD_SECTION_LAYER_AND_MASK_DATA) + if (section == PSD_SECTION_LAYER_AND_MASK_DATA) { return readByteArray("LayerAndMaskData", LayerAndMaskDataLength, is, "Not a Valid PSD File"); + } skipBytes(is, LayerAndMaskDataLength); // byte LayerAndMaskData[] = readByteArray("LayerAndMaskData", @@ -439,13 +452,15 @@ public class PsdImageParser extends Imag List blocks = readImageResourceBlocks(byteSource, new int[] { IMAGE_RESOURCE_ID_ICC_PROFILE, }, 1); - if ((blocks == null) || (blocks.size() < 1)) + if ((blocks == null) || (blocks.size() < 1)) { return null; + } ImageResourceBlock irb = blocks.get(0); byte bytes[] = irb.data; - if ((bytes == null) || (bytes.length < 1)) + if ((bytes == null) || (bytes.length < 1)) { return null; + } return bytes; } @@ -453,8 +468,9 @@ public class PsdImageParser extends Imag public Dimension getImageSize(ByteSource byteSource, Map params) throws ImageReadException, IOException { PsdHeaderInfo bhi = readHeader(byteSource); - if (bhi == null) + if (bhi == null) { throw new ImageReadException("PSD: couldn't read header"); + } return new Dimension(bhi.Columns, bhi.Rows); @@ -505,12 +521,14 @@ public class PsdImageParser extends Imag ImageContents imageContents = readImageContents(byteSource); // ImageContents imageContents = readImage(byteSource, false); - if (imageContents == null) + if (imageContents == null) { throw new ImageReadException("PSD: Couldn't read blocks"); + } PsdHeaderInfo header = imageContents.header; - if (header == null) + if (header == null) { throw new ImageReadException("PSD: Couldn't read Header"); + } int Width = header.Columns; int Height = header.Rows; @@ -523,8 +541,9 @@ public class PsdImageParser extends Imag // System.out.println("header.Mode: " + header.Mode); // System.out.println("getChannelsPerMode(header.Mode): " + // getChannelsPerMode(header.Mode)); - if (BitsPerPixel < 0) + if (BitsPerPixel < 0) { BitsPerPixel = 0; + } ImageFormat Format = ImageFormat.IMAGE_FORMAT_PSD; String FormatName = "Photoshop"; String MimeType = "image/x-photoshop"; @@ -571,8 +590,9 @@ public class PsdImageParser extends Imag for (int i = 0; i < blocks.size(); i++) { ImageResourceBlock block = blocks.get(i); - if (block.id == ID) + if (block.id == ID) { return block; + } } return null; } @@ -582,42 +602,38 @@ public class PsdImageParser extends Imag throws ImageReadException, IOException { pw.println("gif.dumpImageFile"); - { - ImageInfo fImageData = getImageInfo(byteSource); - if (fImageData == null) - return false; - - fImageData.toString(pw, ""); + ImageInfo fImageData = getImageInfo(byteSource); + if (fImageData == null) { + return false; } - { - ImageContents imageContents = readImageContents(byteSource); - imageContents.dump(pw); - imageContents.header.dump(pw); + fImageData.toString(pw, ""); + ImageContents imageContents = readImageContents(byteSource); - List blocks = readImageResourceBlocks( - byteSource, - // fImageContents.ImageResources, - null, -1); + imageContents.dump(pw); + imageContents.header.dump(pw); - pw.println("blocks.size(): " + blocks.size()); + List blocks = readImageResourceBlocks( + byteSource, + // fImageContents.ImageResources, + null, -1); - // System.out.println("gif.blocks: " + blocks.blocks.size()); - for (int i = 0; i < blocks.size(); i++) { - ImageResourceBlock block = blocks.get(i); - pw.println("\t" + i + " (" + Integer.toHexString(block.id) - + ", " + "'" - + new String(block.nameData, "ISO-8859-1") - + "' (" - + block.nameData.length - + "), " - // + block.getClass().getName() - // + ", " - + " data: " + block.data.length + " type: '" - + new PsdConstants().getDescription(block.id) + "' " - + ")"); + pw.println("blocks.size(): " + blocks.size()); - } + // System.out.println("gif.blocks: " + blocks.blocks.size()); + for (int i = 0; i < blocks.size(); i++) { + ImageResourceBlock block = blocks.get(i); + pw.println("\t" + i + " (" + Integer.toHexString(block.id) + + ", " + "'" + + new String(block.nameData, "ISO-8859-1") + + "' (" + + block.nameData.length + + "), " + // + block.getClass().getName() + // + ", " + + " data: " + block.data.length + " type: '" + + new PsdConstants().getDescription(block.id) + "' " + + ")"); } @@ -634,12 +650,14 @@ public class PsdImageParser extends Imag ImageContents imageContents = readImageContents(byteSource); // ImageContents imageContents = readImage(byteSource, false); - if (imageContents == null) + if (imageContents == null) { throw new ImageReadException("PSD: Couldn't read blocks"); + } PsdHeaderInfo header = imageContents.header; - if (header == null) + if (header == null) { throw new ImageReadException("PSD: Couldn't read Header"); + } // ImageDescriptor id = (ImageDescriptor) // findBlock(fImageContents.blocks, @@ -721,25 +739,24 @@ public class PsdImageParser extends Imag throw new ImageReadException("Unknown Compression: " + imageContents.Compression); } - { - InputStream is = null; + + InputStream is = null; - try { - is = getInputStream(byteSource, PSD_SECTION_IMAGE_DATA); - fDataReader.readData(is, result, imageContents, this); + try { + is = getInputStream(byteSource, PSD_SECTION_IMAGE_DATA); + fDataReader.readData(is, result, imageContents, this); - fDataReader.dump(); - // is. - // ImageContents imageContents = readImageContents(is); - // return imageContents; - } finally { - try { - if (is != null) - is.close(); - } catch (Exception e) { - Debug.debug(e); + fDataReader.dump(); + // is. + // ImageContents imageContents = readImageContents(is); + // return imageContents; + } finally { + try { + if (is != null) { + is.close(); } - + } catch (Exception e) { + Debug.debug(e); } } @@ -768,36 +785,43 @@ public class PsdImageParser extends Imag ImageContents imageContents = readImageContents(byteSource); - if (imageContents == null) + if (imageContents == null) { throw new ImageReadException("PSD: Couldn't read blocks"); + } PsdHeaderInfo header = imageContents.header; - if (header == null) + if (header == null) { throw new ImageReadException("PSD: Couldn't read Header"); + } List blocks = readImageResourceBlocks(byteSource, new int[] { IMAGE_RESOURCE_ID_XMP, }, -1); - if ((blocks == null) || (blocks.size() < 1)) + if ((blocks == null) || (blocks.size() < 1)) { return null; + } List xmpBlocks = new ArrayList(); if (false) { // TODO: for PSD 7 and later, verify "XMP" name. for (int i = 0; i < blocks.size(); i++) { ImageResourceBlock block = blocks.get(i); - if (!block.getName().equals(BLOCK_NAME_XMP)) + if (!block.getName().equals(BLOCK_NAME_XMP)) { continue; + } xmpBlocks.add(block); } - } else + } else { xmpBlocks.addAll(blocks); + } - if (xmpBlocks.size() < 1) + if (xmpBlocks.size() < 1) { return null; - if (xmpBlocks.size() > 1) + } + if (xmpBlocks.size() > 1) { throw new ImageReadException( "PSD contains more than one XMP block."); + } ImageResourceBlock block = xmpBlocks.get(0); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParser.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParser.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParser.java Thu Sep 27 18:22:37 2012 @@ -31,12 +31,12 @@ public abstract class DataParser { int width = header.Columns; int height = header.Rows; - for (int y = 0; y < height; y++) + for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int rgb = getRGB(data, x, y, imageContents); buffer.setElem(y * width + x, rgb); } - + } } protected abstract int getRGB(int data[][][], int x, int y, Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java Thu Sep 27 18:22:37 2012 @@ -24,10 +24,11 @@ public class DataParserBitmap extends Da protected int getRGB(int data[][][], int x, int y, ImageContents imageContents) { int sample = 0xff & data[0][y][x]; - if (sample == 0) + if (sample == 0) { sample = 255; - else + } else { sample = 0; + } // sample = 255- sample; int alpha = 0xff; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java Thu Sep 27 18:22:37 2012 @@ -47,9 +47,10 @@ public class CompressedDataReader extend // this.setDebug(true); int scanline_count = height * header.Channels; int scanline_bytecounts[] = new int[scanline_count]; - for (int i = 0; i < scanline_count; i++) + for (int i = 0; i < scanline_count; i++) { scanline_bytecounts[i] = bfp.read2Bytes("scanline_bytecount[" + i + "]", is, "PSD: bad Image Data"); + } bfp.setDebug(false); // System.out.println("fImageContents.Compression: " // + imageContents.Compression); @@ -59,7 +60,7 @@ public class CompressedDataReader extend int channel_count = dataParser.getBasicChannelsCount(); int data[][][] = new int[channel_count][height][]; // channels[0] = - for (int channel = 0; channel < channel_count; channel++) + for (int channel = 0; channel < channel_count; channel++) { for (int y = 0; y < height; y++) { int index = channel * height + y; byte packed[] = bfp.readByteArray("scanline", @@ -81,6 +82,7 @@ public class CompressedDataReader extend data[channel][y] = scanline; } + } dataParser.parseData(data, bi, imageContents); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java Thu Sep 27 18:22:37 2012 @@ -46,22 +46,19 @@ public class UncompressedDataReader exte int channel_count = dataParser.getBasicChannelsCount(); int depth = header.Depth; MyBitInputStream mbis = new MyBitInputStream(is, BYTE_ORDER_MSB); - BitsToByteInputStream bbis = new BitsToByteInputStream(mbis, 8); // we - // want - // all - // samples - // to - // be - // bytes + // we want all samples to be bytes + BitsToByteInputStream bbis = new BitsToByteInputStream(mbis, 8); int data[][][] = new int[channel_count][height][width]; - for (int channel = 0; channel < channel_count; channel++) - for (int y = 0; y < height; y++) + for (int channel = 0; channel < channel_count; channel++) { + for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int b = bbis.readBits(depth); data[channel][y][x] = (byte) b; } + } + } dataParser.parseData(data, bi, imageContents); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java Thu Sep 27 18:22:37 2012 @@ -47,14 +47,17 @@ public class TiffContents { for (int j = 0; j < fields.size(); j++) { TiffField field = fields.get(j); TiffElement oversizeValue = field.getOversizeValueElement(); - if (null != oversizeValue) + if (null != oversizeValue) { result.add(oversizeValue); + } } - if (directory.hasTiffImageData()) + if (directory.hasTiffImageData()) { result.addAll(directory.getTiffRawImageDataElements()); - if (directory.hasJpegImageData()) + } + if (directory.hasJpegImageData()) { result.add(directory.getJpegRawImageDataElement()); + } } return result; @@ -65,8 +68,9 @@ public class TiffContents { TiffDirectory directory = directories.get(i); TiffField field = directory.findField(tag); - if (null != field) + if (null != field) { return field; + } } return null; @@ -81,10 +85,12 @@ public class TiffContents { for (int i = 0; i < elements.size(); i++) { TiffElement element = elements.get(i); - if (element.offset > lastEnd) + if (element.offset > lastEnd) { Debug.debug("\t" + "gap: " + (element.offset - lastEnd)); - if (element.offset < lastEnd) + } + if (element.offset < lastEnd) { Debug.debug("\t" + "overlap"); + } Debug.debug("element, start: " + element.offset + ", length: " + element.length + ", end: " @@ -92,8 +98,9 @@ public class TiffContents { + element.getElementDescription(false)); if (verbose) { String verbosity = element.getElementDescription(true); - if (null != verbosity) + if (null != verbosity) { Debug.debug(verbosity); + } } lastEnd = element.offset + element.length; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java Thu Sep 27 18:22:37 2012 @@ -51,8 +51,9 @@ public class TiffDirectory extends TiffE @Override public String getElementDescription(boolean verbose) { - if (!verbose) + if (!verbose) { return "TIFF Directory (" + description() + ")"; + } int entryOffset = offset + TIFF_DIRECTORY_HEADER_LENGTH; @@ -126,18 +127,21 @@ public class TiffDirectory extends TiffE } public boolean hasJpegImageData() throws ImageReadException { - if (null != findField(TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT)) + if (null != findField(TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT)) { return true; + } return false; } public boolean hasTiffImageData() throws ImageReadException { - if (null != findField(TiffTagConstants.TIFF_TAG_TILE_OFFSETS)) + if (null != findField(TiffTagConstants.TIFF_TAG_TILE_OFFSETS)) { return true; + } - if (null != findField(TiffTagConstants.TIFF_TAG_STRIP_OFFSETS)) + if (null != findField(TiffTagConstants.TIFF_TAG_STRIP_OFFSETS)) { return true; + } return false; } @@ -150,8 +154,9 @@ public class TiffDirectory extends TiffE public BufferedImage getTiffImage(int byteOrder, Map params) throws ImageReadException, IOException { - if (null == tiffImageData) + if (null == tiffImageData) { return null; + } return new TiffImageParser().getBufferedImage(this, byteOrder, params); } @@ -163,18 +168,21 @@ public class TiffDirectory extends TiffE public TiffField findField(TagInfo tag, boolean failIfMissing) throws ImageReadException { - if (entries == null) + if (entries == null) { return null; + } for (int i = 0; i < entries.size(); i++) { TiffField field = entries.get(i); - if (field.tag == tag.tag) + if (field.tag == tag.tag) { return field; + } } - if (failIfMissing) + if (failIfMissing) { throw new ImageReadException("Missing expected field: " + tag.getDescription()); + } return null; } @@ -579,8 +587,9 @@ public class TiffDirectory extends TiffE @Override public String getElementDescription(boolean verbose) { - if (verbose) + if (verbose) { return null; + } return "ImageDataElement"; } } @@ -591,9 +600,10 @@ public class TiffDirectory extends TiffE int offsets[] = offsetsField.getIntArrayValue(); int byteCounts[] = byteCountsField.getIntArrayValue(); - if (offsets.length != byteCounts.length) + if (offsets.length != byteCounts.length) { throw new ImageReadException("offsets.length(" + offsets.length + ") != byteCounts.length(" + byteCounts.length + ")"); + } List result = new ArrayList(); for (int i = 0; i < offsets.length; i++) { @@ -613,8 +623,9 @@ public class TiffDirectory extends TiffE return getRawImageDataElements(tileOffsets, tileByteCounts); } else if ((stripOffsets != null) && (stripByteCounts != null)) { return getRawImageDataElements(stripOffsets, stripByteCounts); - } else + } else { throw new ImageReadException("Couldn't find image data."); + } } public boolean imageDataInStrips() throws ImageReadException { @@ -623,14 +634,15 @@ public class TiffDirectory extends TiffE TiffField stripOffsets = findField(TiffTagConstants.TIFF_TAG_STRIP_OFFSETS); TiffField stripByteCounts = findField(TiffTagConstants.TIFF_TAG_STRIP_BYTE_COUNTS); - if ((tileOffsets != null) && (tileByteCounts != null)) + if ((tileOffsets != null) && (tileByteCounts != null)) { return false; - else if ((stripOffsets != null) && (stripByteCounts != null)) + } else if ((stripOffsets != null) && (stripByteCounts != null)) { return true; - else if ((stripOffsets != null) && (stripByteCounts != null)) + } else if ((stripOffsets != null) && (stripByteCounts != null)) { return true; - else + } else { throw new ImageReadException("Couldn't find image data."); + } } public ImageDataElement getJpegRawImageDataElement() @@ -644,8 +656,9 @@ public class TiffDirectory extends TiffE int byteCount = jpegInterchangeFormatLength.getIntArrayValue()[0]; return new ImageDataElement(offset, byteCount); - } else + } else { throw new ImageReadException("Couldn't find image data."); + } } private TiffImageData tiffImageData = null; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java Thu Sep 27 18:22:37 2012 @@ -84,8 +84,9 @@ public class TiffField implements TiffCo @Override public String getElementDescription(boolean verbose) { - if (verbose) + if (verbose) { return null; + } return "OversizeValueElement, tag: " + tagInfo.name + ", fieldType: " + fieldType.name; @@ -93,8 +94,9 @@ public class TiffField implements TiffCo } public TiffElement getOversizeValueElement() { - if (fieldType.isLocalValue(this)) + if (fieldType.isLocalValue(this)) { return null; + } return new OversizeValueElement(valueOffset, oversizeValue.length); } @@ -106,8 +108,9 @@ public class TiffField implements TiffCo private static FieldType getFieldType(int value) { for (int i = 0; i < FIELD_TYPES.size(); i++) { FieldType fieldType = FIELD_TYPES.get(i); - if (fieldType.type == value) + if (fieldType.type == value) { return fieldType; + } } return FIELD_TYPE_UNKNOWN; @@ -117,8 +120,9 @@ public class TiffField implements TiffCo List possibleMatches) { // Please keep this method in sync with TiffImageMetadata's findField() - if (possibleMatches.size() < 1) + if (possibleMatches.size() < 1) { return null; + } // else if (possibleMatches.size() == 1) // { // TagInfo tagInfo = (TagInfo) possibleMatches.get(0); @@ -128,34 +132,37 @@ public class TiffField implements TiffCo // first search for exact match. for (int i = 0; i < possibleMatches.size(); i++) { TagInfo tagInfo = possibleMatches.get(i); - if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) + if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) { // pass continue; - else if (directoryType == tagInfo.directoryType.directoryType) + } else if (directoryType == tagInfo.directoryType.directoryType) { return tagInfo; + } } // accept an inexact match. for (int i = 0; i < possibleMatches.size(); i++) { TagInfo tagInfo = possibleMatches.get(i); - if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) + if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) { // pass continue; - else if (directoryType >= 0 - && tagInfo.directoryType.isImageDirectory()) + } else if (directoryType >= 0 + && tagInfo.directoryType.isImageDirectory()) { return tagInfo; - else if (directoryType < 0 - && !tagInfo.directoryType.isImageDirectory()) + } else if (directoryType < 0 + && !tagInfo.directoryType.isImageDirectory()) { return tagInfo; + } } // accept a wildcard match. for (int i = 0; i < possibleMatches.size(); i++) { TagInfo tagInfo = possibleMatches.get(i); - if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) + if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) { return tagInfo; + } } // // accept a very rough match. @@ -262,8 +269,9 @@ public class TiffField implements TiffCo public void fillInValue(ByteSource byteSource) throws IOException, TiffValueOutsideFileBoundsException { - if (fieldType.isLocalValue(this)) + if (fieldType.isLocalValue(this)) { return; + } int valueLength = getValueLengthInBytes(); long valueLengthLong = 0xffffffffL & valueLength; @@ -294,8 +302,9 @@ public class TiffField implements TiffCo } private String getValueDescription(Object o) { - if (o == null) + if (o == null) { return null; + } if (o instanceof Number) { return o.toString(); @@ -315,13 +324,13 @@ public class TiffField implements TiffCo result.append("... (" + objects.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + object); } return result.toString(); - } - // else if (o instanceof Number[]) + // } else if (o instanceof Number[]) // { // Number numbers[] = (Number[]) o; // StringBuffer result = new StringBuffer(); @@ -336,7 +345,7 @@ public class TiffField implements TiffCo // } // return result.toString(); // } - else if (o instanceof short[]) { + } else if (o instanceof short[]) { short values[] = (short[]) o; StringBuffer result = new StringBuffer(); @@ -347,8 +356,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -363,8 +373,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -379,8 +390,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -395,8 +407,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -411,8 +424,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -427,8 +441,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -443,8 +458,9 @@ public class TiffField implements TiffCo result.append("... (" + values.length + ")"); break; } - if (i > 0) + if (i > 0) { result.append(", "); + } result.append("" + value); } return result.toString(); @@ -479,8 +495,9 @@ public class TiffField implements TiffCo } public void dump(PrintWriter pw, String prefix) { - if (prefix != null) + if (prefix != null) { pw.print(prefix + ": "); + } pw.println(toString()); pw.flush(); @@ -517,8 +534,9 @@ public class TiffField implements TiffCo } public String getTagName() { - if (tagInfo == TiffTagConstants.TIFF_TAG_UNKNOWN) + if (tagInfo == TiffTagConstants.TIFF_TAG_UNKNOWN) { return tagInfo.name + " (0x" + Integer.toHexString(tag) + ")"; + } return tagInfo.name; } @@ -535,11 +553,13 @@ public class TiffField implements TiffCo public String getStringValue() throws ImageReadException { Object o = getValue(); - if (o == null) + if (o == null) { return null; - if (!(o instanceof String)) + } + if (!(o instanceof String)) { throw new ImageReadException("Expected String value(" + tagInfo.getDescription() + "): " + o); + } return (String) o; } @@ -614,25 +634,28 @@ public class TiffField implements TiffCo // if (o == null) // return null; - if (o instanceof Number) + if (o instanceof Number) { return new int[] { ((Number) o).intValue() }; - else if (o instanceof Number[]) { + } else if (o instanceof Number[]) { Number numbers[] = (Number[]) o; int result[] = new int[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i].intValue(); + } return result; } else if (o instanceof short[]) { short numbers[] = (short[]) o; int result[] = new int[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = 0xffff & numbers[i]; + } return result; } else if (o instanceof int[]) { int numbers[] = (int[]) o; int result[] = new int[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i]; + } return result; } @@ -651,32 +674,37 @@ public class TiffField implements TiffCo } else if (o instanceof Number[]) { Number numbers[] = (Number[]) o; double result[] = new double[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i].doubleValue(); + } return result; } else if (o instanceof short[]) { short numbers[] = (short[]) o; double result[] = new double[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i]; + } return result; } else if (o instanceof int[]) { int numbers[] = (int[]) o; double result[] = new double[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i]; + } return result; } else if (o instanceof float[]) { float numbers[] = (float[]) o; double result[] = new double[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i]; + } return result; } else if (o instanceof double[]) { double numbers[] = (double[]) o; double result[] = new double[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { result[i] = numbers[i]; + } return result; } @@ -690,25 +718,28 @@ public class TiffField implements TiffCo // if (o == null) // return -1; - if (o instanceof Number) + if (o instanceof Number) { return ((Number) o).intValue(); - else if (o instanceof Number[]) { + } else if (o instanceof Number[]) { Number numbers[] = (Number[]) o; int sum = 0; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { sum += numbers[i].intValue(); + } return sum; } else if (o instanceof short[]) { short[] numbers = (short[]) o; int sum = 0; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { sum += numbers[i]; + } return sum; } else if (o instanceof int[]) { int numbers[] = (int[]) o; int sum = 0; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { sum += numbers[i]; + } return sum; } @@ -719,18 +750,20 @@ public class TiffField implements TiffCo public int getIntValue() throws ImageReadException { Object o = getValue(); - if (o == null) + if (o == null) { throw new ImageReadException("Missing value: " + tagInfo.getDescription()); + } return ((Number) o).intValue(); } public double getDoubleValue() throws ImageReadException { Object o = getValue(); - if (o == null) + if (o == null) { throw new ImageReadException("Missing value: " + tagInfo.getDescription()); + } return ((Number) o).doubleValue(); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffHeader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffHeader.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffHeader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffHeader.java Thu Sep 27 18:22:37 2012 @@ -33,8 +33,9 @@ public class TiffHeader extends TiffElem @Override public String getElementDescription(boolean verbose) { - if (verbose) + if (verbose) { return null; + } return "TIFF Header"; } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java Thu Sep 27 18:22:37 2012 @@ -66,10 +66,11 @@ public class TiffImageMetadata extends I TagInfo tag = tags.get(i); Integer count = map.get(tag.tag); - if (count == null) + if (count == null) { map.put(tag.tag, 1); - else + } else { map.put(tag.tag, count + 1); + } } return map; @@ -451,8 +452,9 @@ public class TiffImageMetadata extends I List directories = getDirectories(); for (int i = 0; i < directories.size(); i++) { Directory directory = (Directory) directories.get(i); - if (directory.type == directoryType) + if (directory.type == directoryType) { return directory.directory; + } } return null; } @@ -469,8 +471,9 @@ public class TiffImageMetadata extends I public GPSInfo getGPS() throws ImageReadException { TiffDirectory gpsDirectory = findDirectory(DIRECTORY_TYPE_GPS); - if (null == gpsDirectory) + if (null == gpsDirectory) { return null; + } // more specific example of how to access GPS values. TiffField latitudeRefField = gpsDirectory @@ -483,8 +486,9 @@ public class TiffImageMetadata extends I .findField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); if (latitudeRefField == null || latitudeField == null - || longitudeRefField == null || longitudeField == null) + || longitudeRefField == null || longitudeField == null) { return null; + } // all of these values are strings. String latitudeRef = latitudeRefField.getStringValue(); @@ -493,9 +497,10 @@ public class TiffImageMetadata extends I RationalNumber longitude[] = (RationalNumber[]) longitudeField .getValue(); - if (latitude.length != 3 || longitude.length != 3) + if (latitude.length != 3 || longitude.length != 3) { throw new ImageReadException( "Expected three values for latitude and longitude."); + } RationalNumber latitudeDegrees = latitude[0]; RationalNumber latitudeMinutes = latitude[1]; @@ -565,13 +570,14 @@ public class TiffImageMetadata extends I + (longitudeMinutes.doubleValue() / 60.0) + (longitudeSeconds.doubleValue() / 3600.0); - if (longitudeRef.trim().equalsIgnoreCase("e")) + if (longitudeRef.trim().equalsIgnoreCase("e")) { return result; - else if (longitudeRef.trim().equalsIgnoreCase("w")) + } else if (longitudeRef.trim().equalsIgnoreCase("w")) { return -result; - else + } else { throw new ImageReadException("Unknown longitude ref: \"" + longitudeRef + "\""); + } } public double getLatitudeAsDegreesNorth() throws ImageReadException { @@ -579,13 +585,14 @@ public class TiffImageMetadata extends I + (latitudeMinutes.doubleValue() / 60.0) + (latitudeSeconds.doubleValue() / 3600.0); - if (latitudeRef.trim().equalsIgnoreCase("n")) + if (latitudeRef.trim().equalsIgnoreCase("n")) { return result; - else if (latitudeRef.trim().equalsIgnoreCase("s")) + } else if (latitudeRef.trim().equalsIgnoreCase("s")) { return -result; - else + } else { throw new ImageReadException("Unknown latitude ref: \"" + latitudeRef + "\""); + } } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java Thu Sep 27 18:22:37 2012 @@ -106,8 +106,9 @@ public class TiffImageParser extends Ima TiffField heightField = directory.findField( TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true); - if ((widthField == null) || (heightField == null)) + if ((widthField == null) || (heightField == null)) { throw new ImageReadException("TIFF image missing size info."); + } int height = heightField.getIntValue(); int width = widthField.getIntValue(); @@ -168,8 +169,9 @@ public class TiffImageParser extends Ima TiffField heightField = directory.findField( TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true); - if ((widthField == null) || (heightField == null)) + if ((widthField == null) || (heightField == null)) { throw new ImageReadException("TIFF image missing size info."); + } int height = heightField.getIntValue(); int width = widthField.getIntValue(); @@ -180,8 +182,9 @@ public class TiffImageParser extends Ima .findField(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT); int resolutionUnit = 2; // Inch if ((resolutionUnitField != null) - && (resolutionUnitField.getValue() != null)) + && (resolutionUnitField.getValue() != null)) { resolutionUnit = resolutionUnitField.getIntValue(); + } double unitsPerInch = -1; switch (resolutionUnit) { @@ -233,8 +236,9 @@ public class TiffImageParser extends Ima int bitsPerSample = 1; if ((bitsPerSampleField != null) - && (bitsPerSampleField.getValue() != null)) + && (bitsPerSampleField.getValue() != null)) { bitsPerSample = bitsPerSampleField.getIntValueOrArraySum(); + } int bitsPerPixel = bitsPerSample; // assume grayscale; // dunno if this handles colormapped images correctly. @@ -263,8 +267,9 @@ public class TiffImageParser extends Ima boolean usesPalette = false; TiffField colorMapField = directory .findField(TiffTagConstants.TIFF_TAG_COLOR_MAP); - if (colorMapField != null) + if (colorMapField != null) { usesPalette = true; + } int colorType = ImageInfo.COLOR_TYPE_RGB; @@ -342,8 +347,9 @@ public class TiffImageParser extends Ima { ImageInfo imageData = getImageInfo(byteSource); - if (imageData == null) + if (imageData == null) { return false; + } imageData.toString(pw, ""); } @@ -360,16 +366,18 @@ public class TiffImageParser extends Ima List directories = contents.directories; - if (directories == null) + if (directories == null) { return false; + } for (int d = 0; d < directories.size(); d++) { TiffDirectory directory = directories.get(d); List entries = directory.entries; - if (entries == null) + if (entries == null) { return false; + } // Debug.debug("directory offset", directory.offset); @@ -436,8 +444,9 @@ public class TiffImageParser extends Ima int byteOrder = reader.getByteOrder(); TiffDirectory directory = contents.directories.get(0); BufferedImage result = directory.getTiffImage(byteOrder, params); - if (null == result) + if (null == result) { throw new ImageReadException("TIFF does not contain an image."); + } return result; } @@ -464,8 +473,9 @@ public class TiffImageParser extends Ima int byteOrder, Map params) throws ImageReadException, IOException { List entries = directory.entries; - if (entries == null) + if (entries == null) { throw new ImageReadException("TIFF missing entries"); + } int photometricInterpretation = 0xffff & directory .getSingleFieldValue(TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION); @@ -478,8 +488,9 @@ public class TiffImageParser extends Ima int samplesPerPixel = 1; TiffField samplesPerPixelField = directory .findField(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL); - if (samplesPerPixelField != null) + if (samplesPerPixelField != null) { samplesPerPixel = samplesPerPixelField.getIntValue(); + } int bitsPerSample[] = { 1 }; int bitsPerPixel = samplesPerPixel; TiffField bitsPerSampleField = directory @@ -501,14 +512,16 @@ public class TiffImageParser extends Ima // dumpOptionalNumberTag(entries, TIFF_TAG_PLANAR_CONFIGURATION); TiffField predictorField = directory .findField(TiffTagConstants.TIFF_TAG_PREDICTOR); - if (null != predictorField) + if (null != predictorField) { predictor = predictorField.getIntValueOrArraySum(); + } } - if (samplesPerPixel != bitsPerSample.length) + if (samplesPerPixel != bitsPerSample.length) { throw new ImageReadException("Tiff: samplesPerPixel (" + samplesPerPixel + ")!=fBitsPerSample.length (" + bitsPerSample.length + ")"); + } boolean hasAlpha = false; ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha); @@ -551,10 +564,11 @@ public class TiffImageParser extends Ima int expected_colormap_size = 3 * (1 << bitsPerPixel); - if (colorMap.length != expected_colormap_size) + if (colorMap.length != expected_colormap_size) { throw new ImageReadException("Tiff: fColorMap.length (" + colorMap.length + ")!=expected_colormap_size (" + expected_colormap_size + ")"); + } return new PhotometricInterpreterPalette(samplesPerPixel, bitsPerSample, predictor, width, height, colorMap); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Thu Sep 27 18:22:37 2012 @@ -50,8 +50,9 @@ public class TiffReader extends BinaryFi return readTiffHeader(is, formatCompliance); } finally { try { - if (is != null) + if (is != null) { is.close(); + } } catch (Exception e) { Debug.debug(e); } @@ -66,8 +67,9 @@ public class TiffReader extends BinaryFi setByteOrder(BYTE_ORDER_1, BYTE_ORDER_2); int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid TIFF File"); - if (tiffVersion != 42) + if (tiffVersion != 42) { throw new ImageReadException("Unknown Tiff Version: " + tiffVersion); + } int offsetToFirstIFD = read4Bytes("offsetToFirstIFD", is, "Not a Valid TIFF File"); @@ -75,8 +77,9 @@ public class TiffReader extends BinaryFi skipBytes(is, offsetToFirstIFD - 8, "Not a Valid TIFF File: couldn't find IFDs"); - if (debug) + if (debug) { System.out.println(""); + } return new TiffHeader(BYTE_ORDER_1, tiffVersion, offsetToFirstIFD); } @@ -85,8 +88,9 @@ public class TiffReader extends BinaryFi FormatCompliance formatCompliance, Listener listener) throws ImageReadException, IOException { TiffHeader tiffHeader = readTiffHeader(byteSource, formatCompliance); - if (!listener.setTiffHeader(tiffHeader)) + if (!listener.setTiffHeader(tiffHeader)) { return; + } int offset = tiffHeader.offsetToFirstIFD; int dirType = TiffDirectory.DIRECTORY_TYPE_ROOT; @@ -118,8 +122,9 @@ public class TiffReader extends BinaryFi // Debug.debug("dirType", dirType); // Debug.debug(); - if (visited.contains(offset)) + if (visited.contains(offset)) { return false; + } visited.add(offset); InputStream is = null; @@ -139,10 +144,11 @@ public class TiffReader extends BinaryFi entryCount = read2Bytes("DirectoryEntryCount", is, "Not a Valid TIFF File"); } catch (IOException e) { - if (strict) + if (strict) { throw e; - else + } else { return true; + } } // Debug.debug("entryCount", entryCount); @@ -195,8 +201,9 @@ public class TiffReader extends BinaryFi fields.add(field); - if (!listener.addField(field)) + if (!listener.addField(field)) { return true; + } } int nextDirectoryOffset = read4Bytes("nextDirectoryOffset", is, @@ -219,8 +226,9 @@ public class TiffReader extends BinaryFi } } - if (!listener.addDirectory(directory)) + if (!listener.addDirectory(directory)) { return true; + } if (listener.readOffsetDirectories()) { List fieldsToRemove = new ArrayList(); @@ -233,21 +241,23 @@ public class TiffReader extends BinaryFi * do * nothing */ - } else + } else { continue; + } int subDirectoryOffset = ((Number) entry.getValue()) .intValue(); int subDirectoryType; - if (entry.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag) + if (entry.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag) { subDirectoryType = TiffDirectory.DIRECTORY_TYPE_EXIF; - else if (entry.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag) + } else if (entry.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag) { subDirectoryType = TiffDirectory.DIRECTORY_TYPE_GPS; - else if (entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) + } else if (entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) { subDirectoryType = TiffDirectory.DIRECTORY_TYPE_INTEROPERABILITY; - else + } else { throw new ImageReadException( "Unknown subdirectory type."); + } // Debug.debug("sub dir", subDirectoryOffset); boolean subDirectoryRead = readDirectory(byteSource, @@ -274,8 +284,9 @@ public class TiffReader extends BinaryFi return true; } finally { try { - if (is != null) + if (is != null) { is.close(); + } } catch (Exception e) { Debug.debug(e); } @@ -306,9 +317,10 @@ public class TiffReader extends BinaryFi public Collector(Map params) { boolean readThumbnails = true; - if (params != null && params.containsKey(PARAM_KEY_READ_THUMBNAILS)) + if (params != null && params.containsKey(PARAM_KEY_READ_THUMBNAILS)) { readThumbnails = Boolean.TRUE.equals(params .get(PARAM_KEY_READ_THUMBNAILS)); + } this.readThumbnails = readThumbnails; } @@ -384,9 +396,10 @@ public class TiffReader extends BinaryFi Collector collector = new FirstDirectoryCollector(readImageData); read(byteSource, params, formatCompliance, collector); TiffContents contents = collector.getContents(); - if (contents.directories.size() < 1) + if (contents.directories.size() < 1) { throw new ImageReadException( "Image did not contain any directories."); + } return contents; } @@ -396,9 +409,10 @@ public class TiffReader extends BinaryFi Collector collector = new Collector(null); readDirectories(byteSource, formatCompliance, collector); TiffContents contents = collector.getContents(); - if (contents.directories.size() < 1) + if (contents.directories.size() < 1) { throw new ImageReadException( "Image did not contain any directories."); + } return contents; } @@ -464,14 +478,16 @@ public class TiffReader extends BinaryFi } else { TiffField tileWidthField = directory .findField(TiffTagConstants.TIFF_TAG_TILE_WIDTH); - if (null == tileWidthField) + if (null == tileWidthField) { throw new ImageReadException("Can't find tile width field."); + } int tileWidth = tileWidthField.getIntValue(); TiffField tileLengthField = directory .findField(TiffTagConstants.TIFF_TAG_TILE_LENGTH); - if (null == tileLengthField) + if (null == tileLengthField) { throw new ImageReadException("Can't find tile length field."); + } int tileLength = tileLengthField.getIntValue(); return new TiffImageData.Tiles(data, tileWidth, tileLength); @@ -484,8 +500,9 @@ public class TiffReader extends BinaryFi int offset = element.offset; int length = element.length; // Sony DCR-PC110 has an off-by-one error. - if (offset + length == byteSource.getLength() + 1) + if (offset + length == byteSource.getLength() + 1) { length--; + } byte data[] = byteSource.getBlock(offset, length); return new JpegImageData(offset, length, data); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java Thu Sep 27 18:22:37 2012 @@ -45,9 +45,11 @@ public class TagConstantsUtils implement public static TiffDirectoryType getExifDirectoryType(int type) { - for (int i = 0; i < tiffDirectoryTypes.length; i++) - if (tiffDirectoryTypes[i].directoryType == type) + for (int i = 0; i < tiffDirectoryTypes.length; i++) { + if (tiffDirectoryTypes[i].directoryType == type) { return tiffDirectoryTypes[i]; + } + } return TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN; } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java Thu Sep 27 18:22:37 2012 @@ -79,8 +79,9 @@ public abstract class DataReader impleme if (bits < 8) { int sign = sample & 1; sample = sample << (8 - bits); // scale to byte. - if (sign > 0) + if (sign > 0) { sample = sample | ((1 << (8 - bits)) - 1); // extend to byte + } } else if (bits > 8) { sample = sample >> (bits - 8); // extend to byte. } @@ -95,8 +96,8 @@ public abstract class DataReader impleme } protected int[] applyPredictor(int samples[]) { - if (predictor == 2) // Horizontal differencing. - { + if (predictor == 2) { + // Horizontal differencing. for (int i = 0; i < samples.length; i++) { samples[i] = 0xff & (samples[i] + last[i]); last[i] = samples[i]; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java Thu Sep 27 18:22:37 2012 @@ -187,8 +187,9 @@ public final class DataReaderStrips exte resetPredictor(); y++; bis.flushCache(); - if (y >= height) + if (y >= height) { break; + } } } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java Thu Sep 27 18:22:37 2012 @@ -147,8 +147,9 @@ public final class DataReaderTiled exten resetPredictor(); tileY++; bis.flushCache(); - if (tileY >= tileLength) + if (tileY >= tileLength) { break; + } } } @@ -174,8 +175,9 @@ public final class DataReaderTiled exten if (x >= width) { x = 0; y += tileLength; - if (y >= height) + if (y >= height) { break; + } } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java Thu Sep 27 18:22:37 2012 @@ -43,8 +43,9 @@ public abstract class FieldType extends } public int getBytesLength(TiffField entry) throws ImageReadException { - if (length < 1) + if (length < 1) { throw new ImageReadException("Unknown field type"); + } return length * entry.length; } @@ -62,8 +63,9 @@ public abstract class FieldType extends public String getDisplayValue(TiffField entry) throws ImageReadException { Object o = getSimpleValue(entry); - if (o == null) + if (o == null) { return "NULL"; + } return o.toString(); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java?rev=1391156&r1=1391155&r2=1391156&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java Thu Sep 27 18:22:37 2012 @@ -115,8 +115,9 @@ public class FieldTypeAscii extends Fiel position += (bytes.length + 1); } return result; - } else + } else { throw new ImageWriteException("Unknown data type: " + o); + } } }