You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/12/04 18:24:32 UTC
svn commit: r1417043 [11/21] - in /commons/proper/imaging/trunk/src:
main/java/org/apache/commons/imaging/
main/java/org/apache/commons/imaging/color/
main/java/org/apache/commons/imaging/common/
main/java/org/apache/commons/imaging/common/bytesource/ ...
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -23,12 +23,12 @@ import org.apache.commons.imaging.ImageR
public class ScanlineFilterUp extends ScanlineFilter {
private final int BytesPerPixel;
- public ScanlineFilterUp(int BytesPerPixel) {
+ public ScanlineFilterUp(final int BytesPerPixel) {
this.BytesPerPixel = BytesPerPixel;
}
@Override
- public void unfilter(byte src[], byte dst[], byte up[])
+ public void unfilter(final byte src[], final byte dst[], final byte up[])
throws ImageReadException, IOException {
for (int i = 0; i < src.length; i++) {
// byte b;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilter.java Tue Dec 4 17:23:16 2012
@@ -24,7 +24,7 @@ import org.apache.commons.imaging.common
public abstract class TransparencyFilter extends BinaryFileParser {
protected final byte bytes[];
- public TransparencyFilter(byte bytes[]) {
+ public TransparencyFilter(final byte bytes[]) {
this.bytes = bytes;
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterGrayscale.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterGrayscale.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterGrayscale.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterGrayscale.java Tue Dec 4 17:23:16 2012
@@ -24,17 +24,17 @@ import org.apache.commons.imaging.ImageR
public class TransparencyFilterGrayscale extends TransparencyFilter {
private final int transparent_color;
- public TransparencyFilterGrayscale(byte bytes[]) throws ImageReadException,
+ public TransparencyFilterGrayscale(final byte bytes[]) throws ImageReadException,
IOException {
super(bytes);
- ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+ final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
transparent_color = read2Bytes("transparent_color", is,
"tRNS: Missing transparent_color");
}
@Override
- public int filter(int rgb, int index) throws ImageReadException,
+ public int filter(final int rgb, final int index) throws ImageReadException,
IOException {
if (index != transparent_color) {
return rgb;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java Tue Dec 4 17:23:16 2012
@@ -22,14 +22,14 @@ import org.apache.commons.imaging.ImageR
public class TransparencyFilterIndexedColor extends TransparencyFilter {
- public TransparencyFilterIndexedColor(byte bytes[]) {
+ public TransparencyFilterIndexedColor(final byte bytes[]) {
super(bytes);
}
int count = 0;
@Override
- public int filter(int rgb, int index) throws ImageReadException,
+ public int filter(final int rgb, final int index) throws ImageReadException,
IOException {
if (index >= bytes.length) {
return rgb;
@@ -41,8 +41,8 @@ public class TransparencyFilterIndexedCo
+ ", bytes.length: " + bytes.length);
}
- int alpha = bytes[index];
- int result = ((0xff & alpha) << 24) | (0x00ffffff & rgb);
+ final int alpha = bytes[index];
+ final int result = ((0xff & alpha) << 24) | (0x00ffffff & rgb);
if ((count < 100) && (index > 0)) {
count++;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterTrueColor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterTrueColor.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterTrueColor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterTrueColor.java Tue Dec 4 17:23:16 2012
@@ -27,11 +27,11 @@ public class TransparencyFilterTrueColor
private final int transparent_blue;
private final int transparent_color;
- public TransparencyFilterTrueColor(byte bytes[]) throws ImageReadException,
+ public TransparencyFilterTrueColor(final byte bytes[]) throws ImageReadException,
IOException {
super(bytes);
- ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+ final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
transparent_red = read2Bytes("transparent_red", is,
"tRNS: Missing transparent_color");
transparent_green = read2Bytes("transparent_green", is,
@@ -46,7 +46,7 @@ public class TransparencyFilterTrueColor
}
@Override
- public int filter(int rgb, int sample) throws ImageReadException,
+ public int filter(final int rgb, final int sample) throws ImageReadException,
IOException {
if ((0x00ffffff & rgb) == transparent_color) {
return 0x00;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/FileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/FileInfo.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/FileInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/FileInfo.java Tue Dec 4 17:23:16 2012
@@ -26,7 +26,7 @@ public abstract class FileInfo {
protected final int width, height;
protected final boolean RAWBITS;
- public FileInfo(int width, int height, boolean RAWBITS) {
+ public FileInfo(final int width, final int height, final boolean RAWBITS) {
this.width = width;
this.height = height;
this.RAWBITS = RAWBITS;
@@ -54,10 +54,10 @@ public abstract class FileInfo {
// do nothing by default.
}
- protected static int readSample(InputStream is, int bytesPerSample) throws IOException {
+ protected static int readSample(final InputStream is, final int bytesPerSample) throws IOException {
int sample = 0;
for (int i = 0; i < bytesPerSample; i++) {
- int nextByte = is.read();
+ final int nextByte = is.read();
if (nextByte < 0) {
throw new IOException("PNM: Unexpected EOF");
}
@@ -67,7 +67,7 @@ public abstract class FileInfo {
return sample;
}
- protected static int scaleSample(int sample, float scale, int max) throws IOException {
+ protected static int scaleSample(int sample, final float scale, final int max) throws IOException {
if (sample < 0) {
// Even netpbm tools break for files like this
throw new IOException("Negative pixel values are invalid in PNM files");
@@ -78,7 +78,7 @@ public abstract class FileInfo {
return (int)((sample * scale / max) + 0.5f);
}
- public void readImage(ImageBuilder imageBuilder, InputStream is)
+ public void readImage(final ImageBuilder imageBuilder, final InputStream is)
throws IOException {
// is = new BufferedInputStream(is);
// int count = 0;
@@ -87,11 +87,11 @@ public abstract class FileInfo {
// {
if (!RAWBITS) {
- WhiteSpaceReader wsr = new WhiteSpaceReader(is);
+ final WhiteSpaceReader wsr = new WhiteSpaceReader(is);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- int rgb = getRGB(wsr);
+ final int rgb = getRGB(wsr);
imageBuilder.setRGB(x, y, rgb);
// count++;
@@ -102,7 +102,7 @@ public abstract class FileInfo {
for (int y = 0; y < height; y++) {
// System.out.println("y: " + y);
for (int x = 0; x < width; x++) {
- int rgb = getRGB(is);
+ final int rgb = getRGB(is);
imageBuilder.setRGB(x, y, rgb);
// count++;
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java Tue Dec 4 17:23:16 2012
@@ -32,7 +32,7 @@ public class PamFileInfo extends FileInf
private final boolean hasAlpha;
private final TupleReader tupleReader;
- PamFileInfo(int width, int height, int depth, int maxval, String tupleType) throws ImageReadException {
+ PamFileInfo(final int width, final int height, final int depth, final int maxval, final String tupleType) throws ImageReadException {
super(width, height, true);
this.depth = depth;
this.maxval = maxval;
@@ -98,12 +98,12 @@ public class PamFileInfo extends FileInf
}
@Override
- public int getRGB(WhiteSpaceReader wsr) throws IOException {
+ public int getRGB(final WhiteSpaceReader wsr) throws IOException {
throw new UnsupportedOperationException("PAM files are only ever binary");
}
@Override
- public int getRGB(InputStream is) throws IOException {
+ public int getRGB(final InputStream is) throws IOException {
return tupleReader.getRGB(is);
}
@@ -115,7 +115,7 @@ public class PamFileInfo extends FileInf
private class GrayscaleTupleReader extends TupleReader {
private final int colorType;
- public GrayscaleTupleReader(int colorType) {
+ public GrayscaleTupleReader(final int colorType) {
this.colorType = colorType;
}
@@ -125,7 +125,7 @@ public class PamFileInfo extends FileInf
}
@Override
- public int getRGB(InputStream is) throws IOException {
+ public int getRGB(final InputStream is) throws IOException {
int sample = readSample(is, bytesPerSample);
sample = scaleSample(sample, scale, maxval);
@@ -135,7 +135,7 @@ public class PamFileInfo extends FileInf
alpha = scaleSample(alpha, scale, maxval);
}
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
| ((0xff & sample) << 8) | ((0xff & sample) << 0);
return rgb;
@@ -149,7 +149,7 @@ public class PamFileInfo extends FileInf
}
@Override
- public int getRGB(InputStream is) throws IOException {
+ public int getRGB(final InputStream is) throws IOException {
int red = readSample(is, bytesPerSample);
int green = readSample(is, bytesPerSample);
int blue = readSample(is, bytesPerSample);
@@ -164,7 +164,7 @@ public class PamFileInfo extends FileInf
alpha = scaleSample(alpha, scale, maxval);
}
- int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
| ((0xff & green) << 8) | ((0xff & blue) << 0);
return rgb;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamWriter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamWriter.java Tue Dec 4 17:23:16 2012
@@ -30,15 +30,15 @@ public class PamWriter extends PnmWriter
}
@Override
- public void writeImage(BufferedImage src, OutputStream os,
- Map<String, Object> params) throws ImageWriteException, IOException {
+ public void writeImage(final BufferedImage src, final OutputStream os,
+ final Map<String, Object> params) throws ImageWriteException, IOException {
os.write(PNM_PREFIX_BYTE);
os.write(PAM_RAW_CODE);
os.write(PNM_NEWLINE);
- int width = src.getWidth();
- int height = src.getHeight();
+ final int width = src.getWidth();
+ final int height = src.getHeight();
os.write(("WIDTH " + width).getBytes("US-ASCII"));
os.write(PNM_NEWLINE);
@@ -60,11 +60,11 @@ public class PamWriter extends PnmWriter
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- int argb = src.getRGB(x, y);
- int alpha = 0xff & (argb >> 24);
- int red = 0xff & (argb >> 16);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
+ final int argb = src.getRGB(x, y);
+ final int alpha = 0xff & (argb >> 24);
+ final int red = 0xff & (argb >> 16);
+ final int green = 0xff & (argb >> 8);
+ final int blue = 0xff & (argb >> 0);
os.write((byte) red);
os.write((byte) green);
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -23,7 +23,7 @@ import org.apache.commons.imaging.ImageF
import org.apache.commons.imaging.ImageInfo;
public class PbmFileInfo extends FileInfo {
- public PbmFileInfo(int width, int height, boolean RAWBITS) {
+ public PbmFileInfo(final int width, final int height, final boolean RAWBITS) {
super(width, height, RAWBITS);
}
@@ -72,9 +72,9 @@ public class PbmFileInfo extends FileInf
private int bits_in_cache = 0;
@Override
- public int getRGB(InputStream is) throws IOException {
+ public int getRGB(final InputStream is) throws IOException {
if (bits_in_cache < 1) {
- int bits = is.read();
+ final int bits = is.read();
if (bits < 0) {
throw new IOException("PBM: Unexpected EOF");
}
@@ -82,7 +82,7 @@ public class PbmFileInfo extends FileInf
bits_in_cache += 8;
}
- int bit = 0x1 & (bitcache >> 7);
+ final int bit = 0x1 & (bitcache >> 7);
bitcache <<= 1;
bits_in_cache--;
@@ -96,8 +96,8 @@ public class PbmFileInfo extends FileInf
}
@Override
- public int getRGB(WhiteSpaceReader wsr) throws IOException {
- int bit = Integer.parseInt(wsr.readtoWhiteSpace());
+ public int getRGB(final WhiteSpaceReader wsr) throws IOException {
+ final int bit = Integer.parseInt(wsr.readtoWhiteSpace());
if (bit == 0) {
return 0xff000000;
}
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -24,19 +24,19 @@ import java.util.Map;
import org.apache.commons.imaging.ImageWriteException;
public class PbmWriter extends PnmWriter implements PnmConstants {
- public PbmWriter(boolean RAWBITS) {
+ public PbmWriter(final boolean RAWBITS) {
super(RAWBITS);
}
@Override
- public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+ public void writeImage(final BufferedImage src, final OutputStream os, final Map<String,Object> params)
throws ImageWriteException, IOException {
os.write(PNM_PREFIX_BYTE);
os.write(RAWBITS ? PBM_RAW_CODE : PBM_TEXT_CODE);
os.write(PNM_SEPARATOR);
- int width = src.getWidth();
- int height = src.getHeight();
+ final int width = src.getWidth();
+ final int height = src.getHeight();
os.write(("" + width).getBytes("US-ASCII"));
os.write(PNM_SEPARATOR);
@@ -49,10 +49,10 @@ public class PbmWriter extends PnmWriter
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);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
+ final int argb = src.getRGB(x, y);
+ final int red = 0xff & (argb >> 16);
+ final int green = 0xff & (argb >> 8);
+ final int blue = 0xff & (argb >> 0);
int sample = (red + green + blue) / 3;
if (sample > 127) {
sample = 0;
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -28,7 +28,7 @@ public class PgmFileInfo extends FileInf
private final float scale;
private final int bytesPerSample;
- public PgmFileInfo(int width, int height, boolean RAWBITS, int max) throws ImageReadException {
+ public PgmFileInfo(final int width, final int height, final boolean RAWBITS, final int max) throws ImageReadException {
super(width, height, RAWBITS);
if (max <= 0) {
throw new ImageReadException("PGM maxVal " + max
@@ -82,28 +82,28 @@ public class PgmFileInfo extends FileInf
}
@Override
- public int getRGB(InputStream is) throws IOException {
+ public int getRGB(final InputStream is) throws IOException {
int sample = readSample(is, bytesPerSample);
sample = scaleSample(sample, scale, max);
- int alpha = 0xff;
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
| ((0xff & sample) << 8) | ((0xff & sample) << 0);
return rgb;
}
@Override
- public int getRGB(WhiteSpaceReader wsr) throws IOException {
+ public int getRGB(final WhiteSpaceReader wsr) throws IOException {
int sample = Integer.parseInt(wsr.readtoWhiteSpace());
sample = scaleSample(sample, scale, max);
- int alpha = 0xff;
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
| ((0xff & sample) << 8) | ((0xff & sample) << 0);
return rgb;
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -24,12 +24,12 @@ import java.util.Map;
import org.apache.commons.imaging.ImageWriteException;
public class PgmWriter extends PnmWriter implements PnmConstants {
- public PgmWriter(boolean RAWBITS) {
+ public PgmWriter(final boolean RAWBITS) {
super(RAWBITS);
}
@Override
- public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+ public void writeImage(final BufferedImage src, final OutputStream os, final Map<String,Object> params)
throws ImageWriteException, IOException {
// System.out.println
// (b1 == 0x50 && b2 == 0x36)
@@ -37,8 +37,8 @@ public class PgmWriter extends PnmWriter
os.write(RAWBITS ? 0x35 : 0x32);
os.write(PNM_SEPARATOR);
- int width = src.getWidth();
- int height = src.getHeight();
+ final int width = src.getWidth();
+ final int height = src.getHeight();
os.write(("" + width).getBytes("US-ASCII"));
os.write(PNM_SEPARATOR);
@@ -51,11 +51,11 @@ public class PgmWriter extends PnmWriter
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);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
- int sample = (red + green + blue) / 3;
+ final int argb = src.getRGB(x, y);
+ final int red = 0xff & (argb >> 16);
+ final int green = 0xff & (argb >> 8);
+ final int blue = 0xff & (argb >> 0);
+ final int sample = (red + green + blue) / 3;
if (RAWBITS) {
os.write((byte) sample);
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -79,16 +79,16 @@ public class PnmImageParser extends Imag
};
}
- private FileInfo readHeader(InputStream is) throws ImageReadException,
+ private FileInfo readHeader(final InputStream is) throws ImageReadException,
IOException {
- byte identifier1 = readByte("Identifier1", is, "Not a Valid PNM File");
- byte identifier2 = readByte("Identifier2", is, "Not a Valid PNM File");
+ final byte identifier1 = readByte("Identifier1", is, "Not a Valid PNM File");
+ final byte identifier2 = readByte("Identifier2", is, "Not a Valid PNM File");
if (identifier1 != PNM_PREFIX_BYTE) {
throw new ImageReadException("PNM file has invalid prefix byte 1");
}
- WhiteSpaceReader wsr = new WhiteSpaceReader(is);
+ final WhiteSpaceReader wsr = new WhiteSpaceReader(is);
if (identifier2 == PBM_TEXT_CODE ||
identifier2 == PBM_RAW_CODE ||
@@ -97,24 +97,24 @@ public class PnmImageParser extends Imag
identifier2 == PPM_TEXT_CODE ||
identifier2 == PPM_RAW_CODE) {
- int width = Integer.parseInt(wsr.readtoWhiteSpace());
- int height = Integer.parseInt(wsr.readtoWhiteSpace());
+ final int width = Integer.parseInt(wsr.readtoWhiteSpace());
+ final int height = Integer.parseInt(wsr.readtoWhiteSpace());
if (identifier2 == PBM_TEXT_CODE) {
return new PbmFileInfo(width, height, false);
} else if (identifier2 == PBM_RAW_CODE) {
return new PbmFileInfo(width, height, true);
} else if (identifier2 == PGM_TEXT_CODE) {
- int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
+ final int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
return new PgmFileInfo(width, height, false, maxgray);
} else if (identifier2 == PGM_RAW_CODE) {
- int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
+ final int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
return new PgmFileInfo(width, height, true, maxgray);
} else if (identifier2 == PPM_TEXT_CODE) {
- int max = Integer.parseInt(wsr.readtoWhiteSpace());
+ final int max = Integer.parseInt(wsr.readtoWhiteSpace());
return new PpmFileInfo(width, height, false, max);
} else if (identifier2 == PPM_RAW_CODE) {
- int max = Integer.parseInt(wsr.readtoWhiteSpace());
+ final int max = Integer.parseInt(wsr.readtoWhiteSpace());
return new PpmFileInfo(width, height, true, max);
} else {
throw new ImageReadException("PNM file has invalid header.");
@@ -139,8 +139,8 @@ public class PnmImageParser extends Imag
if (line.startsWith("#")) {
continue;
}
- StringTokenizer tokenizer = new StringTokenizer(line, " ", false);
- String type = tokenizer.nextToken();
+ final StringTokenizer tokenizer = new StringTokenizer(line, " ", false);
+ final String type = tokenizer.nextToken();
if (type.equals("WIDTH")) {
seenWidth = true;
width = Integer.parseInt(tokenizer.nextToken());
@@ -181,7 +181,7 @@ public class PnmImageParser extends Imag
}
}
- private FileInfo readHeader(ByteSource byteSource)
+ private FileInfo readHeader(final ByteSource byteSource)
throws ImageReadException, IOException {
InputStream is = null;
@@ -194,22 +194,22 @@ public class PnmImageParser extends Imag
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
}
}
@Override
- public byte[] getICCProfileBytes(ByteSource byteSource, Map<String,Object> params)
+ public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
return null;
}
@Override
- public Dimension getImageSize(ByteSource byteSource, Map<String,Object> params)
+ public Dimension getImageSize(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- FileInfo info = readHeader(byteSource);
+ final FileInfo info = readHeader(byteSource);
if (info == null) {
throw new ImageReadException("PNM: Couldn't read Header");
@@ -218,55 +218,55 @@ public class PnmImageParser extends Imag
return new Dimension(info.width, info.height);
}
- public byte[] embedICCProfile(byte image[], byte profile[]) {
+ public byte[] embedICCProfile(final byte image[], final byte profile[]) {
return null;
}
@Override
- public boolean embedICCProfile(File src, File dst, byte profile[]) {
+ public boolean embedICCProfile(final File src, final File dst, final byte profile[]) {
return false;
}
@Override
- public IImageMetadata getMetadata(ByteSource byteSource, Map<String,Object> params)
+ public IImageMetadata getMetadata(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
return null;
}
@Override
- public ImageInfo getImageInfo(ByteSource byteSource, Map<String,Object> params)
+ public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- FileInfo info = readHeader(byteSource);
+ final FileInfo info = readHeader(byteSource);
if (info == null) {
throw new ImageReadException("PNM: Couldn't read Header");
}
- List<String> Comments = new ArrayList<String>();
+ final List<String> Comments = new ArrayList<String>();
- int BitsPerPixel = info.getBitDepth() * info.getNumComponents();
- ImageFormat Format = info.getImageType();
- String FormatName = info.getImageTypeDescription();
- String MimeType = info.getMIMEType();
- int NumberOfImages = 1;
- boolean isProgressive = false;
+ final int BitsPerPixel = info.getBitDepth() * info.getNumComponents();
+ final ImageFormat Format = info.getImageType();
+ final String FormatName = info.getImageTypeDescription();
+ final String MimeType = info.getMIMEType();
+ final int NumberOfImages = 1;
+ final boolean isProgressive = false;
// boolean isProgressive = (fPNGChunkIHDR.InterlaceMethod != 0);
//
- int PhysicalWidthDpi = 72;
- float PhysicalWidthInch = (float) ((double) info.width / (double) PhysicalWidthDpi);
- int PhysicalHeightDpi = 72;
- float PhysicalHeightInch = (float) ((double) info.height / (double) PhysicalHeightDpi);
+ final int PhysicalWidthDpi = 72;
+ final float PhysicalWidthInch = (float) ((double) info.width / (double) PhysicalWidthDpi);
+ final int PhysicalHeightDpi = 72;
+ final float PhysicalHeightInch = (float) ((double) info.height / (double) PhysicalHeightDpi);
- String FormatDetails = info.getImageTypeDescription();
+ final String FormatDetails = info.getImageTypeDescription();
- boolean isTransparent = info.hasAlpha();
- boolean usesPalette = false;
+ final boolean isTransparent = info.hasAlpha();
+ final boolean usesPalette = false;
- int ColorType = info.getColorType();
- String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_NONE;
+ final int ColorType = info.getColorType();
+ final String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_NONE;
- ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
+ final ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
Format, FormatName, info.height, MimeType, NumberOfImages,
PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
PhysicalWidthInch, info.width, isProgressive, isTransparent,
@@ -276,11 +276,11 @@ public class PnmImageParser extends Imag
}
@Override
- public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
+ public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource)
throws ImageReadException, IOException {
pw.println("pnm.dumpImageFile");
- ImageInfo imageData = getImageInfo(byteSource);
+ final ImageInfo imageData = getImageInfo(byteSource);
if (imageData == null) {
return false;
}
@@ -293,20 +293,20 @@ public class PnmImageParser extends Imag
}
@Override
- public BufferedImage getBufferedImage(ByteSource byteSource, Map<String,Object> params)
+ public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
InputStream is = null;
try {
is = byteSource.getInputStream();
- FileInfo info = readHeader(is);
+ final FileInfo info = readHeader(is);
- int width = info.width;
- int height = info.height;
+ final int width = info.width;
+ final int height = info.height;
- boolean hasAlpha = info.hasAlpha();
- ImageBuilder imageBuilder = new ImageBuilder(width, height,
+ final boolean hasAlpha = info.hasAlpha();
+ final ImageBuilder imageBuilder = new ImageBuilder(width, height,
hasAlpha);
info.readImage(imageBuilder, is);
@@ -316,7 +316,7 @@ public class PnmImageParser extends Imag
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
}
@@ -327,21 +327,21 @@ public class PnmImageParser extends Imag
public static final String PARAM_VALUE_PNM_RAWBITS_NO = "NO";
@Override
- public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+ public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
throws ImageWriteException, IOException {
PnmWriter writer = null;
boolean useRawbits = true;
- boolean hasAlpha = new PaletteFactory().hasTransparency(src);
+ final boolean hasAlpha = new PaletteFactory().hasTransparency(src);
if (params != null) {
- Object useRawbitsParam = params.get(PARAM_KEY_PNM_RAWBITS);
+ final Object useRawbitsParam = params.get(PARAM_KEY_PNM_RAWBITS);
if (useRawbitsParam != null) {
if (useRawbitsParam.equals(PARAM_VALUE_PNM_RAWBITS_NO)) {
useRawbits = false;
}
}
- Object subtype = params.get(PARAM_KEY_FORMAT);
+ final Object subtype = params.get(PARAM_KEY_FORMAT);
if (subtype != null) {
if (subtype.equals(ImageFormat.IMAGE_FORMAT_PBM)) {
writer = new PbmWriter(useRawbits);
@@ -376,7 +376,7 @@ public class PnmImageParser extends Imag
}
if (params.size() > 0) {
- Object firstKey = params.keySet().iterator().next();
+ final Object firstKey = params.keySet().iterator().next();
throw new ImageWriteException("Unknown parameter: " + firstKey);
}
@@ -394,7 +394,7 @@ public class PnmImageParser extends Imag
* @return Xmp Xml as String, if present. Otherwise, returns null.
*/
@Override
- public String getXmpXml(ByteSource byteSource, Map<String,Object> params)
+ public String getXmpXml(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
return null;
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmWriter.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmWriter.java Tue Dec 4 17:23:16 2012
@@ -26,7 +26,7 @@ import org.apache.commons.imaging.ImageW
public abstract class PnmWriter {
protected final boolean RAWBITS;
- public PnmWriter(boolean RAWBITS) {
+ public PnmWriter(final boolean RAWBITS) {
this.RAWBITS = RAWBITS;
}
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -28,7 +28,7 @@ public class PpmFileInfo extends FileInf
private final float scale;
private final int bytesPerSample;
- public PpmFileInfo(int width, int height, boolean RAWBITS, int max) throws ImageReadException {
+ public PpmFileInfo(final int width, final int height, final boolean RAWBITS, final int max) throws ImageReadException {
super(width, height, RAWBITS);
if (max <= 0) {
throw new ImageReadException("PPM maxVal " + max
@@ -82,7 +82,7 @@ public class PpmFileInfo extends FileInf
}
@Override
- public int getRGB(InputStream is) throws IOException {
+ public int getRGB(final InputStream is) throws IOException {
int red = readSample(is, bytesPerSample);
int green = readSample(is, bytesPerSample);
int blue = readSample(is, bytesPerSample);
@@ -90,16 +90,16 @@ public class PpmFileInfo extends FileInf
red = scaleSample(red, scale, max);
green = scaleSample(green, scale, max);
blue = scaleSample(blue, scale, max);
- int alpha = 0xff;
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
| ((0xff & green) << 8) | ((0xff & blue) << 0);
return rgb;
}
@Override
- public int getRGB(WhiteSpaceReader wsr) throws IOException {
+ public int getRGB(final WhiteSpaceReader wsr) throws IOException {
int red = Integer.parseInt(wsr.readtoWhiteSpace());
int green = Integer.parseInt(wsr.readtoWhiteSpace());
int blue = Integer.parseInt(wsr.readtoWhiteSpace());
@@ -107,9 +107,9 @@ public class PpmFileInfo extends FileInf
red = scaleSample(red, scale, max);
green = scaleSample(green, scale, max);
blue = scaleSample(blue, scale, max);
- int alpha = 0xff;
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
| ((0xff & green) << 8) | ((0xff & blue) << 0);
return rgb;
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -24,12 +24,12 @@ import java.util.Map;
import org.apache.commons.imaging.ImageWriteException;
public class PpmWriter extends PnmWriter implements PnmConstants {
- public PpmWriter(boolean RAWBITS) {
+ public PpmWriter(final boolean RAWBITS) {
super(RAWBITS);
}
@Override
- public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+ public void writeImage(final BufferedImage src, final OutputStream os, final Map<String,Object> params)
throws ImageWriteException, IOException {
// System.out.println
// (b1 == 0x50 && b2 == 0x36)
@@ -37,8 +37,8 @@ public class PpmWriter extends PnmWriter
os.write(RAWBITS ? 0x36 : 0x33);
os.write(PNM_SEPARATOR);
- int width = src.getWidth();
- int height = src.getHeight();
+ final int width = src.getWidth();
+ final int height = src.getHeight();
os.write(("" + width).getBytes("US-ASCII"));
os.write(PNM_SEPARATOR);
@@ -51,10 +51,10 @@ public class PpmWriter extends PnmWriter
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);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
+ final int argb = src.getRGB(x, y);
+ final int red = 0xff & (argb >> 16);
+ final int green = 0xff & (argb >> 8);
+ final int blue = 0xff & (argb >> 0);
if (RAWBITS) {
os.write((byte) red);
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -22,12 +22,12 @@ import java.io.InputStream;
class WhiteSpaceReader {
private final InputStream is;
- public WhiteSpaceReader(InputStream is) {
+ public WhiteSpaceReader(final InputStream is) {
this.is = is;
}
private char read() throws IOException {
- int result = is.read();
+ final int result = is.read();
if (result < 0) {
throw new IOException("PNM: Unexpected EOF");
}
@@ -52,7 +52,7 @@ class WhiteSpaceReader {
c = nextChar();
}
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
while (!Character.isWhitespace(c)) {
buffer.append(c);
@@ -63,7 +63,7 @@ class WhiteSpaceReader {
}
public String readLine() throws IOException {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
for (char c = read(); (c != '\n') && (c != '\r'); c = read()) {
buffer.append(c);
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageContents.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageContents.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageContents.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageContents.java Tue Dec 4 17:23:16 2012
@@ -28,10 +28,10 @@ public class ImageContents {
public final int LayerAndMaskDataLength;
public final int Compression;
- public ImageContents(PsdHeaderInfo header,
+ public ImageContents(final PsdHeaderInfo header,
- int ColorModeDataLength, int ImageResourcesLength,
- int LayerAndMaskDataLength, int Compression) {
+ final int ColorModeDataLength, final int ImageResourcesLength,
+ final int LayerAndMaskDataLength, final int Compression) {
this.header = header;
this.ColorModeDataLength = ColorModeDataLength;
this.ImageResourcesLength = ImageResourcesLength;
@@ -40,12 +40,12 @@ public class ImageContents {
}
public void dump() {
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
+ final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
dump(pw);
pw.flush();
}
- public void dump(PrintWriter pw) {
+ public void dump(final PrintWriter pw) {
pw.println("");
pw.println("ImageContents");
pw.println("Compression: " + Compression + " ("
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceBlock.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceBlock.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceBlock.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceBlock.java Tue Dec 4 17:23:16 2012
@@ -25,7 +25,7 @@ class ImageResourceBlock {
protected final byte nameData[];
protected final byte data[];
- public ImageResourceBlock(int ID, byte NameData[], byte Data[]) {
+ public ImageResourceBlock(final int ID, final byte NameData[], final byte Data[]) {
this.id = ID;
this.nameData = NameData;
this.data = Data;
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -22,12 +22,12 @@ public class ImageResourceType {
public final int ID;
public final String Description;
- public ImageResourceType(int ID, String Description) {
+ public ImageResourceType(final int ID, final String Description) {
this.ID = ID;
this.Description = Description;
}
- public ImageResourceType(int ID, int ID2, String Description)
+ public ImageResourceType(final int ID, final int ID2, final String Description)
throws ImageReadException {
this(ID, Description);
if (ID != 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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -21,8 +21,8 @@ import org.apache.commons.imaging.util.D
public class PsdConstants {
static final ImageResourceType fImageResourceTypes[];
- public String getDescription(int id) {
- for (ImageResourceType fImageResourceType : fImageResourceTypes) {
+ public String getDescription(final int id) {
+ for (final ImageResourceType fImageResourceType : fImageResourceTypes) {
if (fImageResourceType.ID == id) {
return fImageResourceType.Description;
}
@@ -189,7 +189,7 @@ public class PsdConstants {
0x2710,
10000,
"Print flags information. 2 bytes version (=1), 1 byte center crop marks, 1 byte (=0), 4 bytes bleed width value, 2 bytes bleed width scale."), };
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(PsdConstants.class, e);
}
fImageResourceTypes = temp;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java Tue Dec 4 17:23:16 2012
@@ -29,8 +29,8 @@ public class PsdHeaderInfo {
public final int Depth;
public final int Mode;
- public PsdHeaderInfo(int Version, byte Reserved[], int Channels, int Rows,
- int Columns, int Depth, int Mode) {
+ public PsdHeaderInfo(final int Version, final byte Reserved[], final int Channels, final int Rows,
+ final int Columns, final int Depth, final int Mode) {
this.Version = Version;
this.Reserved = Reserved;
this.Channels = Channels;
@@ -42,12 +42,12 @@ public class PsdHeaderInfo {
}
public void dump() {
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
+ final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
dump(pw);
pw.flush();
}
- public void dump(PrintWriter pw) {
+ public void dump(final PrintWriter pw) {
pw.println("");
pw.println("Header");
pw.println("Version: " + Version + " (" + Integer.toHexString(Version)
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -79,7 +79,7 @@ public class PsdImageParser extends Imag
};
}
- private PsdHeaderInfo readHeader(ByteSource byteSource)
+ private PsdHeaderInfo readHeader(final ByteSource byteSource)
throws ImageReadException, IOException {
InputStream is = null;
@@ -92,61 +92,61 @@ public class PsdImageParser extends Imag
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
}
}
- private PsdHeaderInfo readHeader(InputStream is) throws ImageReadException,
+ private PsdHeaderInfo readHeader(final InputStream is) throws ImageReadException,
IOException {
readAndVerifyBytes(is, new byte[] { 56, 66, 80, 83 },
"Not a Valid PSD File");
- int Version = read2Bytes("Version", is, "Not a Valid PSD File");
+ final int Version = read2Bytes("Version", is, "Not a Valid PSD File");
- byte Reserved[] = readByteArray("Reserved", 6, is,
+ final byte Reserved[] = readByteArray("Reserved", 6, is,
"Not a Valid PSD File");
- int Channels = read2Bytes("Channels", is, "Not a Valid PSD File");
- int Rows = read4Bytes("Rows", is, "Not a Valid PSD File");
- int Columns = read4Bytes("Columns", is, "Not a Valid PSD File");
- int Depth = read2Bytes("Depth", is, "Not a Valid PSD File");
- int Mode = read2Bytes("Mode", is, "Not a Valid PSD File");
+ final int Channels = read2Bytes("Channels", is, "Not a Valid PSD File");
+ final int Rows = read4Bytes("Rows", is, "Not a Valid PSD File");
+ final int Columns = read4Bytes("Columns", is, "Not a Valid PSD File");
+ final int Depth = read2Bytes("Depth", is, "Not a Valid PSD File");
+ final int Mode = read2Bytes("Mode", is, "Not a Valid PSD File");
- PsdHeaderInfo result = new PsdHeaderInfo(Version, Reserved, Channels,
+ final PsdHeaderInfo result = new PsdHeaderInfo(Version, Reserved, Channels,
Rows, Columns, Depth, Mode);
return result;
}
- private ImageContents readImageContents(InputStream is)
+ private ImageContents readImageContents(final InputStream is)
throws ImageReadException, IOException {
- PsdHeaderInfo header = readHeader(is);
+ final PsdHeaderInfo header = readHeader(is);
- int ColorModeDataLength = read4Bytes("ColorModeDataLength", is,
+ final int ColorModeDataLength = read4Bytes("ColorModeDataLength", is,
"Not a Valid PSD File");
skipBytes(is, ColorModeDataLength);
// is.skip(ColorModeDataLength);
// byte ColorModeData[] = readByteArray("ColorModeData",
// ColorModeDataLength, is, "Not a Valid PSD File");
- int ImageResourcesLength = read4Bytes("ImageResourcesLength", is,
+ final int ImageResourcesLength = read4Bytes("ImageResourcesLength", is,
"Not a Valid PSD File");
skipBytes(is, ImageResourcesLength);
// long skipped = is.skip(ImageResourcesLength);
// byte ImageResources[] = readByteArray("ImageResources",
// ImageResourcesLength, is, "Not a Valid PSD File");
- int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength", is,
+ final int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength", is,
"Not a Valid PSD File");
skipBytes(is, LayerAndMaskDataLength);
// is.skip(LayerAndMaskDataLength);
// byte LayerAndMaskData[] = readByteArray("LayerAndMaskData",
// LayerAndMaskDataLength, is, "Not a Valid PSD File");
- int Compression = read2Bytes("Compression", is, "Not a Valid PSD File");
+ final int Compression = read2Bytes("Compression", is, "Not a Valid PSD File");
// skip_bytes(is, LayerAndMaskDataLength);
// byte ImageData[] = readByteArray("ImageData", LayerAndMaskDataLength,
@@ -154,7 +154,7 @@ public class PsdImageParser extends Imag
// System.out.println("Compression: " + Compression);
- ImageContents result = new ImageContents(header, ColorModeDataLength,
+ final ImageContents result = new ImageContents(header, ColorModeDataLength,
// ColorModeData,
ImageResourcesLength,
// ImageResources,
@@ -165,19 +165,19 @@ public class PsdImageParser extends Imag
return result;
}
- private List<ImageResourceBlock> readImageResourceBlocks(byte bytes[],
- int imageResourceIDs[], int maxBlocksToRead)
+ private List<ImageResourceBlock> readImageResourceBlocks(final byte bytes[],
+ final int imageResourceIDs[], final int maxBlocksToRead)
throws ImageReadException, IOException {
return readImageResourceBlocks(new ByteArrayInputStream(bytes),
imageResourceIDs, maxBlocksToRead, bytes.length);
}
- private boolean keepImageResourceBlock(int ID, int imageResourceIDs[]) {
+ private boolean keepImageResourceBlock(final int ID, final int imageResourceIDs[]) {
if (imageResourceIDs == null) {
return true;
}
- for (int imageResourceID : imageResourceIDs) {
+ for (final int imageResourceID : imageResourceIDs) {
if (ID == imageResourceID) {
return true;
}
@@ -186,43 +186,43 @@ public class PsdImageParser extends Imag
return false;
}
- private List<ImageResourceBlock> readImageResourceBlocks(InputStream is,
- int imageResourceIDs[], int maxBlocksToRead, int available)
+ private List<ImageResourceBlock> readImageResourceBlocks(final InputStream is,
+ final int imageResourceIDs[], final int maxBlocksToRead, int available)
throws ImageReadException, IOException {
- List<ImageResourceBlock> result = new ArrayList<ImageResourceBlock>();
+ final List<ImageResourceBlock> result = new ArrayList<ImageResourceBlock>();
while (available > 0) {
readAndVerifyBytes(is, new byte[] { 56, 66, 73, 77 },
"Not a Valid PSD File");
available -= 4;
- int id = read2Bytes("ID", is, "Not a Valid PSD File");
+ final int id = read2Bytes("ID", is, "Not a Valid PSD File");
available -= 2;
- int nameLength = readByte("NameLength", is, "Not a Valid PSD File");
+ final int nameLength = readByte("NameLength", is, "Not a Valid PSD File");
available -= 1;
- byte nameBytes[] = readByteArray("NameData", nameLength, is,
+ final byte nameBytes[] = readByteArray("NameData", nameLength, is,
"Not a Valid PSD File");
available -= nameLength;
if (((nameLength + 1) % 2) != 0) {
- int NameDiscard = readByte("NameDiscard", is,
+ final int NameDiscard = readByte("NameDiscard", is,
"Not a Valid PSD File");
available -= 1;
}
// String Name = readPString("Name", 6, is, "Not a Valid PSD File");
- int DataSize = read4Bytes("Size", is, "Not a Valid PSD File");
+ final int DataSize = read4Bytes("Size", is, "Not a Valid PSD File");
available -= 4;
// int ActualDataSize = ((DataSize % 2) == 0)
// ? DataSize
// : DataSize + 1; // pad to make even
- byte Data[] = readByteArray("Data", DataSize, is,
+ final byte Data[] = readByteArray("Data", DataSize, is,
"Not a Valid PSD File");
available -= DataSize;
if ((DataSize % 2) != 0) {
- int DataDiscard = readByte("DataDiscard", is,
+ final int DataDiscard = readByte("DataDiscard", is,
"Not a Valid PSD File");
available -= 1;
}
@@ -243,19 +243,19 @@ public class PsdImageParser extends Imag
}
private List<ImageResourceBlock> readImageResourceBlocks(
- ByteSource byteSource, int imageResourceIDs[], int maxBlocksToRead)
+ final ByteSource byteSource, final int imageResourceIDs[], final int maxBlocksToRead)
throws ImageReadException, IOException {
InputStream is = null;
try {
is = byteSource.getInputStream();
- ImageContents imageContents = readImageContents(is);
+ final ImageContents imageContents = readImageContents(is);
is.close();
is = this.getInputStream(byteSource, PSD_SECTION_IMAGE_RESOURCES);
- byte ImageResources[] = readByteArray("ImageResources",
+ final byte ImageResources[] = readByteArray("ImageResources",
imageContents.ImageResourcesLength, is,
"Not a Valid PSD File");
@@ -266,7 +266,7 @@ public class PsdImageParser extends Imag
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
@@ -281,7 +281,7 @@ public class PsdImageParser extends Imag
private static final int PSD_HEADER_LENGTH = 26;
- private InputStream getInputStream(ByteSource byteSource, int section)
+ private InputStream getInputStream(final ByteSource byteSource, final int section)
throws ImageReadException, IOException {
InputStream is = null;
boolean notFound = false;
@@ -295,7 +295,7 @@ public class PsdImageParser extends Imag
skipBytes(is, PSD_HEADER_LENGTH);
// is.skip(kHeaderLength);
- int ColorModeDataLength = read4Bytes("ColorModeDataLength", is,
+ final int ColorModeDataLength = read4Bytes("ColorModeDataLength", is,
"Not a Valid PSD File");
if (section == PSD_SECTION_COLOR_MODE) {
@@ -306,7 +306,7 @@ public class PsdImageParser extends Imag
// byte ColorModeData[] = readByteArray("ColorModeData",
// ColorModeDataLength, is, "Not a Valid PSD File");
- int ImageResourcesLength = read4Bytes("ImageResourcesLength", is,
+ final int ImageResourcesLength = read4Bytes("ImageResourcesLength", is,
"Not a Valid PSD File");
if (section == PSD_SECTION_IMAGE_RESOURCES) {
@@ -317,7 +317,7 @@ public class PsdImageParser extends Imag
// byte ImageResources[] = readByteArray("ImageResources",
// ImageResourcesLength, is, "Not a Valid PSD File");
- int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength",
+ final int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength",
is, "Not a Valid PSD File");
if (section == PSD_SECTION_LAYER_AND_MASK_DATA) {
@@ -341,7 +341,7 @@ public class PsdImageParser extends Imag
if (notFound && is != null) {
try {
is.close();
- } catch (IOException ignore) {
+ } catch (final IOException ignore) {
}
}
}
@@ -349,7 +349,7 @@ public class PsdImageParser extends Imag
+ section);
}
- private byte[] getData(ByteSource byteSource, int section)
+ private byte[] getData(final ByteSource byteSource, final int section)
throws ImageReadException, IOException {
InputStream is = null;
@@ -363,7 +363,7 @@ public class PsdImageParser extends Imag
}
skipBytes(is, PSD_HEADER_LENGTH);
- int ColorModeDataLength = read4Bytes("ColorModeDataLength", is,
+ final int ColorModeDataLength = read4Bytes("ColorModeDataLength", is,
"Not a Valid PSD File");
if (section == PSD_SECTION_COLOR_MODE) {
@@ -375,7 +375,7 @@ public class PsdImageParser extends Imag
// byte ColorModeData[] = readByteArray("ColorModeData",
// ColorModeDataLength, is, "Not a Valid PSD File");
- int ImageResourcesLength = read4Bytes("ImageResourcesLength", is,
+ final int ImageResourcesLength = read4Bytes("ImageResourcesLength", is,
"Not a Valid PSD File");
if (section == PSD_SECTION_IMAGE_RESOURCES) {
@@ -387,7 +387,7 @@ public class PsdImageParser extends Imag
// byte ImageResources[] = readByteArray("ImageResources",
// ImageResourcesLength, is, "Not a Valid PSD File");
- int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength",
+ final int LayerAndMaskDataLength = read4Bytes("LayerAndMaskDataLength",
is, "Not a Valid PSD File");
if (section == PSD_SECTION_LAYER_AND_MASK_DATA) {
@@ -414,7 +414,7 @@ public class PsdImageParser extends Imag
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
@@ -423,21 +423,21 @@ public class PsdImageParser extends Imag
+ section);
}
- private ImageContents readImageContents(ByteSource byteSource)
+ private ImageContents readImageContents(final ByteSource byteSource)
throws ImageReadException, IOException {
InputStream is = null;
try {
is = byteSource.getInputStream();
- ImageContents imageContents = readImageContents(is);
+ final ImageContents imageContents = readImageContents(is);
return imageContents;
} finally {
try {
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
@@ -448,17 +448,17 @@ public class PsdImageParser extends Imag
public final static int IMAGE_RESOURCE_ID_ICC_PROFILE = 0x040F;
@Override
- public byte[] getICCProfileBytes(ByteSource byteSource, Map<String,Object> params)
+ public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+ final List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
new int[] { IMAGE_RESOURCE_ID_ICC_PROFILE, }, 1);
if ((blocks == null) || (blocks.size() < 1)) {
return null;
}
- ImageResourceBlock irb = blocks.get(0);
- byte bytes[] = irb.data;
+ final ImageResourceBlock irb = blocks.get(0);
+ final byte bytes[] = irb.data;
if ((bytes == null) || (bytes.length < 1)) {
return null;
}
@@ -466,9 +466,9 @@ public class PsdImageParser extends Imag
}
@Override
- public Dimension getImageSize(ByteSource byteSource, Map<String,Object> params)
+ public Dimension getImageSize(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- PsdHeaderInfo bhi = readHeader(byteSource);
+ final PsdHeaderInfo bhi = readHeader(byteSource);
if (bhi == null) {
throw new ImageReadException("PSD: couldn't read header");
}
@@ -477,22 +477,22 @@ public class PsdImageParser extends Imag
}
- public byte[] embedICCProfile(byte image[], byte profile[]) {
+ public byte[] embedICCProfile(final byte image[], final byte profile[]) {
return null;
}
@Override
- public boolean embedICCProfile(File src, File dst, byte profile[]) {
+ public boolean embedICCProfile(final File src, final File dst, final byte profile[]) {
return false;
}
@Override
- public IImageMetadata getMetadata(ByteSource byteSource, Map<String,Object> params)
+ public IImageMetadata getMetadata(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
return null;
}
- private int getChannelsPerMode(int mode) {
+ private int getChannelsPerMode(final int mode) {
switch (mode) {
case 0: // Bitmap
return 1;
@@ -517,24 +517,24 @@ public class PsdImageParser extends Imag
}
@Override
- public ImageInfo getImageInfo(ByteSource byteSource, Map<String,Object> params)
+ public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- ImageContents imageContents = readImageContents(byteSource);
+ final ImageContents imageContents = readImageContents(byteSource);
// ImageContents imageContents = readImage(byteSource, false);
if (imageContents == null) {
throw new ImageReadException("PSD: Couldn't read blocks");
}
- PsdHeaderInfo header = imageContents.header;
+ final PsdHeaderInfo header = imageContents.header;
if (header == null) {
throw new ImageReadException("PSD: Couldn't read Header");
}
- int Width = header.Columns;
- int Height = header.Rows;
+ final int Width = header.Columns;
+ final int Height = header.Rows;
- List<String> Comments = new ArrayList<String>();
+ final List<String> Comments = new ArrayList<String>();
// TODO: comments...
int BitsPerPixel = header.Depth * getChannelsPerMode(header.Mode);
@@ -545,24 +545,24 @@ public class PsdImageParser extends Imag
if (BitsPerPixel < 0) {
BitsPerPixel = 0;
}
- ImageFormat Format = ImageFormat.IMAGE_FORMAT_PSD;
- String FormatName = "Photoshop";
- String MimeType = "image/x-photoshop";
+ final ImageFormat Format = ImageFormat.IMAGE_FORMAT_PSD;
+ final String FormatName = "Photoshop";
+ final String MimeType = "image/x-photoshop";
// we ought to count images, but don't yet.
- int NumberOfImages = -1;
+ final int NumberOfImages = -1;
// not accurate ... only reflects first
- boolean isProgressive = false;
+ final boolean isProgressive = false;
- int PhysicalWidthDpi = 72;
- float PhysicalWidthInch = (float) ((double) Width / (double) PhysicalWidthDpi);
- int PhysicalHeightDpi = 72;
- float PhysicalHeightInch = (float) ((double) Height / (double) PhysicalHeightDpi);
-
- String FormatDetails = "Psd";
-
- boolean isTransparent = false; // TODO: inaccurate.
- boolean usesPalette = header.Mode == COLOR_MODE_INDEXED;
- int ColorType = ImageInfo.COLOR_TYPE_UNKNOWN;
+ final int PhysicalWidthDpi = 72;
+ final float PhysicalWidthInch = (float) ((double) Width / (double) PhysicalWidthDpi);
+ final int PhysicalHeightDpi = 72;
+ final float PhysicalHeightInch = (float) ((double) Height / (double) PhysicalHeightDpi);
+
+ final String FormatDetails = "Psd";
+
+ final boolean isTransparent = false; // TODO: inaccurate.
+ final boolean usesPalette = header.Mode == COLOR_MODE_INDEXED;
+ final int ColorType = ImageInfo.COLOR_TYPE_UNKNOWN;
String compressionAlgorithm;
switch (imageContents.Compression) {
@@ -576,7 +576,7 @@ public class PsdImageParser extends Imag
compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN;
}
- ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
+ final ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
Format, FormatName, Height, MimeType, NumberOfImages,
PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
PhysicalWidthInch, Width, isProgressive, isTransparent,
@@ -587,9 +587,9 @@ public class PsdImageParser extends Imag
// TODO not used
private ImageResourceBlock findImageResourceBlock(
- List<ImageResourceBlock> blocks, int ID) {
+ final List<ImageResourceBlock> blocks, final int ID) {
for (int i = 0; i < blocks.size(); i++) {
- ImageResourceBlock block = blocks.get(i);
+ final ImageResourceBlock block = blocks.get(i);
if (block.id == ID) {
return block;
@@ -599,22 +599,22 @@ public class PsdImageParser extends Imag
}
@Override
- public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
+ public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource)
throws ImageReadException, IOException {
pw.println("gif.dumpImageFile");
- ImageInfo fImageData = getImageInfo(byteSource);
+ final ImageInfo fImageData = getImageInfo(byteSource);
if (fImageData == null) {
return false;
}
fImageData.toString(pw, "");
- ImageContents imageContents = readImageContents(byteSource);
+ final ImageContents imageContents = readImageContents(byteSource);
imageContents.dump(pw);
imageContents.header.dump(pw);
- List<ImageResourceBlock> blocks = readImageResourceBlocks(
+ final List<ImageResourceBlock> blocks = readImageResourceBlocks(
byteSource,
// fImageContents.ImageResources,
null, -1);
@@ -623,7 +623,7 @@ public class PsdImageParser extends Imag
// System.out.println("gif.blocks: " + blocks.blocks.size());
for (int i = 0; i < blocks.size(); i++) {
- ImageResourceBlock block = blocks.get(i);
+ final ImageResourceBlock block = blocks.get(i);
pw.println("\t" + i + " (" + Integer.toHexString(block.id)
+ ", " + "'"
+ new String(block.nameData, "ISO-8859-1")
@@ -646,16 +646,16 @@ public class PsdImageParser extends Imag
private static final int COLOR_MODE_INDEXED = 2;
@Override
- public BufferedImage getBufferedImage(ByteSource byteSource, Map<String,Object> params)
+ public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- ImageContents imageContents = readImageContents(byteSource);
+ final ImageContents imageContents = readImageContents(byteSource);
// ImageContents imageContents = readImage(byteSource, false);
if (imageContents == null) {
throw new ImageReadException("PSD: Couldn't read blocks");
}
- PsdHeaderInfo header = imageContents.header;
+ final PsdHeaderInfo header = imageContents.header;
if (header == null) {
throw new ImageReadException("PSD: Couldn't read Header");
}
@@ -672,16 +672,16 @@ public class PsdImageParser extends Imag
// fImageContents.ImageResources,
null, -1);
- int width = header.Columns;
- int height = header.Rows;
+ final int width = header.Columns;
+ final int height = header.Rows;
// int height = header.Columns;
// int transfer_type;
// transfer_type = DataBuffer.TYPE_BYTE;
- boolean hasAlpha = false;
- BufferedImage result = getBufferedImageFactory(params)
+ final boolean hasAlpha = false;
+ final BufferedImage result = getBufferedImageFactory(params)
.getColorBufferedImage(width, height, hasAlpha);
DataParser dataParser;
@@ -706,7 +706,7 @@ public class PsdImageParser extends Imag
// case 2 : // Indexed=2;
{
- byte ColorModeData[] = getData(byteSource, PSD_SECTION_COLOR_MODE);
+ final byte ColorModeData[] = getData(byteSource, PSD_SECTION_COLOR_MODE);
// ImageResourceBlock block = findImageResourceBlock(blocks,
// 0x03EB);
@@ -756,7 +756,7 @@ public class PsdImageParser extends Imag
if (is != null) {
is.close();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Debug.debug(e);
}
@@ -781,32 +781,32 @@ public class PsdImageParser extends Imag
* @return Xmp Xml as String, if present. Otherwise, returns null.
*/
@Override
- public String getXmpXml(ByteSource byteSource, Map<String,Object> params)
+ public String getXmpXml(final ByteSource byteSource, final Map<String,Object> params)
throws ImageReadException, IOException {
- ImageContents imageContents = readImageContents(byteSource);
+ final ImageContents imageContents = readImageContents(byteSource);
if (imageContents == null) {
throw new ImageReadException("PSD: Couldn't read blocks");
}
- PsdHeaderInfo header = imageContents.header;
+ final PsdHeaderInfo header = imageContents.header;
if (header == null) {
throw new ImageReadException("PSD: Couldn't read Header");
}
- List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+ final List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
new int[] { IMAGE_RESOURCE_ID_XMP, }, -1);
if ((blocks == null) || (blocks.size() < 1)) {
return null;
}
- List<ImageResourceBlock> xmpBlocks = new ArrayList<ImageResourceBlock>();
+ final List<ImageResourceBlock> xmpBlocks = new ArrayList<ImageResourceBlock>();
if (false) {
// TODO: for PSD 7 and later, verify "XMP" name.
for (int i = 0; i < blocks.size(); i++) {
- ImageResourceBlock block = blocks.get(i);
+ final ImageResourceBlock block = blocks.get(i);
if (!block.getName().equals(BLOCK_NAME_XMP)) {
continue;
}
@@ -824,13 +824,13 @@ public class PsdImageParser extends Imag
"PSD contains more than one XMP block.");
}
- ImageResourceBlock block = xmpBlocks.get(0);
+ final ImageResourceBlock block = xmpBlocks.get(0);
try {
// segment data is UTF-8 encoded xml.
- String xml = new String(block.data, 0, block.data.length, "utf-8");
+ final String xml = new String(block.data, 0, block.data.length, "utf-8");
return xml;
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
throw new ImageReadException("Invalid JPEG XMP Segment.");
}
}
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -23,17 +23,17 @@ import org.apache.commons.imaging.format
import org.apache.commons.imaging.formats.psd.PsdHeaderInfo;
public abstract class DataParser {
- public final void parseData(int data[][][], BufferedImage bi,
- ImageContents imageContents) {
- DataBuffer buffer = bi.getRaster().getDataBuffer();
-
- PsdHeaderInfo header = imageContents.header;
- int width = header.Columns;
- int height = header.Rows;
+ public final void parseData(final int data[][][], final BufferedImage bi,
+ final ImageContents imageContents) {
+ final DataBuffer buffer = bi.getRaster().getDataBuffer();
+
+ final PsdHeaderInfo header = imageContents.header;
+ final int width = header.Columns;
+ final int height = header.Rows;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- int rgb = getRGB(data, x, y, imageContents);
+ final int rgb = getRGB(data, x, y, imageContents);
buffer.setElem(y * width + x, rgb);
}
}
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=1417043&r1=1417042&r2=1417043&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 Tue Dec 4 17:23:16 2012
@@ -21,8 +21,8 @@ import org.apache.commons.imaging.format
public class DataParserBitmap extends DataParser {
@Override
- protected int getRGB(int data[][][], int x, int y,
- ImageContents imageContents) {
+ protected int getRGB(final int data[][][], final int x, final int y,
+ final ImageContents imageContents) {
int sample = 0xff & data[0][y][x];
if (sample == 0) {
sample = 255;
@@ -30,9 +30,9 @@ public class DataParserBitmap extends Da
sample = 0;
}
// sample = 255- sample;
- int alpha = 0xff;
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
| ((0xff & sample) << 8) | ((0xff & sample) << 0);
return rgb;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java Tue Dec 4 17:23:16 2012
@@ -21,8 +21,8 @@ import org.apache.commons.imaging.format
public class DataParserCmyk extends DataParser {
@Override
- protected int getRGB(int data[][][], int x, int y,
- ImageContents imageContents) {
+ protected int getRGB(final int data[][][], final int x, final int y,
+ final ImageContents imageContents) {
int sc = 0xff & data[0][y][x];
int sm = 0xff & data[1][y][x];
int sy = 0xff & data[2][y][x];
@@ -34,7 +34,7 @@ public class DataParserCmyk extends Data
sy = 255 - sy;
sk = 255 - sk;
- int rgb = ColorConversions.convertCMYKtoRGB(sc, sm, sy, sk);
+ final int rgb = ColorConversions.convertCMYKtoRGB(sc, sm, sy, sk);
return rgb;
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java Tue Dec 4 17:23:16 2012
@@ -20,12 +20,12 @@ import org.apache.commons.imaging.format
public class DataParserGrayscale extends DataParser {
@Override
- protected int getRGB(int data[][][], int x, int y,
- ImageContents imageContents) {
- int sample = 0xff & data[0][y][x];
- int alpha = 0xff;
+ protected int getRGB(final int data[][][], final int x, final int y,
+ final ImageContents imageContents) {
+ final int sample = 0xff & data[0][y][x];
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
| ((0xff & sample) << 8) | ((0xff & sample) << 0);
return rgb;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java Tue Dec 4 17:23:16 2012
@@ -21,15 +21,15 @@ import org.apache.commons.imaging.format
public class DataParserIndexed extends DataParser {
private final int ColorTable[];
- public DataParserIndexed(byte ColorModeData[]) {
+ public DataParserIndexed(final byte ColorModeData[]) {
ColorTable = new int[256];
for (int i = 0; i < 256; i++) {
- int red = 0xff & ColorModeData[0 * 256 + i];
- int green = 0xff & ColorModeData[1 * 256 + i];
- int blue = 0xff & ColorModeData[2 * 256 + i];
- int alpha = 0xff;
+ final int red = 0xff & ColorModeData[0 * 256 + i];
+ final int green = 0xff & ColorModeData[1 * 256 + i];
+ final int blue = 0xff & ColorModeData[2 * 256 + i];
+ final int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ final int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
| ((0xff & green) << 8) | ((0xff & blue) << 0);
ColorTable[i] = rgb;
@@ -37,10 +37,10 @@ public class DataParserIndexed extends D
}
@Override
- protected int getRGB(int data[][][], int x, int y,
- ImageContents imageContents) {
- int sample = 0xff & data[0][y][x];
- int rgb = ColorTable[sample];
+ protected int getRGB(final int data[][][], final int x, final int y,
+ final ImageContents imageContents) {
+ final int sample = 0xff & data[0][y][x];
+ final int rgb = ColorTable[sample];
return rgb;
}