You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2013/11/27 12:21:16 UTC
svn commit: r1545998 [1/5] - in /commons/proper/imaging/trunk/src:
main/java/org/apache/commons/imaging/
main/java/org/apache/commons/imaging/common/
main/java/org/apache/commons/imaging/common/mylzw/
main/java/org/apache/commons/imaging/formats/bmp/ m...
Author: ebourg
Date: Wed Nov 27 11:21:14 2013
New Revision: 1545998
URL: http://svn.apache.org/r1545998
Log:
Variables name convention
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/RationalNumber.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/ImageContents.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStream.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/JpegIptcRewriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App2Segment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/AppnSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/GenericSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/UnknownSegment.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/GammaCorrection.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterSimple.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIdat.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIhdr.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPhys.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkPlte.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngTextChunk.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverage.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaeth.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterSub.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterGrayscale.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterTrueColor.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/FileInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmFileInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmWriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmFileInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/ImageResourceType.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/UncompressedDataReader.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/BitInputStream.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileInfo.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorGroup.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorSpaceSubset.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutLongestAxisImplementation.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutMostPopulatedBoxesImplementation.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutPalette.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/SampleUsage.java
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java Wed Nov 27 11:21:14 2013
@@ -37,24 +37,24 @@ public class FormatCompliance {
failOnError = false;
}
- public FormatCompliance(final String description, final boolean fail_on_error) {
+ public FormatCompliance(final String description, final boolean failOnError) {
this.description = description;
- this.failOnError = fail_on_error;
+ this.failOnError = failOnError;
}
public static FormatCompliance getDefault() {
return new FormatCompliance("ignore", false);
}
- public void addComment(final String s) throws ImageReadException {
- comments.add(s);
+ public void addComment(final String comment) throws ImageReadException {
+ comments.add(comment);
if (failOnError) {
- throw new ImageReadException(s);
+ throw new ImageReadException(comment);
}
}
- public void addComment(final String s, final int value) throws ImageReadException {
- addComment(s + ": " + getValueDescription(value));
+ public void addComment(final String comment, final int value) throws ImageReadException {
+ addComment(comment + ": " + getValueDescription(value));
}
@Override
@@ -89,7 +89,7 @@ public class FormatCompliance {
return value + " (" + Integer.toHexString(value) + ")";
}
- public boolean compare_bytes(final String name, final byte[] expected, final byte[] actual)
+ public boolean compareBytes(final String name, final byte[] expected, final byte[] actual)
throws ImageReadException {
if (expected.length != actual.length) {
addComment(name + ": " + "Unexpected length: (expected: "
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java Wed Nov 27 11:21:14 2013
@@ -63,10 +63,10 @@ public class ImageDump {
return;
}
- final ICC_ColorSpace fICC_ColorSpace = (ICC_ColorSpace) cs;
- final ICC_Profile fICC_Profile = fICC_ColorSpace.getProfile();
+ final ICC_ColorSpace iccColorSpace = (ICC_ColorSpace) cs;
+ final ICC_Profile iccProfile = iccColorSpace.getProfile();
- final byte[] bytes = fICC_Profile.getData();
+ final byte[] bytes = iccProfile.getData();
final IccProfileParser parser = new IccProfileParser();
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java Wed Nov 27 11:21:14 2013
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List;
public class ImageMetadata implements IImageMetadata {
- protected static final String newline = System.getProperty("line.separator");
+ private static final String NEWLINE = System.getProperty("line.separator");
private final List<IImageMetadataItem> items = new ArrayList<IImageMetadataItem>();
public void add(final String keyword, final String text) {
@@ -48,7 +48,7 @@ public class ImageMetadata implements II
final StringBuilder result = new StringBuilder();
for (int i = 0; i < items.size(); i++) {
if (i > 0) {
- result.append(newline);
+ result.append(NEWLINE);
}
// if (null != prefix)
// result.append(prefix);
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java Wed Nov 27 11:21:14 2013
@@ -119,10 +119,10 @@ public class PackBits {
if (dup == ptr) {
// write run length
final int len = findRunLength(bytes, dup);
- final int actual_len = Math.min(len, 128);
- baos.write(-(actual_len - 1));
+ final int actualLen = Math.min(len, 128);
+ baos.write(-(actualLen - 1));
baos.write(bytes[ptr]);
- ptr += actual_len;
+ ptr += actualLen;
} else {
// write literals
int len = dup - ptr;
@@ -144,10 +144,10 @@ public class PackBits {
if (dup < 0) {
len = bytes.length - ptr;
}
- final int actual_len = Math.min(len, 128);
+ final int actualLen = Math.min(len, 128);
- baos.write(actual_len - 1);
- for (int i = 0; i < actual_len; i++) {
+ baos.write(actualLen - 1);
+ for (int i = 0; i < actualLen; i++) {
baos.write(bytes[ptr]);
ptr++;
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/RationalNumber.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/RationalNumber.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/RationalNumber.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/RationalNumber.java Wed Nov 27 11:21:14 2013
@@ -185,10 +185,10 @@ public class RationalNumber extends Numb
Option bestOption = (low.error < high.error) ? low : high;
- final int MAX_ITERATIONS = 100; // value is quite high, actually.
- // shouldn't matter.
+ final int maxIterations = 100; // value is quite high, actually.
+ // shouldn't matter.
for (int count = 0; bestOption.error > TOLERANCE
- && count < MAX_ITERATIONS; count++) {
+ && count < maxIterations; count++) {
final RationalNumber mediant = RationalNumber.factoryMethod(
(long) low.rationalNumber.numerator
+ (long) high.rationalNumber.numerator,
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java Wed Nov 27 11:21:14 2013
@@ -42,8 +42,8 @@ public class MyBitInputStream extends In
tiffLZWMode = true;
}
- public int readBits(final int SampleBits) throws IOException {
- while (bitsInCache < SampleBits) {
+ public int readBits(final int sampleBits) throws IOException {
+ while (bitsInCache < sampleBits) {
final int next = is.read();
if (next < 0) {
@@ -65,20 +65,20 @@ public class MyBitInputStream extends In
bytesRead++;
bitsInCache += 8;
}
- final int sampleMask = (1 << SampleBits) - 1;
+ final int sampleMask = (1 << sampleBits) - 1;
int sample;
if (byteOrder == ByteOrder.BIG_ENDIAN) {
- sample = sampleMask & (bitCache >> (bitsInCache - SampleBits));
+ sample = sampleMask & (bitCache >> (bitsInCache - sampleBits));
} else {
sample = sampleMask & bitCache;
- bitCache >>= SampleBits;
+ bitCache >>= sampleBits;
}
final int result = sample;
- bitsInCache -= SampleBits;
+ bitsInCache -= sampleBits;
final int remainderMask = (1 << bitsInCache) - 1;
bitCache &= remainderMask;
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java Wed Nov 27 11:21:14 2013
@@ -39,18 +39,18 @@ public class MyBitOutputStream extends O
// TODO: in and out streams CANNOT accurately read/write 32bits at a time,
// as int will overflow. should have used a long
- public void writeBits(int value, final int SampleBits) throws IOException {
- final int sampleMask = (1 << SampleBits) - 1;
+ public void writeBits(int value, final int sampleBits) throws IOException {
+ final int sampleMask = (1 << sampleBits) - 1;
value &= sampleMask;
if (byteOrder == ByteOrder.BIG_ENDIAN) {
// MSB, so add to right
- bitCache = (bitCache << SampleBits) | value;
+ bitCache = (bitCache << sampleBits) | value;
} else {
// LSB, so add to left
bitCache = bitCache | (value << bitsInCache);
}
- bitsInCache += SampleBits;
+ bitsInCache += sampleBits;
while (bitsInCache >= 8) {
if (byteOrder == ByteOrder.BIG_ENDIAN) {
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java Wed Nov 27 11:21:14 2013
@@ -54,16 +54,16 @@ public class MyLzwCompressor {
listener.init(clearCode, eoiCode);
}
- InitializeStringTable();
+ initializeStringTable();
}
- private void InitializeStringTable() {
+ private void initializeStringTable() {
codeSize = initialCodeSize;
- final int intial_entries_count = (1 << codeSize) + 2;
+ final int intialEntriesCount = (1 << codeSize) + 2;
map.clear();
- for (codes = 0; codes < intial_entries_count; codes++) {
+ for (codes = 0; codes < intialEntriesCount; codes++) {
if ((codes != clearCode) && (codes != eoiCode)) {
final ByteArray key = arrayToKey((byte) codes);
@@ -73,7 +73,7 @@ public class MyLzwCompressor {
}
private void clearTable() {
- InitializeStringTable();
+ initializeStringTable();
incrementCodeSize();
}
@@ -230,27 +230,27 @@ public class MyLzwCompressor {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length);
final MyBitOutputStream bos = new MyBitOutputStream(baos, byteOrder);
- InitializeStringTable();
+ initializeStringTable();
clearTable();
writeClearCode(bos);
- int w_start = 0;
- int w_length = 0;
+ int wStart = 0;
+ int wLength = 0;
for (int i = 0; i < bytes.length; i++) {
- if (isInTable(bytes, w_start, w_length + 1)) {
- w_length++;
+ if (isInTable(bytes, wStart, wLength + 1)) {
+ wLength++;
} else {
- final int code = codeFromString(bytes, w_start, w_length);
+ final int code = codeFromString(bytes, wStart, wLength);
writeDataCode(bos, code);
- addTableEntry(bos, bytes, w_start, w_length + 1);
+ addTableEntry(bos, bytes, wStart, wLength + 1);
- w_start = i;
- w_length = 1;
+ wStart = i;
+ wLength = 1;
}
}
- final int code = codeFromString(bytes, w_start, w_length);
+ final int code = codeFromString(bytes, wStart, wLength);
writeDataCode(bos, code);
writeEoiCode(bos);
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java Wed Nov 27 11:21:14 2013
@@ -60,15 +60,15 @@ public final class MyLzwDecompressor {
listener.init(clearCode, eoiCode);
}
- InitializeTable();
+ initializeTable();
}
- private void InitializeTable() {
+ private void initializeTable() {
codeSize = initialCodeSize;
- final int intial_entries_count = 1 << codeSize + 2;
+ final int intialEntriesCount = 1 << codeSize + 2;
- for (int i = 0; i < intial_entries_count; i++) {
+ for (int i = 0; i < intialEntriesCount; i++) {
table[i] = new byte[] { (byte) i, };
}
}
@@ -96,8 +96,8 @@ public final class MyLzwDecompressor {
return table[code];
}
- private boolean isInTable(final int Code) {
- return Code < codes;
+ private boolean isInTable(final int code) {
+ return code < codes;
}
private byte firstChar(final byte[] bytes) {
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java Wed Nov 27 11:21:14 2013
@@ -96,8 +96,8 @@ public class BmpImageParser extends Imag
final byte identifier2 = readByte("Identifier2", is, "Not a Valid BMP File");
if (formatCompliance != null) {
- formatCompliance.compare_bytes("Signature", BMP_HEADER_SIGNATURE,
- new byte[] { identifier1, identifier2, });
+ formatCompliance.compareBytes("Signature", BMP_HEADER_SIGNATURE,
+ new byte[]{identifier1, identifier2,});
}
final int fileSize = read4Bytes("File Size", is, "Not a Valid BMP File");
@@ -259,8 +259,7 @@ public class BmpImageParser extends Imag
profileSize, reservedV5);
}
- private byte[] getRLEBytes(final InputStream is, final int RLESamplesPerByte)
- throws IOException {
+ private byte[] getRLEBytes(final InputStream is, final int rleSamplesPerByte) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
// this.setDebug(true);
@@ -292,8 +291,8 @@ public class BmpImageParser extends Imag
}
break;
default: {
- int size = b / RLESamplesPerByte;
- if ((b % RLESamplesPerByte) > 0) {
+ int size = b / rleSamplesPerByte;
+ if ((b % rleSamplesPerByte) > 0) {
size++;
}
if ((size % 2) != 0) {
@@ -415,7 +414,7 @@ public class BmpImageParser extends Imag
final int pixelCount = bhi.width * bhi.height;
- int imageLineLength = ((((bhi.bitsPerPixel) * bhi.width) + 7) / 8);
+ int imageLineLength = (((bhi.bitsPerPixel) * bhi.width) + 7) / 8;
if (verbose) {
// this.debugNumber("Total BitsPerPixel",
@@ -558,23 +557,23 @@ public class BmpImageParser extends Imag
return null;
}
- private String getBmpTypeDescription(final int Identifier1, final int Identifier2) {
- if ((Identifier1 == 'B') && (Identifier2 == 'M')) {
+ private String getBmpTypeDescription(final int identifier1, final int identifier2) {
+ if ((identifier1 == 'B') && (identifier2 == 'M')) {
return "Windows 3.1x, 95, NT,";
}
- if ((Identifier1 == 'B') && (Identifier2 == 'A')) {
+ if ((identifier1 == 'B') && (identifier2 == 'A')) {
return "OS/2 Bitmap Array";
}
- if ((Identifier1 == 'C') && (Identifier2 == 'I')) {
+ if ((identifier1 == 'C') && (identifier2 == 'I')) {
return "OS/2 Color Icon";
}
- if ((Identifier1 == 'C') && (Identifier2 == 'P')) {
+ if ((identifier1 == 'C') && (identifier2 == 'P')) {
return "OS/2 Color Pointer";
}
- if ((Identifier1 == 'I') && (Identifier2 == 'C')) {
+ if ((identifier1 == 'I') && (identifier2 == 'C')) {
return "OS/2 Icon";
}
- if ((Identifier1 == 'P') && (Identifier2 == 'T')) {
+ if ((identifier1 == 'P') && (identifier2 == 'T')) {
return "OS/2 Pointer";
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/ImageContents.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/ImageContents.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/ImageContents.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/ImageContents.java Wed Nov 27 11:21:14 2013
@@ -19,17 +19,17 @@ package org.apache.commons.imaging.forma
import org.apache.commons.imaging.formats.bmp.pixelparsers.PixelParser;
class ImageContents {
+
public final BmpHeaderInfo bhi;
public final byte[] colorTable;
public final byte[] imageData;
public final PixelParser pixelParser;
- public ImageContents(final BmpHeaderInfo bhi, final byte[] ColorTable,
- final byte[] ImageData, final PixelParser fPixelParser) {
+ public ImageContents(BmpHeaderInfo bhi, byte[] colorTable, byte[] imageData, PixelParser pixelParser) {
this.bhi = bhi;
- this.colorTable = ColorTable;
- this.imageData = ImageData;
- this.pixelParser = fPixelParser;
+ this.colorTable = colorTable;
+ this.imageData = imageData;
+ this.pixelParser = pixelParser;
}
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java Wed Nov 27 11:21:14 2013
@@ -22,10 +22,10 @@ import org.apache.commons.imaging.ImageR
import org.apache.commons.imaging.formats.bmp.BmpHeaderInfo;
public class PixelParserRgb extends PixelParserSimple {
- private int bytecount = 0;
- private int cached_bit_count = 0;
- private int cached_byte = 0;
- int pixelCount = 0;
+ private int bytecount;
+ private int cachedBitCount;
+ private int cachedByte;
+ private int pixelCount;
public PixelParserRgb(final BmpHeaderInfo bhi, final byte[] colorTable,
final byte[] imageData) {
@@ -39,20 +39,20 @@ public class PixelParserRgb extends Pixe
if ((bhi.bitsPerPixel == 1)
|| (bhi.bitsPerPixel == 4)) { // always grayscale?
- if (cached_bit_count < bhi.bitsPerPixel) {
- if (cached_bit_count != 0) {
+ if (cachedBitCount < bhi.bitsPerPixel) {
+ if (cachedBitCount != 0) {
throw new ImageReadException("Unexpected leftover bits: "
- + cached_bit_count + "/" + bhi.bitsPerPixel);
+ + cachedBitCount + "/" + bhi.bitsPerPixel);
}
- cached_bit_count += 8;
- cached_byte = (0xff & imageData[bytecount]);
+ cachedBitCount += 8;
+ cachedByte = (0xff & imageData[bytecount]);
bytecount++;
}
- final int cache_mask = (1 << bhi.bitsPerPixel) - 1;
- final int sample = cache_mask & (cached_byte >> (8 - bhi.bitsPerPixel));
- cached_byte = 0xff & (cached_byte << bhi.bitsPerPixel);
- cached_bit_count -= bhi.bitsPerPixel;
+ final int cacheMask = (1 << bhi.bitsPerPixel) - 1;
+ final int sample = cacheMask & (cachedByte >> (8 - bhi.bitsPerPixel));
+ cachedByte = 0xff & (cachedByte << bhi.bitsPerPixel);
+ cachedBitCount -= bhi.bitsPerPixel;
return getColorTableRGB(sample);
} else if (bhi.bitsPerPixel == 8) { // always grayscale?
@@ -106,7 +106,7 @@ public class PixelParserRgb extends Pixe
@Override
public void newline() throws ImageReadException, IOException {
- cached_bit_count = 0;
+ cachedBitCount = 0;
while (((bytecount) % 4) != 0) {
is.readByte("Pixel", "BMP Image Data");
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRle.java Wed Nov 27 11:21:14 2013
@@ -65,7 +65,7 @@ public class PixelParserRle extends Pixe
private int processByteOfData(final int[] rgbs, final int repeat, int x, final int y,
final int width, final int height, final ImageBuilder imageBuilder) {
// int rbg
- int pixels_written = 0;
+ int pixelsWritten = 0;
for (int i = 0; i < repeat; i++) {
if ((x >= 0) && (x < width) && (y >= 0) && (y < height)) {
@@ -80,10 +80,10 @@ public class PixelParserRle extends Pixe
}
x++;
- pixels_written++;
+ pixelsWritten++;
}
- return pixels_written;
+ return pixelsWritten;
}
@Override
@@ -95,10 +95,8 @@ public class PixelParserRle extends Pixe
boolean done = false;
while (!done) {
- final int a = 0xff & is.readByte("RLE (" + x + "," + y + ") a",
- "BMP: Bad RLE");
- final int b = 0xff & is.readByte("RLE (" + x + "," + y + ") b",
- "BMP: Bad RLE");
+ final int a = 0xff & is.readByte("RLE (" + x + "," + y + ") a", "BMP: Bad RLE");
+ final int b = 0xff & is.readByte("RLE (" + x + "," + y + ") b", "BMP: Bad RLE");
if (a == 0) {
switch (b) {
@@ -120,9 +118,9 @@ public class PixelParserRle extends Pixe
break;
}
default: {
- final int SamplesPerByte = getSamplesPerByte();
- int size = b / SamplesPerByte;
- if ((b % SamplesPerByte) > 0) {
+ final int samplesPerByte = getSamplesPerByte();
+ int size = b / samplesPerByte;
+ if ((b % samplesPerByte) > 0) {
size++;
}
if ((size % 2) != 0) {
@@ -141,7 +139,7 @@ public class PixelParserRle extends Pixe
for (int i = 0; remaining > 0; i++) {
// for (int i = 0; i < bytes.length; i++)
final int[] samples = convertDataToSamples(0xff & bytes[i]);
- final int towrite = Math.min(remaining, SamplesPerByte);
+ final int towrite = Math.min(remaining, samplesPerByte);
// System.out.println("remaining: " + remaining);
// System.out.println("SamplesPerByte: "
// + SamplesPerByte);
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/writers/BmpWriterPalette.java Wed Nov 27 11:21:14 2013
@@ -72,8 +72,8 @@ public class BmpWriterPalette extends Bm
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int bit_cache = 0;
- int bits_in_cache = 0;
+ int bitCache = 0;
+ int bitsInCache = 0;
int bytecount = 0;
for (int y = height - 1; y >= 0; y--) {
@@ -88,24 +88,24 @@ public class BmpWriterPalette extends Bm
bytecount++;
} else {
// 4 or 1
- bit_cache = (bit_cache << bitsPerSample) | index;
- bits_in_cache += bitsPerSample;
- if (bits_in_cache >= 8) {
- baos.write(0xff & bit_cache);
+ bitCache = (bitCache << bitsPerSample) | index;
+ bitsInCache += bitsPerSample;
+ if (bitsInCache >= 8) {
+ baos.write(0xff & bitCache);
bytecount++;
- bit_cache = 0;
- bits_in_cache = 0;
+ bitCache = 0;
+ bitsInCache = 0;
}
}
}
- if (bits_in_cache > 0) {
- bit_cache = (bit_cache << (8 - bits_in_cache));
+ if (bitsInCache > 0) {
+ bitCache = (bitCache << (8 - bitsInCache));
- baos.write(0xff & bit_cache);
+ baos.write(0xff & bitCache);
bytecount++;
- bit_cache = 0;
- bits_in_cache = 0;
+ bitCache = 0;
+ bitsInCache = 0;
}
while ((bytecount % 4) != 0) {
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifHeaderInfo.java Wed Nov 27 11:21:14 2013
@@ -34,26 +34,26 @@ class GifHeaderInfo {
public final boolean sortFlag;
public final byte sizeOfGlobalColorTable;
- public GifHeaderInfo(final byte Identifier1, final byte Identifier2, final byte Identifier3,
- final byte Version1, final byte Version2, final byte Version3,
- final int LogicalScreenWidth, final int LogicalScreenHeight, final byte PackedFields,
- final byte BackgroundColorIndex, final byte PixelAspectRatio,
- final boolean GlobalColorTableFlag, final byte ColorResolution,
- final boolean SortFlag, final byte SizeofGlobalColorTable) {
- this.identifier1 = Identifier1;
- this.identifier2 = Identifier2;
- this.identifier3 = Identifier3;
- this.version1 = Version1;
- this.version2 = Version2;
- this.version3 = Version3;
- this.logicalScreenWidth = LogicalScreenWidth;
- this.logicalScreenHeight = LogicalScreenHeight;
- this.packedFields = PackedFields;
- this.backgroundColorIndex = BackgroundColorIndex;
- this.pixelAspectRatio = PixelAspectRatio;
- this.globalColorTableFlag = GlobalColorTableFlag;
- this.colorResolution = ColorResolution;
- this.sortFlag = SortFlag;
- this.sizeOfGlobalColorTable = SizeofGlobalColorTable;
+ public GifHeaderInfo(final byte identifier1, final byte identifier2, final byte identifier3,
+ final byte version1, final byte version2, final byte version3,
+ final int logicalScreenWidth, final int logicalScreenHeight, final byte packedFields,
+ final byte backgroundColorIndex, final byte pixelAspectRatio,
+ final boolean globalColorTableFlag, final byte colorResolution,
+ final boolean sortFlag, final byte sizeOfGlobalColorTable) {
+ this.identifier1 = identifier1;
+ this.identifier2 = identifier2;
+ this.identifier3 = identifier3;
+ this.version1 = version1;
+ this.version2 = version2;
+ this.version3 = version3;
+ this.logicalScreenWidth = logicalScreenWidth;
+ this.logicalScreenHeight = logicalScreenHeight;
+ this.packedFields = packedFields;
+ this.backgroundColorIndex = backgroundColorIndex;
+ this.pixelAspectRatio = pixelAspectRatio;
+ this.globalColorTableFlag = globalColorTableFlag;
+ this.colorResolution = colorResolution;
+ this.sortFlag = sortFlag;
+ this.sizeOfGlobalColorTable = sizeOfGlobalColorTable;
}
}
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java Wed Nov 27 11:21:14 2013
@@ -116,8 +116,8 @@ public class GifImageParser extends Imag
final byte version3 = readByte("version3", is, "Not a Valid GIF File");
if (formatCompliance != null) {
- formatCompliance.compare_bytes("Signature", GIF_HEADER_SIGNATURE,
- new byte[] { identifier1, identifier2, identifier3, });
+ formatCompliance.compareBytes("Signature", GIF_HEADER_SIGNATURE,
+ new byte[]{identifier1, identifier2, identifier3,});
formatCompliance.compare("version", 56, version1);
formatCompliance
.compare("version", new int[] { 55, 57, }, version2);
@@ -207,9 +207,9 @@ public class GifImageParser extends Imag
}
private byte[] readSubBlock(final InputStream is) throws IOException {
- final int block_size = 0xff & readByte("block_size", is, "GIF: corrupt block");
+ final int blockSize = 0xff & readByte("block_size", is, "GIF: corrupt block");
- return readBytes("block", is, block_size, "GIF: corrupt block");
+ return readBytes("block", is, blockSize, "GIF: corrupt block");
}
protected GenericGifBlock readGenericGIFBlock(final InputStream is, final int code)
@@ -335,57 +335,49 @@ public class GifImageParser extends Imag
final int blockCode, final InputStream is, final boolean stopBeforeImageData,
final FormatCompliance formatCompliance) throws ImageReadException,
IOException {
- final int ImageLeftPosition = read2Bytes("Image Left Position", is,
- "Not a Valid GIF File");
- final int ImageTopPosition = read2Bytes("Image Top Position", is,
- "Not a Valid GIF File");
+ final int imageLeftPosition = read2Bytes("Image Left Position", is, "Not a Valid GIF File");
+ final int imageTopPosition = read2Bytes("Image Top Position", is, "Not a Valid GIF File");
final int imageWidth = read2Bytes("Image Width", is, "Not a Valid GIF File");
final int imageHeight = read2Bytes("Image Height", is, "Not a Valid GIF File");
- final byte PackedFields = readByte("Packed Fields", is,
- "Not a Valid GIF File");
+ final byte packedFields = readByte("Packed Fields", is, "Not a Valid GIF File");
if (formatCompliance != null) {
- formatCompliance.checkBounds("Width", 1, ghi.logicalScreenWidth,
- imageWidth);
- formatCompliance.checkBounds("Height", 1, ghi.logicalScreenHeight,
- imageHeight);
- formatCompliance.checkBounds("Left Position", 0,
- ghi.logicalScreenWidth - imageWidth, ImageLeftPosition);
- formatCompliance.checkBounds("Top Position", 0,
- ghi.logicalScreenHeight - imageHeight, ImageTopPosition);
+ formatCompliance.checkBounds("Width", 1, ghi.logicalScreenWidth, imageWidth);
+ formatCompliance.checkBounds("Height", 1, ghi.logicalScreenHeight, imageHeight);
+ formatCompliance.checkBounds("Left Position", 0, ghi.logicalScreenWidth - imageWidth, imageLeftPosition);
+ formatCompliance.checkBounds("Top Position", 0, ghi.logicalScreenHeight - imageHeight, imageTopPosition);
}
if (getDebug()) {
- printByteBits("PackedFields bits", PackedFields);
+ printByteBits("PackedFields bits", packedFields);
}
- final boolean LocalColorTableFlag = (((PackedFields >> 7) & 1) > 0);
+ final boolean localColorTableFlag = (((packedFields >> 7) & 1) > 0);
if (getDebug()) {
- System.out.println("LocalColorTableFlag: " + LocalColorTableFlag);
+ System.out.println("LocalColorTableFlag: " + localColorTableFlag);
}
- final boolean InterlaceFlag = (((PackedFields >> 6) & 1) > 0);
+ final boolean interlaceFlag = (((packedFields >> 6) & 1) > 0);
if (getDebug()) {
- System.out.println("Interlace Flag: " + InterlaceFlag);
+ System.out.println("Interlace Flag: " + interlaceFlag);
}
- final boolean SortFlag = (((PackedFields >> 5) & 1) > 0);
+ final boolean sortFlag = (((packedFields >> 5) & 1) > 0);
if (getDebug()) {
- System.out.println("Sort Flag: " + SortFlag);
+ System.out.println("Sort Flag: " + sortFlag);
}
- final byte SizeofLocalColorTable = (byte) (PackedFields & 7);
+ final byte sizeOfLocalColorTable = (byte) (packedFields & 7);
if (getDebug()) {
- System.out.println("SizeofLocalColorTable: "
- + SizeofLocalColorTable);
+ System.out.println("SizeofLocalColorTable: " + sizeOfLocalColorTable);
}
byte[] localColorTable = null;
- if (LocalColorTableFlag) {
- localColorTable = readColorTable(is, SizeofLocalColorTable);
+ if (localColorTableFlag) {
+ localColorTable = readColorTable(is, sizeOfLocalColorTable);
}
byte[] imageData = null;
if (!stopBeforeImageData) {
- final int LZWMinimumCodeSize = is.read();
+ final int lzwMinimumCodeSize = is.read();
final GenericGifBlock block = readGenericGIFBlock(is, -1);
final byte[] bytes = block.appendSubBlocks();
@@ -393,7 +385,7 @@ public class GifImageParser extends Imag
final int size = imageWidth * imageHeight;
final MyLzwDecompressor myLzwDecompressor = new MyLzwDecompressor(
- LZWMinimumCodeSize, ByteOrder.LITTLE_ENDIAN);
+ lzwMinimumCodeSize, ByteOrder.LITTLE_ENDIAN);
imageData = myLzwDecompressor.decompress(bais, size);
} else {
final int LZWMinimumCodeSize = is.read();
@@ -405,12 +397,12 @@ public class GifImageParser extends Imag
}
return new ImageDescriptor(blockCode,
- ImageLeftPosition, ImageTopPosition, imageWidth, imageHeight,
- PackedFields, LocalColorTableFlag, InterlaceFlag, SortFlag,
- SizeofLocalColorTable, localColorTable, imageData);
+ imageLeftPosition, imageTopPosition, imageWidth, imageHeight,
+ packedFields, localColorTableFlag, interlaceFlag, sortFlag,
+ sizeOfLocalColorTable, localColorTable, imageData);
}
- private int simple_pow(final int base, final int power) {
+ private int simplePow(final int base, final int power) {
int result = 1;
for (int i = 0; i < power; i++) {
@@ -420,14 +412,14 @@ public class GifImageParser extends Imag
return result;
}
- private int convertColorTableSize(final int ct_size) {
- return 3 * simple_pow(2, ct_size + 1);
+ private int convertColorTableSize(final int tableSize) {
+ return 3 * simplePow(2, tableSize + 1);
}
- private byte[] readColorTable(final InputStream is, final int ct_size) throws IOException {
- final int actual_size = convertColorTableSize(ct_size);
+ private byte[] readColorTable(final InputStream is, final int tableSize) throws IOException {
+ final int actualSize = convertColorTableSize(tableSize);
- return readBytes("block", is, actual_size, "GIF: corrupt Color Table");
+ return readBytes("block", is, actualSize, "GIF: corrupt Color Table");
}
private GifBlock findBlock(final List<GifBlock> blocks, final int code) {
@@ -717,24 +709,23 @@ public class GifImageParser extends Imag
for (int row = 0; row < height; row++) {
int y;
if (id.interlaceFlag) {
- int the_row = row;
- if (the_row < rowsInPass1) {
- y = the_row * 8;
+ int theRow = row;
+ if (theRow < rowsInPass1) {
+ y = theRow * 8;
} else {
- the_row -= rowsInPass1;
- if (the_row < (rowsInPass2)) {
- y = 4 + (the_row * 8);
+ theRow -= rowsInPass1;
+ if (theRow < (rowsInPass2)) {
+ y = 4 + (theRow * 8);
} else {
- the_row -= rowsInPass2;
- if (the_row < (rowsInPass3)) {
- y = 2 + (the_row * 4);
+ theRow -= rowsInPass2;
+ if (theRow < (rowsInPass3)) {
+ y = 2 + (theRow * 4);
} else {
- the_row -= rowsInPass3;
- if (the_row < (rowsInPass4)) {
- y = 1 + (the_row * 2);
+ theRow -= rowsInPass3;
+ if (theRow < (rowsInPass4)) {
+ y = 1 + (theRow * 2);
} else {
- throw new ImageReadException(
- "Gif: Strange Row");
+ throw new ImageReadException("Gif: Strange Row");
}
}
}
@@ -760,15 +751,14 @@ public class GifImageParser extends Imag
}
- private void writeAsSubBlocks(final OutputStream os, final byte[] bytes)
- throws IOException {
+ private void writeAsSubBlocks(final OutputStream os, final byte[] bytes) throws IOException {
int index = 0;
while (index < bytes.length) {
- final int block_size = Math.min(bytes.length - index, 255);
- os.write(block_size);
- os.write(bytes, index, block_size);
- index += block_size;
+ final int blockSize = Math.min(bytes.length - index, 255);
+ os.write(blockSize);
+ os.write(bytes, index, blockSize);
+ index += blockSize;
}
os.write(0); // last block
}
@@ -805,16 +795,14 @@ public class GifImageParser extends Imag
final boolean hasAlpha = new PaletteFactory().hasTransparency(src);
- final int max_colors = hasAlpha ? 255 : 256;
+ final int maxColors = hasAlpha ? 255 : 256;
- Palette palette2 = new PaletteFactory().makeExactRgbPaletteSimple(src,
- max_colors);
+ Palette palette2 = new PaletteFactory().makeExactRgbPaletteSimple(src, maxColors);
// int palette[] = new PaletteFactory().makePaletteSimple(src, 256);
// Map palette_map = paletteToMap(palette);
if (palette2 == null) {
- palette2 = new PaletteFactory().makeQuantizedRgbPalette(src,
- max_colors);
+ palette2 = new PaletteFactory().makeQuantizedRgbPalette(src, maxColors);
if (verbose) {
System.out.println("quantizing");
}
@@ -823,10 +811,9 @@ public class GifImageParser extends Imag
}
if (palette2 == null) {
- throw new ImageWriteException(
- "Gif: can't write images with more than 256 colors");
+ throw new ImageWriteException("Gif: can't write images with more than 256 colors");
}
- final int palette_size = palette2.length() + (hasAlpha ? 1 : 0);
+ final int paletteSize = palette2.length() + (hasAlpha ? 1 : 0);
final BinaryOutputStream bos = new BinaryOutputStream(os, ByteOrder.LITTLE_ENDIAN);
@@ -844,11 +831,11 @@ public class GifImageParser extends Imag
bos.write2Bytes(width);
bos.write2Bytes(height);
- final int colorTableScaleLessOne = (palette_size > 128) ? 7
- : (palette_size > 64) ? 6 : (palette_size > 32) ? 5
- : (palette_size > 16) ? 4 : (palette_size > 8) ? 3
- : (palette_size > 4) ? 2
- : (palette_size > 2) ? 1 : 0;
+ final int colorTableScaleLessOne = (paletteSize > 128) ? 7
+ : (paletteSize > 64) ? 6 : (paletteSize > 32) ? 5
+ : (paletteSize > 16) ? 4 : (paletteSize > 8) ? 3
+ : (paletteSize > 4) ? 2
+ : (paletteSize > 2) ? 1 : 0;
final int colorTableSizeInFormat = 1 << (colorTableScaleLessOne + 1);
{
@@ -867,12 +854,12 @@ public class GifImageParser extends Imag
bos.write(packedFields); // one byte
}
{
- final byte BackgroundColorIndex = 0;
- bos.write(BackgroundColorIndex);
+ final byte backgroundColorIndex = 0;
+ bos.write(backgroundColorIndex);
}
{
- final byte PixelAspectRatio = 0;
- bos.write(PixelAspectRatio);
+ final byte pixelAspectRatio = 0;
+ bos.write(pixelAspectRatio);
}
//{
@@ -924,19 +911,27 @@ public class GifImageParser extends Imag
bos.write2Bytes(height); // Image Height
{
- final boolean LocalColorTableFlag = true;
+ final boolean localColorTableFlag = true;
// boolean LocalColorTableFlag = false;
- final boolean InterlaceFlag = false;
- final boolean SortFlag = false;
- final int SizeOfLocalColorTable = colorTableScaleLessOne;
+ final boolean interlaceFlag = false;
+ final boolean sortFlag = false;
+ final int sizeOfLocalColorTable = colorTableScaleLessOne;
// int SizeOfLocalColorTable = 0;
- final int PackedFields = ((LocalColorTableFlag ? LOCAL_COLOR_TABLE_FLAG_MASK
- : 0)
- | (InterlaceFlag ? INTERLACE_FLAG_MASK : 0)
- | (SortFlag ? SORT_FLAG_MASK : 0) | (7 & SizeOfLocalColorTable));
- bos.write(PackedFields); // one byte
+ final int packedFields;
+ if (localColorTableFlag) {
+ packedFields = (LOCAL_COLOR_TABLE_FLAG_MASK
+ | (interlaceFlag ? INTERLACE_FLAG_MASK : 0)
+ | (sortFlag ? SORT_FLAG_MASK : 0)
+ | (7 & sizeOfLocalColorTable));
+ } else {
+ packedFields = (0
+ | (interlaceFlag ? INTERLACE_FLAG_MASK : 0)
+ | (sortFlag ? SORT_FLAG_MASK : 0)
+ | (7 & sizeOfLocalColorTable));
+ }
+ bos.write(packedFields); // one byte
}
}
@@ -963,10 +958,10 @@ public class GifImageParser extends Imag
{ // get Image Data.
// int image_data_total = 0;
- int LZWMinimumCodeSize = colorTableScaleLessOne + 1;
+ int lzwMinimumCodeSize = colorTableScaleLessOne + 1;
// LZWMinimumCodeSize = Math.max(8, LZWMinimumCodeSize);
- if (LZWMinimumCodeSize < 2) {
- LZWMinimumCodeSize = 2;
+ if (lzwMinimumCodeSize < 2) {
+ lzwMinimumCodeSize = 2;
}
// TODO:
@@ -974,10 +969,10 @@ public class GifImageParser extends Imag
// better
// choice
// here.
- bos.write(LZWMinimumCodeSize);
+ bos.write(lzwMinimumCodeSize);
final MyLzwCompressor compressor = new MyLzwCompressor(
- LZWMinimumCodeSize, ByteOrder.LITTLE_ENDIAN, false); // GIF
+ lzwMinimumCodeSize, ByteOrder.LITTLE_ENDIAN, false); // GIF
// Mode);
final byte[] imagedata = new byte[width * height];
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java Wed Nov 27 11:21:14 2013
@@ -161,15 +161,14 @@ public class IcnsImageParser extends Ima
private IcnsHeader readIcnsHeader(final InputStream is)
throws ImageReadException, IOException {
- final int Magic = read4Bytes("Magic", is, "Not a Valid ICNS File");
- final int FileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File");
+ final int magic = read4Bytes("Magic", is, "Not a Valid ICNS File");
+ final int fileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File");
- if (Magic != ICNS_MAGIC) {
- throw new ImageReadException("Not a Valid ICNS File: "
- + "magic is 0x" + Integer.toHexString(Magic));
+ if (magic != ICNS_MAGIC) {
+ throw new ImageReadException("Not a Valid ICNS File: " + "magic is 0x" + Integer.toHexString(magic));
}
- return new IcnsHeader(Magic, FileSize);
+ return new IcnsHeader(magic, fileSize);
}
public static class IcnsElement {
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java?rev=1545998&r1=1545997&r2=1545998&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java Wed Nov 27 11:21:14 2013
@@ -25,76 +25,66 @@ public final class IcnsType {
private final int bitsPerPixel;
private final boolean hasMask;
- public static final IcnsType ICNS_16x12_1BIT_IMAGE_AND_MASK = new IcnsType(
- "icm#", 16, 12, 1, true);
- public static final IcnsType ICNS_16x12_4BIT_IMAGE = new IcnsType("icm4",
- 16, 12, 4, false);
- public static final IcnsType ICNS_16x12_8BIT_IMAGE = new IcnsType("icm8",
- 16, 12, 8, false);
-
- public static final IcnsType ICNS_16x16_8BIT_MASK = new IcnsType("s8mk",
- 16, 16, 8, true);
- public static final IcnsType ICNS_16x16_1BIT_IMAGE_AND_MASK = new IcnsType(
- "ics#", 16, 16, 1, true);
- public static final IcnsType ICNS_16x16_4BIT_IMAGE = new IcnsType("ics4",
- 16, 16, 4, false);
- public static final IcnsType ICNS_16x16_8BIT_IMAGE = new IcnsType("ics8",
- 16, 16, 8, false);
- public static final IcnsType ICNS_16x16_32BIT_IMAGE = new IcnsType("is32",
- 16, 16, 32, false);
-
- public static final IcnsType ICNS_32x32_8BIT_MASK = new IcnsType("l8mk",
- 32, 32, 8, true);
- public static final IcnsType ICNS_32x32_1BIT_IMAGE_AND_MASK = new IcnsType(
- "ICN#", 32, 32, 1, true);
- public static final IcnsType ICNS_32x32_4BIT_IMAGE = new IcnsType("icl4",
- 32, 32, 4, false);
- public static final IcnsType ICNS_32x32_8BIT_IMAGE = new IcnsType("icl8",
- 32, 32, 8, false);
- public static final IcnsType ICNS_32x32_32BIT_IMAGE = new IcnsType("il32",
- 32, 32, 32, false);
-
- public static final IcnsType ICNS_48x48_8BIT_MASK = new IcnsType("h8mk",
- 48, 48, 8, true);
- public static final IcnsType ICNS_48x48_1BIT_IMAGE_AND_MASK = new IcnsType(
- "ich#", 48, 48, 1, true);
- public static final IcnsType ICNS_48x48_4BIT_IMAGE = new IcnsType("ich4",
- 48, 48, 4, false);
- public static final IcnsType ICNS_48x48_8BIT_IMAGE = new IcnsType("ich8",
- 48, 48, 8, false);
- public static final IcnsType ICNS_48x48_32BIT_IMAGE = new IcnsType("ih32",
- 48, 48, 32, false);
-
- public static final IcnsType ICNS_128x128_8BIT_MASK = new IcnsType("t8mk",
- 128, 128, 8, true);
- public static final IcnsType ICNS_128x128_32BIT_IMAGE = new IcnsType(
- "it32", 128, 128, 32, false);
+ public static final IcnsType ICNS_16x12_1BIT_IMAGE_AND_MASK = new IcnsType("icm#", 16, 12, 1, true);
+ public static final IcnsType ICNS_16x12_4BIT_IMAGE = new IcnsType("icm4", 16, 12, 4, false);
+ public static final IcnsType ICNS_16x12_8BIT_IMAGE = new IcnsType("icm8", 16, 12, 8, false);
+
+ public static final IcnsType ICNS_16x16_8BIT_MASK = new IcnsType("s8mk", 16, 16, 8, true);
+ public static final IcnsType ICNS_16x16_1BIT_IMAGE_AND_MASK = new IcnsType("ics#", 16, 16, 1, true);
+ public static final IcnsType ICNS_16x16_4BIT_IMAGE = new IcnsType("ics4", 16, 16, 4, false);
+ public static final IcnsType ICNS_16x16_8BIT_IMAGE = new IcnsType("ics8", 16, 16, 8, false);
+ public static final IcnsType ICNS_16x16_32BIT_IMAGE = new IcnsType("is32", 16, 16, 32, false);
+
+ public static final IcnsType ICNS_32x32_8BIT_MASK = new IcnsType("l8mk", 32, 32, 8, true);
+ public static final IcnsType ICNS_32x32_1BIT_IMAGE_AND_MASK = new IcnsType("ICN#", 32, 32, 1, true);
+ public static final IcnsType ICNS_32x32_4BIT_IMAGE = new IcnsType("icl4", 32, 32, 4, false);
+ public static final IcnsType ICNS_32x32_8BIT_IMAGE = new IcnsType("icl8", 32, 32, 8, false);
+ public static final IcnsType ICNS_32x32_32BIT_IMAGE = new IcnsType("il32", 32, 32, 32, false);
+
+ public static final IcnsType ICNS_48x48_8BIT_MASK = new IcnsType("h8mk", 48, 48, 8, true);
+ public static final IcnsType ICNS_48x48_1BIT_IMAGE_AND_MASK = new IcnsType("ich#", 48, 48, 1, true);
+ public static final IcnsType ICNS_48x48_4BIT_IMAGE = new IcnsType("ich4", 48, 48, 4, false);
+ public static final IcnsType ICNS_48x48_8BIT_IMAGE = new IcnsType("ich8", 48, 48, 8, false);
+ public static final IcnsType ICNS_48x48_32BIT_IMAGE = new IcnsType("ih32", 48, 48, 32, false);
- public static final IcnsType ICNS_256x256_32BIT_ARGB_IMAGE = new IcnsType(
- "ic08", 256, 256, 32, false);
+ public static final IcnsType ICNS_128x128_8BIT_MASK = new IcnsType("t8mk", 128, 128, 8, true);
+ public static final IcnsType ICNS_128x128_32BIT_IMAGE = new IcnsType("it32", 128, 128, 32, false);
- public static final IcnsType ICNS_512x512_32BIT_ARGB_IMAGE = new IcnsType(
- "ic09", 512, 512, 32, false);
+ public static final IcnsType ICNS_256x256_32BIT_ARGB_IMAGE = new IcnsType("ic08", 256, 256, 32, false);
+
+ public static final IcnsType ICNS_512x512_32BIT_ARGB_IMAGE = new IcnsType("ic09", 512, 512, 32, false);
private static final IcnsType[] ALL_IMAGE_TYPES = {
- ICNS_16x12_1BIT_IMAGE_AND_MASK, ICNS_16x12_4BIT_IMAGE,
- ICNS_16x12_8BIT_IMAGE, ICNS_16x16_1BIT_IMAGE_AND_MASK,
- ICNS_16x16_4BIT_IMAGE, ICNS_16x16_8BIT_IMAGE,
- ICNS_16x16_32BIT_IMAGE, ICNS_32x32_1BIT_IMAGE_AND_MASK,
- ICNS_32x32_4BIT_IMAGE, ICNS_32x32_8BIT_IMAGE,
- ICNS_32x32_32BIT_IMAGE, ICNS_48x48_1BIT_IMAGE_AND_MASK,
- ICNS_48x48_4BIT_IMAGE, ICNS_48x48_8BIT_IMAGE,
- ICNS_48x48_32BIT_IMAGE, ICNS_128x128_32BIT_IMAGE,
- ICNS_256x256_32BIT_ARGB_IMAGE, ICNS_512x512_32BIT_ARGB_IMAGE };
+ ICNS_16x12_1BIT_IMAGE_AND_MASK,
+ ICNS_16x12_4BIT_IMAGE,
+ ICNS_16x12_8BIT_IMAGE,
+ ICNS_16x16_1BIT_IMAGE_AND_MASK,
+ ICNS_16x16_4BIT_IMAGE,
+ ICNS_16x16_8BIT_IMAGE,
+ ICNS_16x16_32BIT_IMAGE,
+ ICNS_32x32_1BIT_IMAGE_AND_MASK,
+ ICNS_32x32_4BIT_IMAGE,
+ ICNS_32x32_8BIT_IMAGE,
+ ICNS_32x32_32BIT_IMAGE,
+ ICNS_48x48_1BIT_IMAGE_AND_MASK,
+ ICNS_48x48_4BIT_IMAGE,
+ ICNS_48x48_8BIT_IMAGE,
+ ICNS_48x48_32BIT_IMAGE,
+ ICNS_128x128_32BIT_IMAGE,
+ ICNS_256x256_32BIT_ARGB_IMAGE,
+ ICNS_512x512_32BIT_ARGB_IMAGE};
private static final IcnsType[] ALL_MASK_TYPES = {
- ICNS_16x12_1BIT_IMAGE_AND_MASK, ICNS_16x16_1BIT_IMAGE_AND_MASK,
- ICNS_16x16_8BIT_MASK, ICNS_32x32_1BIT_IMAGE_AND_MASK,
- ICNS_32x32_8BIT_MASK, ICNS_48x48_1BIT_IMAGE_AND_MASK,
- ICNS_48x48_8BIT_MASK, ICNS_128x128_8BIT_MASK };
+ ICNS_16x12_1BIT_IMAGE_AND_MASK,
+ ICNS_16x16_1BIT_IMAGE_AND_MASK,
+ ICNS_16x16_8BIT_MASK,
+ ICNS_32x32_1BIT_IMAGE_AND_MASK,
+ ICNS_32x32_8BIT_MASK,
+ ICNS_48x48_1BIT_IMAGE_AND_MASK,
+ ICNS_48x48_8BIT_MASK,
+ ICNS_128x128_8BIT_MASK};
- private IcnsType(final String type, final int width, final int height, final int bitsPerPixel,
- final boolean hasMask) {
+ private IcnsType(String type, int width, int height, int bitsPerPixel, boolean hasMask) {
this.type = typeAsInt(type);
this.width = width;
this.height = height;
@@ -175,7 +165,7 @@ public final class IcnsType {
}
public static int typeAsInt(final String type) {
- byte[] bytes = null;
+ byte[] bytes;
try {
bytes = type.getBytes("US-ASCII");
} catch (final UnsupportedEncodingException unsupportedEncodingException) {