diff --git a/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/svg/SVGImageReader.java b/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/svg/SVGImageReader.java index 8a4ea85d..eb7c405d 100755 --- a/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/svg/SVGImageReader.java +++ b/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/svg/SVGImageReader.java @@ -95,8 +95,8 @@ public class SVGImageReader extends ImageReaderBase { } @Override - public void setInput(Object pInput, boolean pSeekForwardOnly, boolean pIgnoreMetadata) { - super.setInput(pInput, pSeekForwardOnly, pIgnoreMetadata); + public void setInput(Object pInput, boolean seekForwardOnly, boolean ignoreMetadata) { + super.setInput(pInput, seekForwardOnly, ignoreMetadata); if (imageInput != null) { TranscoderInput input = new TranscoderInput(IIOUtil.createStreamAdapter(imageInput)); diff --git a/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReader.java b/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReader.java index 3eebd02d..71916de7 100755 --- a/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReader.java +++ b/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReader.java @@ -126,11 +126,11 @@ public class TIFFImageReader extends ImageReaderBase { checkBounds(pIndex); } - protected void checkBounds(int pIndex) throws IOException { - if (pIndex < getMinIndex()){ + protected void checkBounds(int index) throws IOException { + if (index < getMinIndex()){ throw new IndexOutOfBoundsException("index < minIndex"); } - else if (pIndex >= getNumImages(true)) { + else if (index >= getNumImages(true)) { throw new IndexOutOfBoundsException("index > numImages"); } } @@ -179,9 +179,9 @@ public class TIFFImageReader extends ImageReaderBase { throw new UnsupportedOperationException("Method getImageTypes not implemented");// TODO: Implement } - public int getNumImages(boolean pAllowSearch) throws IOException { + public int getNumImages(boolean allowSearch) throws IOException { init(); - if (pAllowSearch) { + if (allowSearch) { return mDecoder.getNumPages(); } return -1; diff --git a/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageWriter.java b/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageWriter.java index ccf33c48..c203e2e7 100755 --- a/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageWriter.java +++ b/imageio/imageio-batik/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageWriter.java @@ -60,9 +60,9 @@ public class TIFFImageWriter extends ImageWriterBase { } @Override - public void setOutput(final Object pOutput) { + public void setOutput(final Object output) { mEncoder = null; - super.setOutput(pOutput); + super.setOutput(output); } public IIOMetadata getDefaultImageMetadata(final ImageTypeSpecifier imageType, final ImageWriteParam param) { diff --git a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageReaderBase.java b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageReaderBase.java index 4b1bed97..9b3080ea 100644 --- a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageReaderBase.java +++ b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageReaderBase.java @@ -71,21 +71,21 @@ public abstract class ImageReaderBase extends ImageReader { * the extension object is unsuitable, an * {@code IllegalArgumentException} should be thrown. * - * @param pProvider the {@code ImageReaderSpi} that is invoking this constructor, or {@code null}. + * @param provider the {@code ImageReaderSpi} that is invoking this constructor, or {@code null}. */ - protected ImageReaderBase(final ImageReaderSpi pProvider) { - super(pProvider); + protected ImageReaderBase(final ImageReaderSpi provider) { + super(provider); } /** * Overrides {@code setInput}, to allow easy access to the input, in case * it is an {@code ImageInputStream}. * - * @param pInput the {@code ImageInputStream} or other + * @param input the {@code ImageInputStream} or other * {@code Object} to use for future decoding. - * @param pSeekForwardOnly if {@code true}, images and metadata + * @param seekForwardOnly if {@code true}, images and metadata * may only be read in ascending order from this input source. - * @param pIgnoreMetadata if {@code true}, metadata + * @param ignoreMetadata if {@code true}, metadata * may be ignored during reads. * * @exception IllegalArgumentException if {@code input} is @@ -96,11 +96,11 @@ public abstract class ImageReaderBase extends ImageReader { * @see ImageInputStream */ @Override - public void setInput(final Object pInput, final boolean pSeekForwardOnly, final boolean pIgnoreMetadata) { + public void setInput(final Object input, final boolean seekForwardOnly, final boolean ignoreMetadata) { resetMembers(); - super.setInput(pInput, pSeekForwardOnly, pIgnoreMetadata); - if (pInput instanceof ImageInputStream) { - imageInput = (ImageInputStream) pInput; + super.setInput(input, seekForwardOnly, ignoreMetadata); + if (input instanceof ImageInputStream) { + imageInput = (ImageInputStream) input; } } @@ -130,11 +130,11 @@ public abstract class ImageReaderBase extends ImageReader { /** * Default implementation that always returns {@code null}. * - * @param pImageIndex ignored, unless overridden + * @param imageIndex ignored, unless overridden * @return {@code null}, unless overridden * @throws IOException never, unless overridden. */ - public IIOMetadata getImageMetadata(int pImageIndex) throws IOException { + public IIOMetadata getImageMetadata(int imageIndex) throws IOException { return null; } @@ -151,11 +151,11 @@ public abstract class ImageReaderBase extends ImageReader { /** * Default implementation that always returns {@code 1}. * - * @param pAllowSearch ignored, unless overridden + * @param allowSearch ignored, unless overridden * @return {@code 1}, unless overridden * @throws IOException never, unless overridden */ - public int getNumImages(boolean pAllowSearch) throws IOException { + public int getNumImages(boolean allowSearch) throws IOException { assertInput(); return 1; } @@ -163,18 +163,18 @@ public abstract class ImageReaderBase extends ImageReader { /** * Convenience method to make sure image index is within bounds. * - * @param pIndex the image index + * @param index the image index * * @throws java.io.IOException if an error occurs during reading - * @throws IndexOutOfBoundsException if not {@code minIndex <= pIndex < numImages} + * @throws IndexOutOfBoundsException if not {@code minIndex <= index < numImages} */ - protected void checkBounds(int pIndex) throws IOException { + protected void checkBounds(int index) throws IOException { assertInput(); - if (pIndex < getMinIndex()) { + if (index < getMinIndex()) { throw new IndexOutOfBoundsException("index < minIndex"); } - else if (getNumImages(false) != -1 && pIndex >= getNumImages(false)) { - throw new IndexOutOfBoundsException("index >= numImages (" + pIndex + " >= " + getNumImages(false) + ")"); + else if (getNumImages(false) != -1 && index >= getNumImages(false)) { + throw new IndexOutOfBoundsException("index >= numImages (" + index + " >= " + getNumImages(false) + ")"); } } diff --git a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageWriterBase.java b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageWriterBase.java index 5f18b336..04e26c71 100755 --- a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageWriterBase.java +++ b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/ImageWriterBase.java @@ -65,10 +65,10 @@ public abstract class ImageWriterBase extends ImageWriter { * the extension object is unsuitable, an * {@code IllegalArgumentException} should be thrown. * - * @param pProvider the {@code ImageWriterSpi} that is constructing this object, or {@code null}. + * @param provider the {@code ImageWriterSpi} that is constructing this object, or {@code null}. */ - protected ImageWriterBase(final ImageWriterSpi pProvider) { - super(pProvider); + protected ImageWriterBase(final ImageWriterSpi provider) { + super(provider); } public String getFormatName() throws IOException { @@ -76,11 +76,11 @@ public abstract class ImageWriterBase extends ImageWriter { } @Override - public void setOutput(final Object pOutput) { - super.setOutput(pOutput); + public void setOutput(final Object output) { + super.setOutput(output); - if (pOutput instanceof ImageOutputStream) { - imageOutput = (ImageOutputStream) pOutput; + if (output instanceof ImageOutputStream) { + imageOutput = (ImageOutputStream) output; } } @@ -98,21 +98,21 @@ public abstract class ImageWriterBase extends ImageWriter { /** * Returns {@code null} * - * @param pParam ignored. + * @param param ignored. * @return {@code null}. */ - public IIOMetadata getDefaultStreamMetadata(final ImageWriteParam pParam) { + public IIOMetadata getDefaultStreamMetadata(final ImageWriteParam param) { return null; } /** * Returns {@code null} * - * @param pInData ignored. - * @param pParam ignored. + * @param inData ignored. + * @param param ignored. * @return {@code null}. */ - public IIOMetadata convertStreamMetadata(final IIOMetadata pInData, final ImageWriteParam pParam) { + public IIOMetadata convertStreamMetadata(final IIOMetadata inData, final ImageWriteParam param) { return null; } diff --git a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/util/ProgressListenerBase.java b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/util/ProgressListenerBase.java index 4a4ba7ff..0a8964af 100755 --- a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/util/ProgressListenerBase.java +++ b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/util/ProgressListenerBase.java @@ -44,51 +44,51 @@ public abstract class ProgressListenerBase implements IIOReadProgressListener, I protected ProgressListenerBase() { } - public void imageComplete(ImageReader pSource) { + public void imageComplete(ImageReader source) { } - public void imageProgress(ImageReader pSource, float pPercentageDone) { + public void imageProgress(ImageReader source, float percentageDone) { } - public void imageStarted(ImageReader pSource, int pImageIndex) { + public void imageStarted(ImageReader source, int imageIndex) { } - public void readAborted(ImageReader pSource) { + public void readAborted(ImageReader source) { } - public void sequenceComplete(ImageReader pSource) { + public void sequenceComplete(ImageReader source) { } - public void sequenceStarted(ImageReader pSource, int pMinIndex) { + public void sequenceStarted(ImageReader source, int minIndex) { } - public void thumbnailComplete(ImageReader pSource) { + public void thumbnailComplete(ImageReader source) { } - public void thumbnailProgress(ImageReader pSource, float pPercentageDone) { + public void thumbnailProgress(ImageReader source, float percentageDone) { } - public void thumbnailStarted(ImageReader pSource, int pImageIndex, int pThumbnailIndex) { + public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) { } - public void imageComplete(ImageWriter pSource) { + public void imageComplete(ImageWriter source ) { } - public void imageProgress(ImageWriter pSource, float pPercentageDone) { + public void imageProgress(ImageWriter source, float percentageDone) { } - public void imageStarted(ImageWriter pSource, int pImageIndex) { + public void imageStarted(ImageWriter source, int imageIndex) { } - public void thumbnailComplete(ImageWriter pSource) { + public void thumbnailComplete(ImageWriter source) { } - public void thumbnailProgress(ImageWriter pSource, float pPercentageDone) { + public void thumbnailProgress(ImageWriter source, float percentageDone) { } - public void thumbnailStarted(ImageWriter pSource, int pImageIndex, int pThumbnailIndex) { + public void thumbnailStarted(ImageWriter source, int imageIndex, int thumbnailIndex) { } - public void writeAborted(ImageWriter pSource) { + public void writeAborted(ImageWriter source) { } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapDescriptor.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapDescriptor.java index 36c67748..de3645b4 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapDescriptor.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapDescriptor.java @@ -39,34 +39,34 @@ import java.awt.image.BufferedImage; * @version $Id: Bitmap.java,v 1.0 25.feb.2006 00:29:44 haku Exp$ */ abstract class BitmapDescriptor { - protected final DirectoryEntry mEntry; - protected final DIBHeader mHeader; + protected final DirectoryEntry entry; + protected final DIBHeader header; - protected BufferedImage mImage; + protected BufferedImage image; public BitmapDescriptor(final DirectoryEntry pEntry, final DIBHeader pHeader) { Validate.notNull(pEntry, "entry"); Validate.notNull(pHeader, "header"); - mEntry = pEntry; - mHeader = pHeader; + entry = pEntry; + header = pHeader; } abstract public BufferedImage getImage(); public final int getWidth() { - return mEntry.getWidth(); + return entry.getWidth(); } public final int getHeight() { - return mEntry.getHeight(); + return entry.getHeight(); } protected final int getColorCount() { - return mEntry.getColorCount() != 0 ? mEntry.getColorCount() : 1 << getBitCount(); + return entry.getColorCount() != 0 ? entry.getColorCount() : 1 << getBitCount(); } protected final int getBitCount() { - return mEntry.getBitCount() != 0 ? mEntry.getBitCount() : mHeader.getBitCount(); + return entry.getBitCount() != 0 ? entry.getBitCount() : header.getBitCount(); } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapIndexed.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapIndexed.java index 2b0e88c5..17fdc28f 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapIndexed.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapIndexed.java @@ -43,17 +43,17 @@ import java.util.Hashtable; * @version $Id: BitmapIndexed.java,v 1.0 25.feb.2006 00:29:44 haku Exp$ */ class BitmapIndexed extends BitmapDescriptor { - protected final int[] mBits; - protected final int[] mColors; + protected final int[] bits; + protected final int[] colors; - private BitmapMask mMask; + private BitmapMask mask; public BitmapIndexed(final DirectoryEntry pEntry, final DIBHeader pHeader) { super(pEntry, pHeader); - mBits = new int[getWidth() * getHeight()]; + bits = new int[getWidth() * getHeight()]; // NOTE: We're adding space for one extra color, for transparency - mColors = new int[getColorCount() + 1]; + colors = new int[getColorCount() + 1]; } public BufferedImage createImageIndexed() { @@ -64,10 +64,9 @@ class BitmapIndexed extends BitmapDescriptor { // This is slightly obscure, and should probably be moved.. Hashtable properties = null; - if (mEntry instanceof DirectoryEntry.CUREntry) { - DirectoryEntry.CUREntry entry = (DirectoryEntry.CUREntry) mEntry; + if (entry instanceof DirectoryEntry.CUREntry) { properties = new Hashtable(1); - properties.put("cursor_hotspot", entry.getHotspot()); + properties.put("cursor_hotspot", ((DirectoryEntry.CUREntry) this.entry).getHotspot()); } BufferedImage image = new BufferedImage( @@ -82,13 +81,13 @@ class BitmapIndexed extends BitmapDescriptor { final int trans = icm.getTransparentPixel(); for (int y = 0; y < getHeight(); y++) { for (int x = 0; x < getWidth(); x++) { - if (mMask.isTransparent(x, y)) { - mBits[x + getWidth() * y] = trans; + if (mask.isTransparent(x, y)) { + bits[x + getWidth() * y] = trans; } } } - raster.setSamples(0, 0, getWidth(), getHeight(), 0, mBits); + raster.setSamples(0, 0, getWidth(), getHeight(), 0, bits); //System.out.println("Image: " + image); @@ -102,18 +101,18 @@ class BitmapIndexed extends BitmapDescriptor { // NOTE: This is a hack to make room for transparent pixel for mask int bits = getBitCount(); - int colors = mColors.length; + int colors = this.colors.length; int trans = -1; // Try to avoid USHORT transfertype, as it results in BufferedImage TYPE_CUSTOM // NOTE: This code assumes icons are small, and is NOT optimized for performance... if (colors > (1 << getBitCount())) { - int index = BitmapIndexed.findTransIndexMaybeRemap(mColors, mBits); + int index = BitmapIndexed.findTransIndexMaybeRemap(this.colors, this.bits); if (index == -1) { // No duplicate found, increase bitcount bits++; - trans = mColors.length - 1; + trans = this.colors.length - 1; } else { // Found a duplicate, use it as trans @@ -124,7 +123,7 @@ class BitmapIndexed extends BitmapDescriptor { // NOTE: Setting hasAlpha to true, makes things work on 1.2 return new InverseColorMapIndexColorModel( - bits, colors, mColors, 0, true, trans, + bits, colors, this.colors, 0, true, trans, bits <= 8 ? DataBuffer.TYPE_BYTE : DataBuffer.TYPE_USHORT ); } @@ -170,13 +169,13 @@ class BitmapIndexed extends BitmapDescriptor { } public BufferedImage getImage() { - if (mImage == null) { - mImage = createImageIndexed(); + if (image == null) { + image = createImageIndexed(); } - return mImage; + return image; } public void setMask(final BitmapMask pMask) { - mMask = pMask; + mask = pMask; } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapMask.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapMask.java index e5e11c1c..874dcf56 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapMask.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapMask.java @@ -38,19 +38,19 @@ import java.awt.image.BufferedImage; * @version $Id: BitmapMask.java,v 1.0 25.feb.2006 00:29:44 haku Exp$ */ class BitmapMask extends BitmapDescriptor { - protected final BitmapIndexed mMask; + protected final BitmapIndexed mask; public BitmapMask(final DirectoryEntry pParent, final DIBHeader pHeader) { super(pParent, pHeader); - mMask = new BitmapIndexed(pParent, pHeader); + mask = new BitmapIndexed(pParent, pHeader); } boolean isTransparent(final int pX, final int pY) { // NOTE: 1: Fully transparent, 0: Opaque... - return mMask.mBits[pX + pY * getWidth()] != 0; + return mask.bits[pX + pY * getWidth()] != 0; } public BufferedImage getImage() { - return mMask.getImage(); + return mask.getImage(); } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapRGB.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapRGB.java index 774caf48..aaa75359 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapRGB.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapRGB.java @@ -43,6 +43,6 @@ class BitmapRGB extends BitmapDescriptor { } public BufferedImage getImage() { - return mImage; + return image; } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapUnsupported.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapUnsupported.java index 73d7be5b..84078090 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapUnsupported.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/BitmapUnsupported.java @@ -38,15 +38,15 @@ import java.awt.image.BufferedImage; * @version $Id: BitmapUnsupported.java,v 1.0 25.feb.2006 00:29:44 haku Exp$ */ class BitmapUnsupported extends BitmapDescriptor { - private String mMessage; + private String message; public BitmapUnsupported(final DirectoryEntry pEntry, final String pMessage) { super(pEntry, null); - mMessage = pMessage; + message = pMessage; } public BufferedImage getImage() { - throw new IllegalStateException(mMessage); + throw new IllegalStateException(message); } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DIBHeader.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DIBHeader.java index af4ef23f..974fba5d 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DIBHeader.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DIBHeader.java @@ -41,16 +41,16 @@ import java.io.IOException; * @see BMP file format (Wikipedia) */ abstract class DIBHeader { - protected int mSize; + protected int size; - protected int mWidth; + protected int width; // NOTE: If a bitmask is present, this value includes the height of the mask // (so often header.height = entry.height * 2) - protected int mHeight; + protected int height; - protected int mPlanes; - protected int mBitCount; + protected int planes; + protected int bitCount; /** * 0 = BI_RGB: No compression @@ -58,18 +58,18 @@ abstract class DIBHeader { * 2 = BI_RLE4: 4 bit RLE Compression (4 bit only) * 3 = BI_BITFIELDS: No compression (16 & 32 bit only) */ - protected int mCompression; + protected int compression; // May be 0 if not known - protected int mImageSize; + protected int imageSize; - protected int mXPixelsPerMeter; - protected int mYPixelsPerMeter; + protected int xPixelsPerMeter; + protected int yPixelsPerMeter; - protected int mColorsUsed; + protected int colorsUsed; // 0 means all colors are important - protected int mColorsImportant; + protected int colorsImportant; protected DIBHeader() { } @@ -102,47 +102,47 @@ abstract class DIBHeader { protected abstract void read(int pSize, DataInput pStream) throws IOException; public final int getSize() { - return mSize; + return size; } public final int getWidth() { - return mWidth; + return width; } public final int getHeight() { - return mHeight; + return height; } public final int getPlanes() { - return mPlanes; + return planes; } public final int getBitCount() { - return mBitCount; + return bitCount; } public int getCompression() { - return mCompression; + return compression; } public int getImageSize() { - return mImageSize; + return imageSize; } public int getXPixelsPerMeter() { - return mXPixelsPerMeter; + return xPixelsPerMeter; } public int getYPixelsPerMeter() { - return mYPixelsPerMeter; + return yPixelsPerMeter; } public int getColorsUsed() { - return mColorsUsed; + return colorsUsed; } public int getColorsImportant() { - return mColorsImportant; + return colorsImportant; } public String toString() { @@ -176,22 +176,22 @@ abstract class DIBHeader { throw new IIOException(String.format("Size: %s !=: %s", pSize, DIB.WINDOWS_V3_HEADER_SIZE)); } - mSize = pSize; + size = pSize; - mWidth = pStream.readInt(); - mHeight = pStream.readInt(); + width = pStream.readInt(); + height = pStream.readInt(); - mPlanes = pStream.readUnsignedShort(); - mBitCount = pStream.readUnsignedShort(); - mCompression = pStream.readInt(); + planes = pStream.readUnsignedShort(); + bitCount = pStream.readUnsignedShort(); + compression = pStream.readInt(); - mImageSize = pStream.readInt(); + imageSize = pStream.readInt(); - mXPixelsPerMeter = pStream.readInt(); - mYPixelsPerMeter = pStream.readInt(); + xPixelsPerMeter = pStream.readInt(); + yPixelsPerMeter = pStream.readInt(); - mColorsUsed = pStream.readInt(); - mColorsImportant = pStream.readInt(); + colorsUsed = pStream.readInt(); + colorsImportant = pStream.readInt(); } } } \ No newline at end of file diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/Directory.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/Directory.java index 9cafc0c4..861224cd 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/Directory.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/Directory.java @@ -41,10 +41,10 @@ import java.util.List; * @version $Id: Directory.java,v 1.0 25.feb.2006 00:29:44 haku Exp$ */ class Directory { - private final List mEntries; + private final List entries; private Directory(int pImageCount) { - mEntries = Arrays.asList(new DirectoryEntry[pImageCount]); + entries = Arrays.asList(new DirectoryEntry[pImageCount]); } public static Directory read(final int pType, final int pImageCount, final DataInput pStream) throws IOException { @@ -54,21 +54,21 @@ class Directory { } private void readEntries(final int pType, final DataInput pStream) throws IOException { - for (int i = 0; i < mEntries.size(); i++) { - mEntries.set(i, DirectoryEntry.read(pType, pStream)); + for (int i = 0; i < entries.size(); i++) { + entries.set(i, DirectoryEntry.read(pType, pStream)); } } public DirectoryEntry getEntry(final int pEntryIndex) { - return mEntries.get(pEntryIndex); + return entries.get(pEntryIndex); } public int count() { - return mEntries.size(); + return entries.size(); } @Override public String toString() { - return String.format("%s%s", getClass().getSimpleName(), mEntries); + return String.format("%s%s", getClass().getSimpleName(), entries); } } diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DirectoryEntry.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DirectoryEntry.java index 163c3acd..41e49f19 100755 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DirectoryEntry.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/DirectoryEntry.java @@ -31,7 +31,6 @@ package com.twelvemonkeys.imageio.plugins.ico; import javax.imageio.IIOException; import java.io.DataInput; import java.io.IOException; -import java.awt.image.BufferedImage; import java.awt.*; /** @@ -43,13 +42,13 @@ import java.awt.*; * @see Wikipedia */ abstract class DirectoryEntry { - private int mWidth; - private int mHeight; - private int mColorCount; - int mPlanes; - int mBitCount; - private int mSize; - private int mOffset; + private int width; + private int height; + private int colorCount; + int planes; + int bitCount; + private int size; + private int offset; private DirectoryEntry() { } @@ -79,58 +78,58 @@ abstract class DirectoryEntry { protected void read(final DataInput pStream) throws IOException { // Width/height = 0, means 256 int w = pStream.readUnsignedByte(); - mWidth = w == 0 ? 256 : w; + width = w == 0 ? 256 : w; int h = pStream.readUnsignedByte(); - mHeight = h == 0 ? 256 : h; + height = h == 0 ? 256 : h; // Color count = 0, means 256 or more colors - mColorCount = pStream.readUnsignedByte(); + colorCount = pStream.readUnsignedByte(); // Ignore. Should be 0, but .NET (System.Drawing.Icon.Save) sets this value to 255, according to Wikipedia pStream.readUnsignedByte(); - mPlanes = pStream.readUnsignedShort(); // Should be 0 or 1 for ICO, x hotspot for CUR - mBitCount = pStream.readUnsignedShort(); // bit count for ICO, y hotspot for CUR + planes = pStream.readUnsignedShort(); // Should be 0 or 1 for ICO, x hotspot for CUR + bitCount = pStream.readUnsignedShort(); // bit count for ICO, y hotspot for CUR // Size of bitmap in bytes - mSize = pStream.readInt(); - mOffset = pStream.readInt(); + size = pStream.readInt(); + offset = pStream.readInt(); } public String toString() { return String.format( "%s: width: %d, height: %d, colors: %d, planes: %d, bit count: %d, size: %d, offset: %d", getClass().getSimpleName(), - mWidth, mHeight, mColorCount, mPlanes, mBitCount, mSize, mOffset + width, height, colorCount, planes, bitCount, size, offset ); } public int getBitCount() { - return mBitCount; + return bitCount; } public int getColorCount() { - return mColorCount; + return colorCount; } public int getHeight() { - return mHeight; + return height; } public int getOffset() { - return mOffset; + return offset; } public int getPlanes() { - return mPlanes; + return planes; } public int getSize() { - return mSize; + return size; } public int getWidth() { - return mWidth; + return width; } /** @@ -145,11 +144,11 @@ abstract class DirectoryEntry { super.read(pStream); // NOTE: This is a hack... - mXHotspot = mPlanes; - mYHotspot = mBitCount; + mXHotspot = planes; + mYHotspot = bitCount; - mPlanes = 1; // Always 1 for all BMP types - mBitCount = 0; + planes = 1; // Always 1 for all BMP types + bitCount = 0; } public Point getHotspot() { diff --git a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/ICOImageReader.java b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/ICOImageReader.java index bd62a431..33c1a842 100644 --- a/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/ICOImageReader.java +++ b/imageio/imageio-ico/src/main/java/com/twelvemonkeys/imageio/plugins/ico/ICOImageReader.java @@ -69,13 +69,13 @@ import java.util.List; // Known issue: 256x256 PNG encoded icons does not have IndexColorModel even if stated in DirectoryEntry (seem impossible as the PNGs are all true color) public class ICOImageReader extends ImageReaderBase { // TODO: Consider moving the reading to inner classes (subclasses of BitmapDescriptor) - private Directory mDirectory; + private Directory directory; // TODO: Review these, make sure we don't have a memory leak - private Map mHeaders = new WeakHashMap(); - private Map mDescriptors = new WeakWeakMap(); + private Map headers = new WeakHashMap(); + private Map descriptors = new WeakWeakMap(); - private ImageReader mPNGImageReader; + private ImageReader pngImageReader; public ICOImageReader() { this(DIB.TYPE_ICO); @@ -101,14 +101,14 @@ public class ICOImageReader extends ImageReaderBase { } protected void resetMembers() { - mDirectory = null; + directory = null; - mHeaders.clear(); - mDescriptors.clear(); + headers.clear(); + descriptors.clear(); - if (mPNGImageReader != null) { - mPNGImageReader.dispose(); - mPNGImageReader = null; + if (pngImageReader != null) { + pngImageReader.dispose(); + pngImageReader = null; } } @@ -158,7 +158,7 @@ public class ICOImageReader extends ImageReaderBase { } @Override - public int getNumImages(final boolean pAllowSearch) throws IOException { + public int getNumImages(final boolean allowSearch) throws IOException { return getDirectory().count(); } @@ -260,38 +260,38 @@ public class ICOImageReader extends ImageReaderBase { private ImageReader getPNGReader() throws IIOException { // TODO: Prefer Sun's std JDK PNGImagerReader, because it has known behaviour? - if (mPNGImageReader == null) { + if (pngImageReader == null) { Iterator readers = ImageIO.getImageReadersByFormatName("PNG"); if (readers.hasNext()) { - mPNGImageReader = readers.next(); + pngImageReader = readers.next(); } else { throw new IIOException("No PNGImageReader found using ImageIO, can't read PNG encoded ICO format."); } } else { - mPNGImageReader.reset(); + pngImageReader.reset(); } - return mPNGImageReader; + return pngImageReader; } private DIBHeader getHeader(final DirectoryEntry pEntry) throws IOException { - if (!mHeaders.containsKey(pEntry)) { + if (!headers.containsKey(pEntry)) { imageInput.seek(pEntry.getOffset()); DIBHeader header = DIBHeader.read(imageInput); - mHeaders.put(pEntry, header); + headers.put(pEntry, header); } - return mHeaders.get(pEntry); + return headers.get(pEntry); } private BufferedImage readBitmap(final DirectoryEntry pEntry) throws IOException { // TODO: Get rid of the caching, as the images are mutable - BitmapDescriptor descriptor = mDescriptors.get(pEntry); + BitmapDescriptor descriptor = descriptors.get(pEntry); - if (descriptor == null || !mDescriptors.containsKey(pEntry)) { + if (descriptor == null || !descriptors.containsKey(pEntry)) { DIBHeader header = getHeader(pEntry); int offset = pEntry.getOffset() + header.getSize(); @@ -333,7 +333,7 @@ public class ICOImageReader extends ImageReaderBase { } } - mDescriptors.put(pEntry, descriptor); + descriptors.put(pEntry, descriptor); } return descriptor.getImage(); @@ -354,8 +354,8 @@ public class ICOImageReader extends ImageReaderBase { break; } - BitmapMask mask = new BitmapMask(pBitmap.mEntry, pBitmap.mHeader); - readBitmapIndexed1(mask.mMask, true); + BitmapMask mask = new BitmapMask(pBitmap.entry, pBitmap.header); + readBitmapIndexed1(mask.mask, true); pBitmap.setMask(mask); } @@ -364,7 +364,7 @@ public class ICOImageReader extends ImageReaderBase { for (int i = 0; i < colorCount; i++) { // aRGB (a is "Reserved") - pBitmap.mColors[i] = (imageInput.readInt() & 0xffffff) | 0xff000000; + pBitmap.colors[i] = (imageInput.readInt() & 0xffffff) | 0xff000000; } } @@ -379,7 +379,7 @@ public class ICOImageReader extends ImageReaderBase { int pos = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); for (int x = 0; x < pBitmap.getWidth(); x++) { - pBitmap.mBits[pos++] = ((row[rowPos] & xOrVal) / xOrVal) & 0xFF; + pBitmap.bits[pos++] = ((row[rowPos] & xOrVal) / xOrVal) & 0xFF; if (xOrVal == 1) { xOrVal = 0x80; @@ -423,7 +423,7 @@ public class ICOImageReader extends ImageReaderBase { rowPos++; } - pBitmap.mBits[pos++] = value & 0xFF; + pBitmap.bits[pos++] = value & 0xFF; high4 = !high4; } @@ -447,7 +447,7 @@ public class ICOImageReader extends ImageReaderBase { int pos = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); for (int x = 0; x < pBitmap.getWidth(); x++) { - pBitmap.mBits[pos++] = row[rowPos++] & 0xFF; + pBitmap.bits[pos++] = row[rowPos++] & 0xFF; } if (abortRequested()) { @@ -480,7 +480,7 @@ public class ICOImageReader extends ImageReaderBase { WritableRaster raster = Raster.createPackedRaster( buffer, pBitmap.getWidth(), pBitmap.getHeight(), pBitmap.getWidth(), cm.getMasks(), null ); - pBitmap.mImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); + pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); for (int y = 0; y < pBitmap.getHeight(); y++) { int offset = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); @@ -516,7 +516,7 @@ public class ICOImageReader extends ImageReaderBase { WritableRaster raster = Raster.createInterleavedRaster( buffer, pBitmap.getWidth(), pBitmap.getHeight(), pBitmap.getWidth(), 3, bOffs, null ); - pBitmap.mImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); + pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); for (int y = 0; y < pBitmap.getHeight(); y++) { int offset = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); @@ -542,7 +542,7 @@ public class ICOImageReader extends ImageReaderBase { WritableRaster raster = Raster.createPackedRaster( buffer, pBitmap.getWidth(), pBitmap.getHeight(), pBitmap.getWidth(), cm.getMasks(), null ); - pBitmap.mImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); + pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); for (int y = 0; y < pBitmap.getHeight(); y++) { int offset = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); @@ -559,11 +559,11 @@ public class ICOImageReader extends ImageReaderBase { private Directory getDirectory() throws IOException { assertInput(); - if (mDirectory == null) { + if (directory == null) { readFileHeader(); } - return mDirectory; + return directory; } private void readFileHeader() throws IOException { @@ -577,7 +577,7 @@ public class ICOImageReader extends ImageReaderBase { int imageCount = imageInput.readUnsignedShort(); // Read directory - mDirectory = Directory.read(type, imageCount, imageInput); + directory = Directory.read(type, imageCount, imageInput); } final DirectoryEntry getEntry(final int pImageIndex) throws IOException { diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BMHDChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BMHDChunk.java index c02cb3a8..7442108a 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BMHDChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BMHDChunk.java @@ -81,100 +81,98 @@ class BMHDChunk extends IFFChunk { // words. The number of words per row is words=((w+15)/16) // Dimensions of raster - int mWidth; - int mHeight; + int width; + int height; // Source offsets // Hmm.. Consider making these Image.properties? - int mXPos; - int mYPos; + int xPos; + int yPos; // The number of source bitplanes in the BODY chunk (see below) is stored in // nPlanes. An ILBM with a CMAP but no BODY and nPlanes = 0 is the // recommended way to store a color map. - int mBitplanes; + int bitplanes; - int mMaskType; - int mCompressionType; + int maskType; + int compressionType; - int mTransparentIndex; + int transparentIndex; // NOTE: Typical values are 10:11 (320 x 200) - int mXAspect; - int mYAspect; + int xAspect; + int yAspect; // Source page dimension // NOTE: The image may be larger than the page, probably ignore these - int mPageWidth; - int mPageHeight; + int pageWidth; + int pageHeight; protected BMHDChunk(int pChunkLength) { super(IFF.CHUNK_BMHD, pChunkLength); } - protected BMHDChunk(int pWidth, int pHeight, int pBitplanes, - int pMaskType, int pCompressionType, - int pTransparentIndex) { + protected BMHDChunk(int pWidth, int pHeight, int pBitplanes, int pMaskType, int pCompressionType, int pTransparentIndex) { super(IFF.CHUNK_BMHD, 20); - mWidth = pWidth; - mHeight = pHeight; - mXPos = 0; - mYPos = 0; - mBitplanes = pBitplanes; - mMaskType = pMaskType; - mCompressionType = pCompressionType; - mTransparentIndex = pTransparentIndex; - mXAspect = 1; - mYAspect = 1; - mPageWidth = Math.min(pWidth, Short.MAX_VALUE); // For some reason, these are signed? - mPageHeight = Math.min(pHeight, Short.MAX_VALUE); + width = pWidth; + height = pHeight; + xPos = 0; + yPos = 0; + bitplanes = pBitplanes; + maskType = pMaskType; + compressionType = pCompressionType; + transparentIndex = pTransparentIndex; + xAspect = 1; + yAspect = 1; + pageWidth = Math.min(pWidth, Short.MAX_VALUE); // For some reason, these are signed? + pageHeight = Math.min(pHeight, Short.MAX_VALUE); } void readChunk(DataInput pInput) throws IOException { - if (mChunkLength != 20) { - throw new IIOException("Unknown BMHD chunk length: " + mChunkLength); + if (chunkLength != 20) { + throw new IIOException("Unknown BMHD chunk length: " + chunkLength); } - mWidth = pInput.readUnsignedShort(); - mHeight = pInput.readUnsignedShort(); - mXPos = pInput.readShort(); - mYPos = pInput.readShort(); - mBitplanes = pInput.readUnsignedByte(); - mMaskType = pInput.readUnsignedByte(); - mCompressionType = pInput.readUnsignedByte(); + width = pInput.readUnsignedShort(); + height = pInput.readUnsignedShort(); + xPos = pInput.readShort(); + yPos = pInput.readShort(); + bitplanes = pInput.readUnsignedByte(); + maskType = pInput.readUnsignedByte(); + compressionType = pInput.readUnsignedByte(); pInput.readByte(); // PAD - mTransparentIndex = pInput.readUnsignedShort(); - mXAspect = pInput.readUnsignedByte(); - mYAspect = pInput.readUnsignedByte(); - mPageWidth = pInput.readShort(); - mPageHeight = pInput.readShort(); + transparentIndex = pInput.readUnsignedShort(); + xAspect = pInput.readUnsignedByte(); + yAspect = pInput.readUnsignedByte(); + pageWidth = pInput.readShort(); + pageHeight = pInput.readShort(); } void writeChunk(DataOutput pOutput) throws IOException { - pOutput.writeInt(mChunkId); - pOutput.writeInt(mChunkLength); + pOutput.writeInt(chunkId); + pOutput.writeInt(chunkLength); - pOutput.writeShort(mWidth); - pOutput.writeShort(mHeight); - pOutput.writeShort(mXPos); - pOutput.writeShort(mYPos); - pOutput.writeByte(mBitplanes); - pOutput.writeByte(mMaskType); - pOutput.writeByte(mCompressionType); + pOutput.writeShort(width); + pOutput.writeShort(height); + pOutput.writeShort(xPos); + pOutput.writeShort(yPos); + pOutput.writeByte(bitplanes); + pOutput.writeByte(maskType); + pOutput.writeByte(compressionType); pOutput.writeByte(0); // PAD - pOutput.writeShort(mTransparentIndex); - pOutput.writeByte(mXAspect); - pOutput.writeByte(mYAspect); - pOutput.writeShort(mPageWidth); - pOutput.writeShort(mPageHeight); + pOutput.writeShort(transparentIndex); + pOutput.writeByte(xAspect); + pOutput.writeByte(yAspect); + pOutput.writeShort(pageWidth); + pOutput.writeShort(pageHeight); } public String toString() { return super.toString() - + " {w=" + mWidth + ", h=" + mHeight - + ", x=" + mXPos + ", y=" + mYPos - + ", planes=" + mBitplanes + ", mask=" + mMaskType - + ", compression=" + mCompressionType + ", trans=" + mTransparentIndex - + ", xAspect=" + mXAspect + ", yAspect=" + mYAspect - + ", pageWidth=" + mPageWidth + ", pageHeight=" + mPageHeight + "}"; + + " {w=" + width + ", h=" + height + + ", x=" + xPos + ", y=" + yPos + + ", planes=" + bitplanes + ", mask=" + maskType + + ", compression=" + compressionType + ", trans=" + transparentIndex + + ", xAspect=" + xAspect + ", yAspect=" + yAspect + + ", pageWidth=" + pageWidth + ", pageHeight=" + pageHeight + "}"; } } diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BODYChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BODYChunk.java index 9cbb9497..0e94d910 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BODYChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/BODYChunk.java @@ -40,7 +40,6 @@ import java.io.DataOutput; * @version $Id: BODYChunk.java,v 1.0 28.feb.2006 01:25:49 haku Exp$ */ class BODYChunk extends IFFChunk { - protected BODYChunk(int pChunkLength) { super(IFF.CHUNK_BODY, pChunkLength); } diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CAMGChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CAMGChunk.java index 98ecb5f8..e42ee11d 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CAMGChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CAMGChunk.java @@ -41,22 +41,21 @@ import java.io.IOException; * @version $Id: CAMGChunk.java,v 1.0 28.feb.2006 02:10:07 haku Exp$ */ class CAMGChunk extends IFFChunk { - // HIRES=0x8000, LACE=0x4 // #define CAMG_HAM 0x800 /* hold and modify */ // #define CAMG_EHB 0x80 /* extra halfbrite */ - private int mCAMG; + private int camg; public CAMGChunk(int pLength) { super(IFF.CHUNK_CAMG, pLength); } void readChunk(DataInput pInput) throws IOException { - if (mChunkLength != 4) { - throw new IIOException("Unknown CAMG chunk length: " + mChunkLength); + if (chunkLength != 4) { + throw new IIOException("Unknown CAMG chunk length: " + chunkLength); } - mCAMG = pInput.readInt(); + camg = pInput.readInt(); } void writeChunk(DataOutput pOutput) throws IOException { @@ -64,11 +63,11 @@ class CAMGChunk extends IFFChunk { } boolean isHAM() { - return (mCAMG & 0x800) != 0; + return (camg & 0x800) != 0; } boolean isEHB() { - return (mCAMG & 0x80) != 0; + return (camg & 0x80) != 0; } public String toString() { diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CMAPChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CMAPChunk.java index 4c0fa687..4171e524 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CMAPChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/CMAPChunk.java @@ -54,34 +54,34 @@ class CMAPChunk extends IFFChunk { // typedef ColorRegister ColorMap[n]; /* size = 3n bytes */ - byte[] mReds; - byte[] mGreens; - byte[] mBlues; + byte[] reds; + byte[] greens; + byte[] blues; - boolean mEHB; + boolean ehb; - final private BMHDChunk mHeader; - final private CAMGChunk mCamg; - private IndexColorModel mModel; + final private BMHDChunk header; + final private CAMGChunk camg; + private IndexColorModel model; protected CMAPChunk(int pChunkLength, BMHDChunk pHeader, CAMGChunk pCamg) { super(IFF.CHUNK_CMAP, pChunkLength); - mHeader = pHeader; - mCamg = pCamg; + header = pHeader; + camg = pCamg; } public CMAPChunk(IndexColorModel pModel) { super(IFF.CHUNK_CMAP, pModel.getMapSize() * 3); - mModel = pModel; - mHeader = null; - mCamg = null; + model = pModel; + header = null; + camg = null; } void readChunk(DataInput pInput) throws IOException { - int numColors = mChunkLength / 3; + int numColors = chunkLength / 3; int paletteSize = numColors; - boolean isEHB = mCamg != null && mCamg.isEHB(); + boolean isEHB = camg != null && camg.isEHB(); if (isEHB) { if (numColors == 32) { paletteSize = 64; @@ -91,22 +91,22 @@ class CMAPChunk extends IFFChunk { } } - mReds = new byte[paletteSize]; - mGreens = mReds.clone(); - mBlues = mReds.clone(); + reds = new byte[paletteSize]; + greens = reds.clone(); + blues = reds.clone(); for (int i = 0; i < numColors; i++) { - mReds[i] = pInput.readByte(); - mGreens[i] = pInput.readByte(); - mBlues[i] = pInput.readByte(); + reds[i] = pInput.readByte(); + greens[i] = pInput.readByte(); + blues[i] = pInput.readByte(); } if (isEHB && numColors == 32) { // Create the half-brite colors for (int i = 0; i < numColors; i++) { - mReds[i + numColors] = (byte) ((mReds[i] & 0xff) / 2); - mGreens[i + numColors] = (byte) ((mGreens[i] & 0xff) / 2); - mBlues[i + numColors] = (byte) ((mBlues[i] & 0xff) / 2); + reds[i + numColors] = (byte) ((reds[i] & 0xff) / 2); + greens[i + numColors] = (byte) ((greens[i] & 0xff) / 2); + blues[i + numColors] = (byte) ((blues[i] & 0xff) / 2); } } @@ -120,7 +120,7 @@ class CMAPChunk extends IFFChunk { // R8 := (Rn x 255 ) / maxColor // All chunks are WORD aligned (even sized), may need to read pad... - if (mChunkLength % 2 != 0) { + if (chunkLength % 2 != 0) { pInput.readByte(); } @@ -128,33 +128,33 @@ class CMAPChunk extends IFFChunk { // Would it work to double to numbers of colors, and create an indexcolormodel, // with alpha, where all colors above the original color is all transparent? // This is a waste of time and space, of course... - int trans = mHeader.mMaskType == BMHDChunk.MASK_TRANSPARENT_COLOR ? mHeader.mTransparentIndex : -1; - mModel = new InverseColorMapIndexColorModel(mHeader.mBitplanes, mReds.length, mReds, mGreens, mBlues, trans); + int trans = header.maskType == BMHDChunk.MASK_TRANSPARENT_COLOR ? header.transparentIndex : -1; + model = new InverseColorMapIndexColorModel(header.bitplanes, reds.length, reds, greens, blues, trans); } void writeChunk(DataOutput pOutput) throws IOException { - pOutput.writeInt(mChunkId); - pOutput.writeInt(mChunkLength); + pOutput.writeInt(chunkId); + pOutput.writeInt(chunkLength); - final int length = mModel.getMapSize(); + final int length = model.getMapSize(); for (int i = 0; i < length; i++) { - pOutput.writeByte(mModel.getRed(i)); - pOutput.writeByte(mModel.getGreen(i)); - pOutput.writeByte(mModel.getBlue(i)); + pOutput.writeByte(model.getRed(i)); + pOutput.writeByte(model.getGreen(i)); + pOutput.writeByte(model.getBlue(i)); } - if (mChunkLength % 2 != 0) { + if (chunkLength % 2 != 0) { pOutput.writeByte(0); // PAD } } public String toString() { - return super.toString() + " {colorMap=" + mModel + "}"; + return super.toString() + " {colorMap=" + model + "}"; } IndexColorModel getIndexColorModel() { - return mModel; + return model; } public BufferedImage createPaletteImage() { diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GRABChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GRABChunk.java index bb4cc03b..efaa0015 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GRABChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GRABChunk.java @@ -47,7 +47,7 @@ class GRABChunk extends IFFChunk { // WORD x, y; /* relative coordinates (pixels) */ // } Point2D; - Point2D mPoint; + Point2D point; protected GRABChunk(int pChunkLength) { super(IFF.CHUNK_GRAB, pChunkLength); @@ -55,22 +55,22 @@ class GRABChunk extends IFFChunk { protected GRABChunk(Point2D pPoint) { super(IFF.CHUNK_GRAB, 4); - mPoint = pPoint; + point = pPoint; } void readChunk(DataInput pInput) throws IOException { - if (mChunkLength != 4) { - throw new IIOException("Unknown GRAB chunk size: " + mChunkLength); + if (chunkLength != 4) { + throw new IIOException("Unknown GRAB chunk size: " + chunkLength); } - mPoint = new Point(pInput.readShort(), pInput.readShort()); + point = new Point(pInput.readShort(), pInput.readShort()); } void writeChunk(DataOutput pOutput) throws IOException { - pOutput.writeShort((int) mPoint.getX()); - pOutput.writeShort((int) mPoint.getY()); + pOutput.writeShort((int) point.getX()); + pOutput.writeShort((int) point.getY()); } public String toString() { - return super.toString() + " {point=" + mPoint + "}"; + return super.toString() + " {point=" + point + "}"; } } diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GenericChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GenericChunk.java index 0f14ff90..bb63d20d 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GenericChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/GenericChunk.java @@ -41,45 +41,45 @@ import java.io.DataOutput; */ class GenericChunk extends IFFChunk { - byte[] mData; + byte[] data; protected GenericChunk(int pChunkId, int pChunkLength) { super(pChunkId, pChunkLength); - mData = new byte[pChunkLength <= 50 ? pChunkLength : 47]; + data = new byte[pChunkLength <= 50 ? pChunkLength : 47]; } protected GenericChunk(int pChunkId, byte[] pChunkData) { super(pChunkId, pChunkData.length); - mData = pChunkData; + data = pChunkData; } void readChunk(DataInput pInput) throws IOException { - pInput.readFully(mData, 0, mData.length); + pInput.readFully(data, 0, data.length); - int toSkip = mChunkLength - mData.length; + int toSkip = chunkLength - data.length; while (toSkip > 0) { toSkip -= pInput.skipBytes(toSkip); } // Read pad - if (mChunkLength % 2 != 0) { + if (chunkLength % 2 != 0) { pInput.readByte(); } } void writeChunk(DataOutput pOutput) throws IOException { - pOutput.writeInt(mChunkId); - pOutput.writeInt(mChunkLength); - pOutput.write(mData, 0, mData.length); + pOutput.writeInt(chunkId); + pOutput.writeInt(chunkLength); + pOutput.write(data, 0, data.length); - if (mData.length % 2 != 0) { + if (data.length % 2 != 0) { pOutput.writeByte(0); // PAD } } public String toString() { return super.toString() + " {value=\"" - + new String(mData, 0, mData.length <= 50 ? mData.length : 47) - + (mChunkLength <= 50 ? "" : "...") + "\"}"; + + new String(data, 0, data.length <= 50 ? data.length : 47) + + (chunkLength <= 50 ? "" : "...") + "\"}"; } } diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFChunk.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFChunk.java index c5517611..f3fadd98 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFChunk.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFChunk.java @@ -40,12 +40,12 @@ import java.io.DataOutput; * @version $Id: IFFChunk.java,v 1.0 28.feb.2006 00:00:45 haku Exp$ */ abstract class IFFChunk { - int mChunkId; - int mChunkLength; + int chunkId; + int chunkLength; protected IFFChunk(int pChunkId, int pChunkLength) { - mChunkId = pChunkId; - mChunkLength = pChunkLength; + chunkId = pChunkId; + chunkLength = pChunkLength; } abstract void readChunk(DataInput pInput) throws IOException; @@ -53,6 +53,6 @@ abstract class IFFChunk { abstract void writeChunk(DataOutput pOutput) throws IOException; public String toString() { - return IFFUtil.toChunkStr(mChunkId) + " chunk (" + mChunkLength + " bytes)"; + return IFFUtil.toChunkStr(chunkId) + " chunk (" + chunkLength + " bytes)"; } } diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageReader.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageReader.java index 7a65350f..7a42ffd5 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageReader.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageReader.java @@ -96,16 +96,17 @@ public class IFFImageReader extends ImageReaderBase { // - Contains definitions of some "new" chunks, as well as alternative FORM types // http://amigan.1emu.net/reg/iff.html - private BMHDChunk mHeader; - private CMAPChunk mColorMap; - private BODYChunk mBody; - private GRABChunk mGrab; - private CAMGChunk mViewPort; - private int mFormType; - private long mBodyStart; + private BMHDChunk header; + private CMAPChunk colorMap; + private BODYChunk body; + @SuppressWarnings({"FieldCanBeLocal"}) + private GRABChunk grab; + private CAMGChunk viewPort; + private int formType; + private long bodyStart; - private BufferedImage mImage; - private DataInputStream mByteRunStream; + private BufferedImage image; + private DataInputStream byteRunStream; public IFFImageReader() { super(IFFImageReaderSpi.sharedProvider()); @@ -118,20 +119,20 @@ public class IFFImageReader extends ImageReaderBase { private void init(int pIndex) throws IOException { checkBounds(pIndex); - if (mHeader == null) { + if (header == null) { readMeta(); } } protected void resetMembers() { - mHeader = null; - mColorMap = null; - mBody = null; - mViewPort = null; - mFormType = 0; + header = null; + colorMap = null; + body = null; + viewPort = null; + formType = 0; - mImage = null; - mByteRunStream = null; + image = null; + byteRunStream = null; } private void readMeta() throws IOException { @@ -141,15 +142,15 @@ public class IFFImageReader extends ImageReaderBase { int remaining = imageInput.readInt() - 4; // We'll read 4 more in a sec - mFormType = imageInput.readInt(); - if (mFormType != IFF.TYPE_ILBM && mFormType != IFF.TYPE_PBM) { - throw new IIOException("Only IFF (FORM) type ILBM and PBM supported: " + IFFUtil.toChunkStr(mFormType)); + formType = imageInput.readInt(); + if (formType != IFF.TYPE_ILBM && formType != IFF.TYPE_PBM) { + throw new IIOException("Only IFF (FORM) type ILBM and PBM supported: " + IFFUtil.toChunkStr(formType)); } //System.out.println("IFF type FORM " + toChunkStr(type)); - mGrab = null; - mViewPort = null; + grab = null; + viewPort = null; while (remaining > 0) { int chunkId = imageInput.readInt(); @@ -163,49 +164,49 @@ public class IFFImageReader extends ImageReaderBase { switch (chunkId) { case IFF.CHUNK_BMHD: - if (mHeader != null) { + if (header != null) { throw new IIOException("Multiple BMHD chunks not allowed"); } - mHeader = new BMHDChunk(length); - mHeader.readChunk(imageInput); + header = new BMHDChunk(length); + header.readChunk(imageInput); - //System.out.println(mHeader); + //System.out.println(header); break; case IFF.CHUNK_CMAP: - if (mColorMap != null) { + if (colorMap != null) { throw new IIOException("Multiple CMAP chunks not allowed"); } - mColorMap = new CMAPChunk(length, mHeader, mViewPort); - mColorMap.readChunk(imageInput); + colorMap = new CMAPChunk(length, header, viewPort); + colorMap.readChunk(imageInput); - //System.out.println(mColorMap); + //System.out.println(colorMap); break; case IFF.CHUNK_GRAB: - if (mGrab != null) { + if (grab != null) { throw new IIOException("Multiple GRAB chunks not allowed"); } - mGrab = new GRABChunk(length); - mGrab.readChunk(imageInput); + grab = new GRABChunk(length); + grab.readChunk(imageInput); - //System.out.println(mGrab); + //System.out.println(grab); break; case IFF.CHUNK_CAMG: - if (mViewPort != null) { + if (viewPort != null) { throw new IIOException("Multiple CAMG chunks not allowed"); } - mViewPort = new CAMGChunk(length); - mViewPort.readChunk(imageInput); + viewPort = new CAMGChunk(length); + viewPort.readChunk(imageInput); - //System.out.println(mViewPort); + //System.out.println(viewPort); break; case IFF.CHUNK_BODY: - if (mBody != null) { + if (body != null) { throw new IIOException("Multiple BODY chunks not allowed"); } - mBody = new BODYChunk(length); - mBodyStart = imageInput.getStreamPosition(); + body = new BODYChunk(length); + bodyStart = imageInput.getStreamPosition(); // NOTE: We don't read the body here, it's done later in the read(int, ImageReadParam) method @@ -228,23 +229,23 @@ public class IFFImageReader extends ImageReaderBase { processImageStarted(pIndex); - mImage = getDestination(pParam, getImageTypes(pIndex), mHeader.mWidth, mHeader.mHeight); - //System.out.println(mBody); - if (mBody != null) { + image = getDestination(pParam, getImageTypes(pIndex), header.width, header.height); + //System.out.println(body); + if (body != null) { //System.out.println("Read body"); readBody(pParam); } else { // TODO: Remove this hack when we have metadata // In the rare case of an ILBM containing nothing but a CMAP - //System.out.println(mColorMap); - if (mColorMap != null) { + //System.out.println(colorMap); + if (colorMap != null) { //System.out.println("Creating palette!"); - mImage = mColorMap.createPaletteImage(); + image = colorMap.createPaletteImage(); } } - BufferedImage result = mImage; + BufferedImage result = image; processImageComplete(); @@ -253,12 +254,12 @@ public class IFFImageReader extends ImageReaderBase { public int getWidth(int pIndex) throws IOException { init(pIndex); - return mHeader.mWidth; + return header.width; } public int getHeight(int pIndex) throws IOException { init(pIndex); - return mHeader.mHeight; + return header.height; } public Iterator getImageTypes(int pIndex) throws IOException { @@ -266,8 +267,8 @@ public class IFFImageReader extends ImageReaderBase { List types = Arrays.asList( getRawImageType(pIndex), - ImageTypeSpecifier.createFromBufferedImageType(mHeader.mBitplanes == 32 ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR) -// TODO: ImageTypeSpecifier.createFromBufferedImageType(mHeader.mBitplanes == 32 ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB), + ImageTypeSpecifier.createFromBufferedImageType(header.bitplanes == 32 ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR) +// TODO: ImageTypeSpecifier.createFromBufferedImageType(header.bitplanes == 32 ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB), // TODO: Allow 32 bit always. Allow RGB and discard alpha, if present? ); return types.iterator(); @@ -278,9 +279,9 @@ public class IFFImageReader extends ImageReaderBase { init(pIndex); // TODO: Stay DRY... // TODO: Use this for creating the Image/Buffer in the read code below... - // NOTE: mColorMap may be null for 8 bit (gray), 24 bit or 32 bit only + // NOTE: colorMap may be null for 8 bit (gray), 24 bit or 32 bit only ImageTypeSpecifier specifier; - switch (mHeader.mBitplanes) { + switch (header.bitplanes) { case 1: // 1 bit case 2: @@ -297,8 +298,8 @@ public class IFFImageReader extends ImageReaderBase { // 8 bit // May be HAM8 if (!isHAM()) { - if (mColorMap != null) { - IndexColorModel cm = mColorMap.getIndexColorModel(); + if (colorMap != null) { + IndexColorModel cm = colorMap.getIndexColorModel(); specifier = IndexedImageTypeSpecifier.createFromIndexColorModel(cm); break; } @@ -317,18 +318,18 @@ public class IFFImageReader extends ImageReaderBase { specifier = ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_4BYTE_ABGR); break; default: - throw new IIOException(String.format("Bit depth not implemented: %d", mHeader.mBitplanes)); + throw new IIOException(String.format("Bit depth not implemented: %d", header.bitplanes)); } return specifier; } private void readBody(final ImageReadParam pParam) throws IOException { - imageInput.seek(mBodyStart); - mByteRunStream = null; + imageInput.seek(bodyStart); + byteRunStream = null; - // NOTE: mColorMap may be null for 8 bit (gray), 24 bit or 32 bit only - if (mColorMap != null) { - IndexColorModel cm = mColorMap.getIndexColorModel(); + // NOTE: colorMap may be null for 8 bit (gray), 24 bit or 32 bit only + if (colorMap != null) { + IndexColorModel cm = colorMap.getIndexColorModel(); readIndexed(pParam, imageInput, cm); } else { @@ -338,8 +339,8 @@ public class IFFImageReader extends ImageReaderBase { } private void readIndexed(final ImageReadParam pParam, final ImageInputStream pInput, final IndexColorModel pModel) throws IOException { - final int width = mHeader.mWidth; - final int height = mHeader.mHeight; + final int width = header.width; + final int height = header.height; final Rectangle aoi = getSourceRegion(pParam, width, height); final Point offset = pParam == null ? new Point(0, 0) : pParam.getDestinationOffset(); @@ -360,9 +361,9 @@ public class IFFImageReader extends ImageReaderBase { } // Ensure band settings from param are compatible with images - checkReadParamBandSettings(pParam, isHAM() ? 3 : 1, mImage.getSampleModel().getNumBands()); + checkReadParamBandSettings(pParam, isHAM() ? 3 : 1, image.getSampleModel().getNumBands()); - WritableRaster destination = mImage.getRaster(); + WritableRaster destination = image.getRaster(); if (destinationBands != null || offset.x != 0 || offset.y != 0) { destination = destination.createWritableChild(0, 0, destination.getWidth(), destination.getHeight(), offset.x, offset.y, destinationBands); } @@ -403,7 +404,7 @@ public class IFFImageReader extends ImageReaderBase { final byte[] data = ((DataBufferByte) raster.getDataBuffer()).getData(); - final int planes = mHeader.mBitplanes; + final int planes = header.bitplanes; Object dataElements = null; Object outDataElements = null; @@ -422,7 +423,7 @@ public class IFFImageReader extends ImageReaderBase { return; } - if (mFormType == IFF.TYPE_ILBM) { + if (formType == IFF.TYPE_ILBM) { int pixelPos = 0; for (int planePos = 0; planePos < planeWidth; planePos++) { IFFUtil.bitRotateCW(planeData, planePos, planeWidth, row, pixelPos, 1); @@ -436,13 +437,13 @@ public class IFFImageReader extends ImageReaderBase { raster.setDataElements(0, 0, width, 1, row); } } - else if (mFormType == IFF.TYPE_PBM) { + else if (formType == IFF.TYPE_PBM) { // TODO: Arraycopy might not be necessary, if it's okay with row larger than width - System.arraycopy(planeData, 0, row, 0, mHeader.mBitplanes * planeWidth); + System.arraycopy(planeData, 0, row, 0, header.bitplanes * planeWidth); raster.setDataElements(0, 0, width, 1, row); } else { - throw new AssertionError(String.format("Unsupported FORM type: %s", mFormType)); + throw new AssertionError(String.format("Unsupported FORM type: %s", formType)); } int dstY = (srcY - aoi.y) / sourceYSubsampling; @@ -470,7 +471,7 @@ public class IFFImageReader extends ImageReaderBase { for (int srcX = 0; srcX < sourceRow.getWidth(); srcX += sourceXSubsampling) { dataElements = sourceRow.getDataElements(srcX, 0, dataElements); int rgb = icm.getRGB(dataElements); - outDataElements = mImage.getColorModel().getDataElements(rgb, outDataElements); + outDataElements = image.getColorModel().getDataElements(rgb, outDataElements); int dstX = srcX / sourceXSubsampling; destination.setDataElements(dstX, dstY, outDataElements); } @@ -479,7 +480,7 @@ public class IFFImageReader extends ImageReaderBase { // TODO: This branch is never tested, and is probably "dead" // ColorConvertOp if (converter == null) { - converter = new ColorConvertOp(cm.getColorSpace(), mImage.getColorModel().getColorSpace(), null); + converter = new ColorConvertOp(cm.getColorSpace(), image.getColorModel().getColorSpace(), null); } converter.filter( raster.createChild(aoi.x, 0, aoi.width, 1, 0, 0, null), @@ -488,7 +489,7 @@ public class IFFImageReader extends ImageReaderBase { } } - processImageProgress(srcY * 100f / mHeader.mWidth); + processImageProgress(srcY * 100f / header.width); if (abortRequested()) { processReadAborted(); break; @@ -502,8 +503,8 @@ public class IFFImageReader extends ImageReaderBase { // bit of the red value for each pixel, and the last holds the most // significant bit of the blue value. private void readTrueColor(ImageReadParam pParam, final ImageInputStream pInput) throws IOException { - final int width = mHeader.mWidth; - final int height = mHeader.mHeight; + final int width = header.width; + final int height = header.height; final Rectangle aoi = getSourceRegion(pParam, width, height); final Point offset = pParam == null ? new Point(0, 0) : pParam.getDestinationOffset(); @@ -524,23 +525,23 @@ public class IFFImageReader extends ImageReaderBase { } // Ensure band settings from param are compatible with images - checkReadParamBandSettings(pParam, mHeader.mBitplanes / 8, mImage.getSampleModel().getNumBands()); + checkReadParamBandSettings(pParam, header.bitplanes / 8, image.getSampleModel().getNumBands()); // NOTE: Each row of the image is stored in an integral number of 16 bit words. // The number of words per row is words=((w+15)/16) int planeWidth = 2 * ((width + 15) / 16); final byte[] planeData = new byte[8 * planeWidth]; - WritableRaster destination = mImage.getRaster(); + WritableRaster destination = image.getRaster(); if (destinationBands != null || offset.x != 0 || offset.y != 0) { destination = destination.createWritableChild(0, 0, destination.getWidth(), destination.getHeight(), offset.x, offset.y, destinationBands); } -// WritableRaster raster = mImage.getRaster().createCompatibleWritableRaster(width, 1); - WritableRaster raster = mImage.getRaster().createCompatibleWritableRaster(8 * planeWidth, 1); +// WritableRaster raster = image.getRaster().createCompatibleWritableRaster(width, 1); + WritableRaster raster = image.getRaster().createCompatibleWritableRaster(8 * planeWidth, 1); Raster sourceRow = raster.createChild(aoi.x, 0, aoi.width, 1, 0, 0, sourceBands); final byte[] data = ((DataBufferByte) raster.getDataBuffer()).getData(); - final int channels = (mHeader.mBitplanes + 7) / 8; + final int channels = (header.bitplanes + 7) / 8; final int planesPerChannel = 8; Object dataElements = null; @@ -559,7 +560,7 @@ public class IFFImageReader extends ImageReaderBase { return; } - if (mFormType == IFF.TYPE_ILBM) { + if (formType == IFF.TYPE_ILBM) { // NOTE: Using (channels - c - 1) instead of just c, // effectively reverses the channel order from RGBA to ABGR int off = (channels - c - 1); @@ -570,11 +571,11 @@ public class IFFImageReader extends ImageReaderBase { pixelPos += 8; } } - else if (mFormType == IFF.TYPE_PBM) { + else if (formType == IFF.TYPE_PBM) { System.arraycopy(planeData, 0, data, srcY * 8 * planeWidth, planeWidth); } else { - throw new AssertionError(String.format("Unsupported FORM type: %s", mFormType)); + throw new AssertionError(String.format("Unsupported FORM type: %s", formType)); } } @@ -594,7 +595,7 @@ public class IFFImageReader extends ImageReaderBase { } } - processImageProgress(srcY * 100f / mHeader.mWidth); + processImageProgress(srcY * 100f / header.width); if (abortRequested()) { processReadAborted(); break; @@ -605,11 +606,11 @@ public class IFFImageReader extends ImageReaderBase { private void readPlaneData(final ImageInputStream pInput, final byte[] pData, final int pOffset, final int pPlaneWidth) throws IOException { - switch (mHeader.mCompressionType) { + switch (header.compressionType) { case BMHDChunk.COMPRESSION_NONE: pInput.readFully(pData, pOffset, pPlaneWidth); // Uncompressed rows must have even number of bytes - if ((mHeader.mBitplanes * pPlaneWidth) % 2 != 0) { + if ((header.bitplanes * pPlaneWidth) % 2 != 0) { pInput.readByte(); } break; @@ -620,27 +621,27 @@ public class IFFImageReader extends ImageReaderBase { // However, we don't know how long each compressed row is, without decoding it... // The workaround below, is to use a decode buffer size of pPlaneWidth, // to make sure we don't decode anything we don't have to (shouldn't). - if (mByteRunStream == null) { - mByteRunStream = new DataInputStream( + if (byteRunStream == null) { + byteRunStream = new DataInputStream( new DecoderStream( - IIOUtil.createStreamAdapter(pInput, mBody.mChunkLength), + IIOUtil.createStreamAdapter(pInput, body.chunkLength), new PackBitsDecoder(true), - pPlaneWidth * mHeader.mBitplanes + pPlaneWidth * header.bitplanes ) ); } - mByteRunStream.readFully(pData, pOffset, pPlaneWidth); + byteRunStream.readFully(pData, pOffset, pPlaneWidth); break; default: - throw new IIOException(String.format("Unknown compression type: %d", mHeader.mCompressionType)); + throw new IIOException(String.format("Unknown compression type: %d", header.compressionType)); } } private void hamToRGB(final byte[] pIndexed, final IndexColorModel pModel, final byte[] pDest, final int pDestOffset) { - final int bits = mHeader.mBitplanes; - final int width = mHeader.mWidth; + final int bits = header.bitplanes; + final int width = header.width; int lastRed = 0; int lastGreen = 0; int lastBlue = 0; @@ -679,7 +680,7 @@ public class IFFImageReader extends ImageReaderBase { } private boolean isHAM() { - return mViewPort != null && mViewPort.isHAM(); + return viewPort != null && viewPort.isHAM(); } public static void main(String[] pArgs) throws IOException { diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriter.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriter.java index e1a3d845..9d6cabfd 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriter.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriter.java @@ -208,9 +208,9 @@ public class IFFImageWriter extends ImageWriterBase { } // ILBM(4) + anno(8+len) + header(8+20) + cmap(8+len)? + body(8+len); - int size = 4 + 8 + anno.mChunkLength + 28 + 8 + pBodyLength; + int size = 4 + 8 + anno.chunkLength + 28 + 8 + pBodyLength; if (cmap != null) { - size += 8 + cmap.mChunkLength; + size += 8 + cmap.chunkLength; } imageOutput.writeInt(IFF.CHUNK_FORM); diff --git a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriterSpi.java b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriterSpi.java index da5c734b..4704236d 100755 --- a/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriterSpi.java +++ b/imageio/imageio-iff/src/main/java/com/twelvemonkeys/imageio/plugins/iff/IFFImageWriterSpi.java @@ -51,7 +51,6 @@ public class IFFImageWriterSpi extends ImageWriterSpi { */ public IFFImageWriterSpi() { this(IIOUtil.getProviderInfo(IFFImageWriterSpi.class)); - } private IFFImageWriterSpi(final ProviderInfo pProviderInfo) { diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java index 69748af5..e1c7a2ab 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractDirectory.java @@ -41,17 +41,17 @@ import java.util.List; * @version $Id: AbstractDirectory.java,v 1.0 Nov 11, 2009 5:31:04 PM haraldk Exp$ */ public abstract class AbstractDirectory implements Directory { - private final List mEntries = new ArrayList(); + private final List entries = new ArrayList(); protected AbstractDirectory(final Collection pEntries) { if (pEntries != null) { - mEntries.addAll(pEntries); + entries.addAll(pEntries); } } - public Entry getEntryById(final Object pIdentifier) { + public Entry getEntryById(final Object identifier) { for (Entry entry : this) { - if (entry.getIdentifier().equals(pIdentifier)) { + if (entry.getIdentifier().equals(identifier)) { return entry; } } @@ -59,9 +59,9 @@ public abstract class AbstractDirectory implements Directory { return null; } - public Entry getEntryByFieldName(final String pFieldName) { + public Entry getEntryByFieldName(final String fieldName) { for (Entry entry : this) { - if (entry.getFieldName() != null && entry.getFieldName().equals(pFieldName)) { + if (entry.getFieldName() != null && entry.getFieldName().equals(fieldName)) { return entry; } } @@ -70,7 +70,7 @@ public abstract class AbstractDirectory implements Directory { } public Iterator iterator() { - return mEntries.iterator(); + return entries.iterator(); } /** @@ -85,23 +85,23 @@ public abstract class AbstractDirectory implements Directory { } } - public boolean add(final Entry pEntry) { + public boolean add(final Entry entry) { assertMutable(); // TODO: Replace if entry is already present? // Some directories may need special ordering, or may/may not support multiple entries for certain ids... - return mEntries.add(pEntry); + return entries.add(entry); } @SuppressWarnings({"SuspiciousMethodCalls"}) - public boolean remove(final Object pEntry) { + public boolean remove(final Object entry) { assertMutable(); - return mEntries.remove(pEntry); + return entries.remove(entry); } public int size() { - return mEntries.size(); + return entries.size(); } /** @@ -118,7 +118,7 @@ public abstract class AbstractDirectory implements Directory { @Override public int hashCode() { - return mEntries.hashCode(); + return entries.hashCode(); } @Override @@ -134,11 +134,11 @@ public abstract class AbstractDirectory implements Directory { // Safe cast, as it must be a subclass for the classes to be equal AbstractDirectory other = (AbstractDirectory) pOther; - return mEntries.equals(other.mEntries); + return entries.equals(other.entries); } @Override public String toString() { - return String.format("%s%s", getClass().getSimpleName(), mEntries.toString()); + return String.format("%s%s", getClass().getSimpleName(), entries.toString()); } } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java index cbd850f6..f10783a3 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/AbstractEntry.java @@ -42,18 +42,18 @@ import java.util.Arrays; */ public abstract class AbstractEntry implements Entry { - private final Object mIdentifier; - private final Object mValue; // TODO: Might need to be mutable.. + private final Object identifier; + private final Object value; // TODO: Might need to be mutable.. - protected AbstractEntry(final Object pIdentifier, final Object pValue) { - Validate.notNull(pIdentifier, "identifier"); + protected AbstractEntry(final Object identifier, final Object value) { + Validate.notNull(identifier, "identifier"); - mIdentifier = pIdentifier; - mValue = pValue; + this.identifier = identifier; + this.value = value; } public final Object getIdentifier() { - return mIdentifier; + return identifier; } /** @@ -66,64 +66,64 @@ public abstract class AbstractEntry implements Entry { } public Object getValue() { - return mValue; + return value; } public String getValueAsString() { if (valueCount() > 1) { if (valueCount() < 16) { - Class type = mValue.getClass().getComponentType(); + Class type = value.getClass().getComponentType(); if (type.isPrimitive()) { if (type.equals(boolean.class)) { - return Arrays.toString((boolean[]) mValue); + return Arrays.toString((boolean[]) value); } else if (type.equals(byte.class)) { - return Arrays.toString((byte[]) mValue); + return Arrays.toString((byte[]) value); } else if (type.equals(char.class)) { - return new String((char[]) mValue); + return new String((char[]) value); } else if (type.equals(double.class)) { - return Arrays.toString((double[]) mValue); + return Arrays.toString((double[]) value); } else if (type.equals(float.class)) { - return Arrays.toString((float[]) mValue); + return Arrays.toString((float[]) value); } else if (type.equals(int.class)) { - return Arrays.toString((int[]) mValue); + return Arrays.toString((int[]) value); } else if (type.equals(long.class)) { - return Arrays.toString((long[]) mValue); + return Arrays.toString((long[]) value); } else if (type.equals(short.class)) { - return Arrays.toString((short[]) mValue); + return Arrays.toString((short[]) value); } // Fall through should never happen } else { - return Arrays.toString((Object[]) mValue); + return Arrays.toString((Object[]) value); } } - return String.valueOf(mValue) + " (" + valueCount() + ")"; + return String.valueOf(value) + " (" + valueCount() + ")"; } - return String.valueOf(mValue); + return String.valueOf(value); } public String getTypeName() { - if (mValue == null) { + if (value == null) { return null; } - return mValue.getClass().getSimpleName(); + return value.getClass().getSimpleName(); } public int valueCount() { // TODO: Collection support? - if (mValue != null && mValue.getClass().isArray()) { - return Array.getLength(mValue); + if (value != null && value.getClass().isArray()) { + return Array.getLength(value); } return 1; @@ -135,7 +135,7 @@ public abstract class AbstractEntry implements Entry { @Override public int hashCode() { - return mIdentifier.hashCode() + 31 * mValue.hashCode(); + return identifier.hashCode() + 31 * value.hashCode(); } @Override @@ -149,8 +149,8 @@ public abstract class AbstractEntry implements Entry { AbstractEntry other = (AbstractEntry) pOther; - return mIdentifier.equals(other.mIdentifier) && ( - mValue == null && other.mValue == null || mValue != null && mValue.equals(other.mValue) + return identifier.equals(other.identifier) && ( + value == null && other.value == null || value != null && value.equals(other.value) ); } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java index e1766f54..8d08a89b 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/Directory.java @@ -38,9 +38,9 @@ package com.twelvemonkeys.imageio.metadata; public interface Directory extends Iterable { // TODO: Spec when more entries exist? Or make Entry support multi-values!? // For multiple entries with same id in directory, the first entry (using the order from the stream) will be returned - Entry getEntryById(Object pIdentifier); + Entry getEntryById(Object identifier); - Entry getEntryByFieldName(String pName); + Entry getEntryByFieldName(String fieldName); // Iterator containing the entries in //Iterator getBestEntries(Object pIdentifier, Object pQualifier, String pLanguage); @@ -51,9 +51,9 @@ public interface Directory extends Iterable { // boolean replace(Entry pEntry)?? // boolean contains(Object pIdentifier)? - boolean add(Entry pEntry); + boolean add(Entry entry); - boolean remove(Object pEntry); // Object in case we retro-fit Collection/Map.. + boolean remove(Object entry); // Object in case we retro-fit Collection/Map.. int size(); diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java index 01457bf4..2888a5f0 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/MetadataReader.java @@ -39,5 +39,5 @@ import java.io.IOException; * @version $Id: MetadataReader.java,v 1.0 Nov 13, 2009 8:38:11 PM haraldk Exp$ */ public abstract class MetadataReader { - public abstract Directory read(ImageInputStream pInput) throws IOException; + public abstract Directory read(ImageInputStream input) throws IOException; } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java index d1ce5930..332ae6fd 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFDirectory.java @@ -41,7 +41,7 @@ import java.util.Collection; * @version $Id: EXIFDirectory.java,v 1.0 Nov 11, 2009 5:02:59 PM haraldk Exp$ */ final class EXIFDirectory extends AbstractDirectory { - EXIFDirectory(final Collection pEntries) { - super(pEntries); + EXIFDirectory(final Collection entries) { + super(entries); } } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java index 39c23ba9..2c401419 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFEntry.java @@ -38,20 +38,20 @@ import com.twelvemonkeys.imageio.metadata.AbstractEntry; * @version $Id: EXIFEntry.java,v 1.0 Nov 13, 2009 5:47:35 PM haraldk Exp$ */ final class EXIFEntry extends AbstractEntry { - final private short mType; + final private short type; - EXIFEntry(final int pIdentifier, final Object pValue, final short pType) { - super(pIdentifier, pValue); + EXIFEntry(final int identifier, final Object value, final short type) { + super(identifier, value); -// if (pType < 1 || pType > TIFF.TYPE_NAMES.length) { -// throw new IllegalArgumentException(String.format("Illegal EXIF type: %s", pType)); +// if (type < 1 || type > TIFF.TYPE_NAMES.length) { +// throw new IllegalArgumentException(String.format("Illegal EXIF type: %s", type)); // } - mType = pType; + this.type = type; } public short getType() { - return mType; + return type; } @Override @@ -110,6 +110,6 @@ final class EXIFEntry extends AbstractEntry { @Override public String getTypeName() { - return TIFF.TYPE_NAMES[mType - 1]; + return TIFF.TYPE_NAMES[type - 1]; } } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java index e4113a11..17d5badf 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/EXIFReader.java @@ -56,14 +56,14 @@ public final class EXIFReader extends MetadataReader { static final Collection KNOWN_IFDS = Arrays.asList(TIFF.TAG_EXIF_IFD, TIFF.TAG_GPS_IFD, TIFF.TAG_INTEROP_IFD); @Override - public Directory read(final ImageInputStream pInput) throws IOException { + public Directory read(final ImageInputStream input) throws IOException { byte[] bom = new byte[2]; - pInput.readFully(bom); + input.readFully(bom); if (bom[0] == 'I' && bom[1] == 'I') { - pInput.setByteOrder(ByteOrder.LITTLE_ENDIAN); + input.setByteOrder(ByteOrder.LITTLE_ENDIAN); } else if (bom[0] == 'M' && bom[1] == 'M') { - pInput.setByteOrder(ByteOrder.BIG_ENDIAN); + input.setByteOrder(ByteOrder.BIG_ENDIAN); } else { throw new IIOException(String.format("Invalid TIFF byte order mark '%s', expected: 'II' or 'MM'", StringUtil.decode(bom, 0, bom.length, "ASCII"))); @@ -71,14 +71,14 @@ public final class EXIFReader extends MetadataReader { // TODO: BigTiff uses version 43 instead of TIFF's 42, and header is slightly different, see // http://www.awaresystems.be/imaging/tiff/bigtiff.html - int magic = pInput.readUnsignedShort(); + int magic = input.readUnsignedShort(); if (magic != TIFF.TIFF_MAGIC) { throw new IIOException(String.format("Wrong TIFF magic in EXIF data: %04x, expected: %04x", magic, TIFF.TIFF_MAGIC)); } - long directoryOffset = pInput.readUnsignedInt(); + long directoryOffset = input.readUnsignedInt(); - return readDirectory(pInput, directoryOffset); + return readDirectory(input, directoryOffset); } private EXIFDirectory readDirectory(final ImageInputStream pInput, final long pOffset) throws IOException { diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java index ffe69ae0..6b9aed06 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/exif/Rational.java @@ -54,8 +54,8 @@ public final class Rational extends Number implements Comparable { // Inspired by http://www.cs.princeton.edu/introcs/92symbolic/Rational.java.html and java.lang.Integer static final Rational ZERO = new Rational(0, 1); - private final long mNumerator; - private final long mDenominator; + private final long numerator; + private final long denominator; public Rational(final long pNumber) { this(pNumber, 1); @@ -74,8 +74,8 @@ public final class Rational extends Number implements Comparable { long num = pNumerator / gcd; long den = pDenominator / gcd; - mNumerator = pDenominator >= 0 ? num : -num; - mDenominator = pDenominator >= 0 ? den : -den; + numerator = pDenominator >= 0 ? num : -num; + denominator = pDenominator >= 0 ? den : -den; } private static long gcd(final long m, final long n) { @@ -95,11 +95,11 @@ public final class Rational extends Number implements Comparable { } public long numerator() { - return mNumerator; + return numerator; } public long denominator() { - return mDenominator; + return denominator; } /// Number implementation @@ -121,7 +121,7 @@ public final class Rational extends Number implements Comparable { @Override public double doubleValue() { - return mNumerator / (double) mDenominator; + return numerator / (double) denominator; } /// Comparable implementation @@ -147,7 +147,7 @@ public final class Rational extends Number implements Comparable { @Override public String toString() { - return mDenominator == 1 ? Long.toString(mNumerator) : String.format("%s/%s", mNumerator, mDenominator); + return denominator == 1 ? Long.toString(numerator) : String.format("%s/%s", numerator, denominator); } /// Operations (adapted from http://www.cs.princeton.edu/introcs/92symbolic/Rational.java.html) @@ -161,10 +161,10 @@ public final class Rational extends Number implements Comparable { } // reduce p1/q2 and p2/q1, then multiply, where a = p1/q1 and b = p2/q2 - Rational c = new Rational(mNumerator, pOther.mDenominator); - Rational d = new Rational(pOther.mNumerator, mDenominator); + Rational c = new Rational(numerator, pOther.denominator); + Rational d = new Rational(pOther.numerator, denominator); - return new Rational(c.mNumerator * d.mNumerator, c.mDenominator * d.mDenominator); + return new Rational(c.numerator * d.numerator, c.denominator * d.denominator); } // return a + b, staving off overflow @@ -178,20 +178,20 @@ public final class Rational extends Number implements Comparable { } // Find gcd of numerators and denominators - long f = gcd(mNumerator, pOther.mNumerator); - long g = gcd(mDenominator, pOther.mDenominator); + long f = gcd(numerator, pOther.numerator); + long g = gcd(denominator, pOther.denominator); // add cross-product terms for numerator // multiply back in return new Rational( - ((mNumerator / f) * (pOther.mDenominator / g) + (pOther.mNumerator / f) * (mDenominator / g)) * f, - lcm(mDenominator, pOther.mDenominator) + ((numerator / f) * (pOther.denominator / g) + (pOther.numerator / f) * (denominator / g)) * f, + lcm(denominator, pOther.denominator) ); } // return -a public Rational negate() { - return new Rational(-mNumerator, mDenominator); + return new Rational(-numerator, denominator); } // return a - b @@ -200,7 +200,7 @@ public final class Rational extends Number implements Comparable { } public Rational reciprocal() { - return new Rational(mDenominator, mNumerator); + return new Rational(denominator, numerator); } // return a / b diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java index a3fb3325..133f07bc 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCDirectory.java @@ -41,7 +41,7 @@ import java.util.Collection; * @version $Id: IPTCDirectory.java,v 1.0 Nov 11, 2009 5:02:59 PM haraldk Exp$ */ final class IPTCDirectory extends AbstractDirectory { - IPTCDirectory(final Collection pEntries) { - super(pEntries); + IPTCDirectory(final Collection entries) { + super(entries); } } \ No newline at end of file diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java index 3b1175a2..2f14cd47 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCEntry.java @@ -38,8 +38,8 @@ import com.twelvemonkeys.imageio.metadata.AbstractEntry; * @version $Id: IPTCEntry.java,v 1.0 Nov 13, 2009 8:57:04 PM haraldk Exp$ */ class IPTCEntry extends AbstractEntry { - public IPTCEntry(final int pTagId, final Object pValue) { - super(pTagId, pValue); + public IPTCEntry(final int tagId, final Object value) { + super(tagId, value); } @Override diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java index a9f23b96..22dfb3bb 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/iptc/IPTCReader.java @@ -57,18 +57,18 @@ public final class IPTCReader extends MetadataReader { private static final int ENCODING_UNSPECIFIED = 0; private static final int ENCODING_UTF_8 = 0x1b2547; - private int mEncoding = ENCODING_UNSPECIFIED; + private int encoding = ENCODING_UNSPECIFIED; @Override - public Directory read(final ImageInputStream pInput) throws IOException { + public Directory read(final ImageInputStream input) throws IOException { final List entries = new ArrayList(); // 0x1c identifies start of a tag - while (pInput.read() == 0x1c) { - short tagId = pInput.readShort(); - int tagByteCount = pInput.readUnsignedShort(); - Entry entry = readEntry(pInput, tagId, tagByteCount); + while (input.read() == 0x1c) { + short tagId = input.readShort(); + int tagByteCount = input.readUnsignedShort(); + Entry entry = readEntry(input, tagId, tagByteCount); if (entry != null) { entries.add(entry); @@ -85,7 +85,7 @@ public final class IPTCReader extends MetadataReader { case IPTC.TAG_CODED_CHARACTER_SET: // TODO: Mapping from ISO 646 to Java supported character sets? // TODO: Move somewhere else? - mEncoding = parseEncoding(pInput, pLength); + encoding = parseEncoding(pInput, pLength); return null; case IPTC.TAG_RECORD_VERSION: // A single unsigned short value @@ -140,7 +140,7 @@ public final class IPTCReader extends MetadataReader { return chars.toString(); } catch (CharacterCodingException notUTF8) { - if (mEncoding == ENCODING_UTF_8) { + if (encoding == ENCODING_UTF_8) { throw new IIOException("Wrong encoding of IPTC data, explicitly set to UTF-8 in DataSet 1:90", notUTF8); } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java index 8f4d53a2..484a5cf9 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPDirectory.java @@ -45,7 +45,7 @@ final class XMPDirectory extends AbstractDirectory { // TODO: XMPDirectory, maybe not even an AbstractDirectory // - Keeping the Document would allow for easier serialization // TODO: Or use direct SAX parsing - public XMPDirectory(List pEntries) { - super(pEntries); + public XMPDirectory(List entries) { + super(entries); } } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java index 202a0ce7..48c760c9 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPEntry.java @@ -38,20 +38,20 @@ import com.twelvemonkeys.imageio.metadata.AbstractEntry; * @version $Id: XMPEntry.java,v 1.0 Nov 17, 2009 9:38:39 PM haraldk Exp$ */ final class XMPEntry extends AbstractEntry { - private final String mFieldName; + private final String fieldName; - public XMPEntry(final String pIdentifier, final Object pValue) { - this(pIdentifier, null, pValue); + public XMPEntry(final String identifier, final Object pValue) { + this(identifier, null, pValue); } - public XMPEntry(final String pIdentifier, final String pFieldName, final Object pValue) { - super(pIdentifier, pValue); - mFieldName = pFieldName; + public XMPEntry(final String identifier, final String fieldName, final Object value) { + super(identifier, value); + this.fieldName = fieldName; } @SuppressWarnings({"SuspiciousMethodCalls"}) @Override public String getFieldName() { - return mFieldName != null ? mFieldName : XMP.DEFAULT_NS_MAPPING.get(getIdentifier()); + return fieldName != null ? fieldName : XMP.DEFAULT_NS_MAPPING.get(getIdentifier()); } } diff --git a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java index c1c46486..2e470822 100644 --- a/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java +++ b/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPReader.java @@ -56,7 +56,7 @@ import java.util.*; */ public final class XMPReader extends MetadataReader { @Override - public Directory read(final ImageInputStream pInput) throws IOException { + public Directory read(final ImageInputStream input) throws IOException { // pInput.mark(); // // BufferedReader reader = new BufferedReader(new InputStreamReader(IIOUtil.createStreamAdapter(pInput), Charset.forName("UTF-8"))); @@ -75,7 +75,7 @@ public final class XMPReader extends MetadataReader { // TODO: Determine encoding and parse using a Reader... // TODO: Refactor scanner to return inputstream? DocumentBuilder builder = factory.newDocumentBuilder(); - Document document = builder.parse(new InputSource(IIOUtil.createStreamAdapter(pInput))); + Document document = builder.parse(new InputSource(IIOUtil.createStreamAdapter(input))); // XMLSerializer serializer = new XMLSerializer(System.err, System.getProperty("file.encoding")); // serializer.serialize(document); diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java index 1ab9fff8..4d46cbbe 100644 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java @@ -110,23 +110,23 @@ public class PICTImageReader extends ImageReaderBase { static boolean DEBUG = false; // Private fields - private QuickDrawContext mContext; - private Rectangle mFrame; + private QuickDrawContext context; + private Rectangle frame; - private int mVersion; + private int version; // Variables for storing draw status - private Point mPenPosition = new Point(0, 0); - private Rectangle mLastRectangle = new Rectangle(0, 0); + private Point penPosition = new Point(0, 0); + private Rectangle lastRectangle = new Rectangle(0, 0); // Ratio between the screen resolution and the image resolution - private double mScreenImageXRatio; - private double mScreenImageYRatio; + private double screenImageXRatio; + private double screenImageYRatio; // List of images created during image import - private List mImages = new ArrayList(); - private long mImageStartStreamPos; - protected int mPicSize; + private List images = new ArrayList(); + private long imageStartStreamPos; + protected int picSize; public PICTImageReader() { this(null); @@ -137,9 +137,9 @@ public class PICTImageReader extends ImageReaderBase { } protected void resetMembers() { - mContext = null; - mFrame = null; - mImages.clear(); + context = null; + frame = null; + images.clear(); } /** @@ -149,14 +149,16 @@ public class PICTImageReader extends ImageReaderBase { * @throws IOException if an I/O error occurs while reading the image. */ private Rectangle getPICTFrame() throws IOException { - if (mFrame == null) { + if (frame == null) { // Read in header information readPICTHeader(imageInput); + if (DEBUG) { System.out.println("Done reading PICT header!"); } } - return mFrame; + + return frame; } /** @@ -184,9 +186,10 @@ public class PICTImageReader extends ImageReaderBase { private void readPICTHeader0(final ImageInputStream pStream) throws IOException { // Get size - mPicSize = pStream.readUnsignedShort(); + picSize = pStream.readUnsignedShort(); + if (DEBUG) { - System.out.println("picSize: " + mPicSize); + System.out.println("picSize: " + picSize); } // Get frame at 72 dpi @@ -197,17 +200,17 @@ public class PICTImageReader extends ImageReaderBase { int h = pStream.readUnsignedShort(); int w = pStream.readUnsignedShort(); - mFrame = new Rectangle(x, y, w - x, h - y); - if (mFrame.width < 0 || mFrame.height < 0) { - throw new IIOException("Error in PICT header: Invalid frame " + mFrame); + frame = new Rectangle(x, y, w - x, h - y); + if (frame.width < 0 || frame.height < 0) { + throw new IIOException("Error in PICT header: Invalid frame " + frame); } if (DEBUG) { - System.out.println("mFrame: " + mFrame); + System.out.println("frame: " + frame); } // Set default display ratios. 72 dpi is the standard Macintosh resolution. - mScreenImageXRatio = 1.0; - mScreenImageYRatio = 1.0; + screenImageXRatio = 1.0; + screenImageYRatio = 1.0; // Get the version, since the way of reading the rest depends on it boolean isExtendedV2 = false; @@ -217,10 +220,10 @@ public class PICTImageReader extends ImageReaderBase { } if (version == (PICT.OP_VERSION << 8) + 0x01) { - mVersion = 1; + this.version = 1; } else if (version == PICT.OP_VERSION && pStream.readShort() == PICT.OP_VERSION_2) { - mVersion = 2; + this.version = 2; // Read in version 2 header op and test that it is valid: HeaderOp 0x0C00 if (pStream.readShort() != PICT.OP_HEADER_OP) { @@ -249,10 +252,10 @@ public class PICTImageReader extends ImageReaderBase { // int h (fixed point) double h2 = PICTUtil.readFixedPoint(pStream); - mScreenImageXRatio = (w - x) / (w2 - x2); - mScreenImageYRatio = (h - y) / (h2 - y2); + screenImageXRatio = (w - x) / (w2 - x2); + screenImageYRatio = (h - y) / (h2 - y2); - if (mScreenImageXRatio < 0 || mScreenImageYRatio < 0) { + if (screenImageXRatio < 0 || screenImageYRatio < 0) { throw new IIOException("Error in PICT header: Invalid bounds " + new Rectangle.Double(x2, y2, w2 - x2, h2 - y2)); } if (DEBUG) { @@ -288,10 +291,10 @@ public class PICTImageReader extends ImageReaderBase { // short w short w2 = pStream.readShort(); - mScreenImageXRatio = (w - x) / (double) (w2 - x2); - mScreenImageYRatio = (h - y) / (double) (h2 - y2); + screenImageXRatio = (w - x) / (double) (w2 - x2); + screenImageYRatio = (h - y) / (double) (h2 - y2); - if (mScreenImageXRatio < 0 || mScreenImageYRatio < 0) { + if (screenImageXRatio < 0 || screenImageYRatio < 0) { throw new IIOException("Error in PICT header: Invalid bounds " + new Rectangle.Double(x2, y2, w2 - x2, h2 - y2)); } if (DEBUG) { @@ -303,8 +306,8 @@ public class PICTImageReader extends ImageReaderBase { } if (DEBUG) { - System.out.println("screenImageXRatio: " + mScreenImageXRatio); - System.out.println("screenImageYRatio: " + mScreenImageYRatio); + System.out.println("screenImageXRatio: " + screenImageXRatio); + System.out.println("screenImageYRatio: " + screenImageYRatio); } } else { @@ -313,13 +316,13 @@ public class PICTImageReader extends ImageReaderBase { } if (DEBUG) { - System.out.println("Version: " + mVersion + (isExtendedV2 ? " extended" : "")); + System.out.println("Version: " + this.version + (isExtendedV2 ? " extended" : "")); } - mImageStartStreamPos = pStream.getStreamPosition(); + imageStartStreamPos = pStream.getStreamPosition(); // Won't need header data again (NOTE: We'll only get here if no exception is thrown) - pStream.flushBefore(mImageStartStreamPos); + pStream.flushBefore(imageStartStreamPos); } static void skipNullHeader(final ImageInputStream pStream) throws IOException { @@ -341,7 +344,7 @@ public class PICTImageReader extends ImageReaderBase { * @throws IOException if an I/O error occurs while reading the image. */ private void drawOnto(Graphics2D pGraphics) throws IOException { - mContext = new QuickDrawContext(pGraphics); + context = new QuickDrawContext(pGraphics); readPICTopcodes(imageInput); if (DEBUG) { @@ -360,7 +363,7 @@ public class PICTImageReader extends ImageReaderBase { * @throws java.io.IOException if an I/O error occurs while reading the image. */ private void readPICTopcodes(ImageInputStream pStream) throws IOException { - pStream.seek(mImageStartStreamPos); + pStream.seek(imageStartStreamPos); int opCode, dh, dv, dataLength; byte[] colorBuffer = new byte[3 * PICT.COLOR_COMP_SIZE]; @@ -386,7 +389,7 @@ public class PICTImageReader extends ImageReaderBase { // Read from file until we read the end of picture opcode do { // Read opcode, version 1: byte, version 2: short - if (mVersion == 1) { + if (version == 1) { opCode = pStream.readUnsignedByte(); } else { @@ -431,7 +434,7 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_BK_PAT: // Get the data - mContext.setBackgroundPattern(PICTUtil.readPattern(pStream)); + context.setBackgroundPattern(PICTUtil.readPattern(pStream)); if (DEBUG) { System.out.println("bkPat"); } @@ -490,7 +493,7 @@ public class PICTImageReader extends ImageReaderBase { // Get the two words // NOTE: This is out of order, compared to other Points Dimension pnsize = new Dimension(pStream.readUnsignedShort(), pStream.readUnsignedShort()); - mContext.setPenSize(pnsize); + context.setPenSize(pnsize); if (DEBUG) { System.out.println("pnsize: " + pnsize); } @@ -503,12 +506,12 @@ public class PICTImageReader extends ImageReaderBase { System.out.println("pnMode: " + mode); } - mContext.setPenMode(mode); + context.setPenMode(mode); break; case PICT.OP_PN_PAT: - mContext.setPenPattern(PICTUtil.readPattern(pStream)); + context.setPenPattern(PICTUtil.readPattern(pStream)); if (DEBUG) { System.out.println("pnPat"); } @@ -557,7 +560,7 @@ public class PICTImageReader extends ImageReaderBase { // currentFont = mGraphics.getFont(); // mGraphics.setFont(new Font(currentFont.getName(), currentFont.getStyle(), tx_size)); //} - mContext.setTextSize(tx_size); + context.setTextSize(tx_size); if (DEBUG) { System.out.println("txSize: " + tx_size); } @@ -599,15 +602,15 @@ public class PICTImageReader extends ImageReaderBase { case 0x0012: // BkPixPat bg = PICTUtil.readColorPattern(pStream); - mContext.setBackgroundPattern(bg); + context.setBackgroundPattern(bg); break; case 0x0013: // PnPixPat pen = PICTUtil.readColorPattern(pStream); - mContext.setBackgroundPattern(pen); + context.setBackgroundPattern(pen); break; case 0x0014: // FillPixPat fill = PICTUtil.readColorPattern(pStream); - mContext.setBackgroundPattern(fill); + context.setBackgroundPattern(fill); break; case PICT.OP_PN_LOC_H_FRAC:// TO BE DONE??? @@ -650,7 +653,7 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_HILITE_MODE: // Change color to hilite color - mContext.setPenPattern(new BitMapPattern(hilight)); + context.setPenPattern(new BitMapPattern(hilight)); if (DEBUG) { System.out.println("opHiliteMode"); } @@ -691,14 +694,14 @@ public class PICTImageReader extends ImageReaderBase { y = getYPtCoord(pStream.readUnsignedShort()); x = getXPtCoord(pStream.readUnsignedShort()); - mPenPosition.setLocation(x, y); + penPosition.setLocation(x, y); // Move pen to new position, draw line - mContext.moveTo(origin); - mContext.lineTo(mPenPosition); + context.moveTo(origin); + context.lineTo(penPosition); if (DEBUG) { - System.out.println("line from: " + origin + " to: " + mPenPosition); + System.out.println("line from: " + origin + " to: " + penPosition); } break; @@ -708,10 +711,10 @@ public class PICTImageReader extends ImageReaderBase { x = getXPtCoord(pStream.readUnsignedShort()); // Draw line - mContext.line(x, y); + context.line(x, y); if (DEBUG) { - System.out.println("lineFrom to: " + mPenPosition); + System.out.println("lineFrom to: " + penPosition); } break; @@ -726,8 +729,8 @@ public class PICTImageReader extends ImageReaderBase { dh_dv = new Point(x, y); // Move pen to new position, draw line if we have a graphics - mPenPosition.setLocation(origin.x + dh_dv.x, origin.y + dh_dv.y); - mContext.lineTo(mPenPosition); + penPosition.setLocation(origin.x + dh_dv.x, origin.y + dh_dv.y); + context.lineTo(penPosition); if (DEBUG) { System.out.println("Short line origin: " + origin + ", dh,dv: " + dh_dv); @@ -740,7 +743,7 @@ public class PICTImageReader extends ImageReaderBase { x = getXPtCoord(pStream.readByte()); // Draw line - mContext.line(x, y); + context.line(x, y); if (DEBUG) { System.out.println("Short line from dh,dv: " + x + "," + y); @@ -765,30 +768,30 @@ public class PICTImageReader extends ImageReaderBase { y = getYPtCoord(pStream.readUnsignedShort()); x = getXPtCoord(pStream.readUnsignedShort()); origin = new Point(x, y); - mPenPosition = origin; - mContext.moveTo(mPenPosition); + penPosition = origin; + context.moveTo(penPosition); text = PICTUtil.readPascalString(pStream); // TODO //if (mGraphics != null) { - // mGraphics.drawString(text, mPenPosition.x, mPenPosition.y); + // mGraphics.drawString(text, penPosition.x, penPosition.y); //} - mContext.drawString(text); + context.drawString(text); if (DEBUG) { - System.out.println("longText origin: " + mPenPosition + ", text:" + text); + System.out.println("longText origin: " + penPosition + ", text:" + text); } break; case PICT.OP_DH_TEXT:// OK, not tested // Get dh dh = getXPtCoord(pStream.readByte()); - mPenPosition.translate(dh, 0); - mContext.moveTo(mPenPosition); + penPosition.translate(dh, 0); + context.moveTo(penPosition); text = PICTUtil.readPascalString(pStream); // TODO // if (mGraphics != null) { -// mGraphics.drawString(text, mPenPosition.x, mPenPosition.y); +// mGraphics.drawString(text, penPosition.x, penPosition.y); // } - mContext.drawString(text); + context.drawString(text); if (DEBUG) { System.out.println("DHText dh: " + dh + ", text:" + text); } @@ -797,14 +800,14 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_DV_TEXT:// OK, not tested // Get dh dv = getYPtCoord(pStream.readByte()); - mPenPosition.translate(0, dv); - mContext.moveTo(mPenPosition); + penPosition.translate(0, dv); + context.moveTo(penPosition); text = PICTUtil.readPascalString(pStream); // TODO //if (mGraphics != null) { - // mGraphics.drawString(text, mPenPosition.x, mPenPosition.y); + // mGraphics.drawString(text, penPosition.x, penPosition.y); //} - mContext.drawString(text); + context.drawString(text); if (DEBUG) { System.out.println("DVText dv: " + dv + ", text:" + text); } @@ -814,16 +817,16 @@ public class PICTImageReader extends ImageReaderBase { // Get dh, dv y = getYPtCoord(pStream.readByte()); x = getXPtCoord(pStream.readByte()); - mPenPosition.translate(x, y); - mContext.moveTo(mPenPosition); + penPosition.translate(x, y); + context.moveTo(penPosition); text = PICTUtil.readPascalString(pStream); // TODO //if (mGraphics != null) { - // mGraphics.drawString(text, mPenPosition.x, mPenPosition.y); + // mGraphics.drawString(text, penPosition.x, penPosition.y); //} - mContext.drawString(text); + context.drawString(text); if (DEBUG) { - System.out.println("DHDVText penPosition: " + mPenPosition + ", text:" + text); + System.out.println("DHDVText penPosition: " + penPosition + ", text:" + text); } break; @@ -843,7 +846,7 @@ public class PICTImageReader extends ImageReaderBase { // mGraphics.setFont(Font.decode(text) // .deriveFont(currentFont.getStyle(), currentFont.getSize())); //} - mContext.drawString(text); + context.drawString(text); if (DEBUG) { System.out.println("fontName: \"" + text +"\""); } @@ -882,7 +885,7 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_INVERT_RECT:// OK, not tested case PICT.OP_FILL_RECT:// OK, not tested // Get the frame rectangle - readRectangle(pStream, mLastRectangle); + readRectangle(pStream, lastRectangle); case PICT.OP_FRAME_SAME_RECT:// OK, not tested case PICT.OP_PAINT_SAME_RECT:// OK, not tested @@ -893,23 +896,23 @@ public class PICTImageReader extends ImageReaderBase { switch (opCode) { case PICT.OP_FRAME_RECT: case PICT.OP_FRAME_SAME_RECT: - mContext.frameRect(mLastRectangle); + context.frameRect(lastRectangle); break; case PICT.OP_PAINT_RECT: case PICT.OP_PAINT_SAME_RECT: - mContext.paintRect(mLastRectangle); + context.paintRect(lastRectangle); break; case PICT.OP_ERASE_RECT: case PICT.OP_ERASE_SAME_RECT: - mContext.eraseRect(mLastRectangle); + context.eraseRect(lastRectangle); break; case PICT.OP_INVERT_RECT: case PICT.OP_INVERT_SAME_RECT: - mContext.invertRect(mLastRectangle); + context.invertRect(lastRectangle); break; case PICT.OP_FILL_RECT: case PICT.OP_FILL_SAME_RECT: - mContext.fillRect(mLastRectangle, fill); + context.fillRect(lastRectangle, fill); break; } @@ -917,34 +920,34 @@ public class PICTImageReader extends ImageReaderBase { if (DEBUG) { switch (opCode) { case PICT.OP_FRAME_RECT: - System.out.println("frameRect: " + mLastRectangle); + System.out.println("frameRect: " + lastRectangle); break; case PICT.OP_PAINT_RECT: - System.out.println("paintRect: " + mLastRectangle); + System.out.println("paintRect: " + lastRectangle); break; case PICT.OP_ERASE_RECT: - System.out.println("eraseRect: " + mLastRectangle); + System.out.println("eraseRect: " + lastRectangle); break; case PICT.OP_INVERT_RECT: - System.out.println("invertRect: " + mLastRectangle); + System.out.println("invertRect: " + lastRectangle); break; case PICT.OP_FILL_RECT: - System.out.println("fillRect: " + mLastRectangle); + System.out.println("fillRect: " + lastRectangle); break; case PICT.OP_FRAME_SAME_RECT: - System.out.println("frameSameRect: " + mLastRectangle); + System.out.println("frameSameRect: " + lastRectangle); break; case PICT.OP_PAINT_SAME_RECT: - System.out.println("paintSameRect: " + mLastRectangle); + System.out.println("paintSameRect: " + lastRectangle); break; case PICT.OP_ERASE_SAME_RECT: - System.out.println("eraseSameRect: " + mLastRectangle); + System.out.println("eraseSameRect: " + lastRectangle); break; case PICT.OP_INVERT_SAME_RECT: - System.out.println("invertSameRect: " + mLastRectangle); + System.out.println("invertSameRect: " + lastRectangle); break; case PICT.OP_FILL_SAME_RECT: - System.out.println("fillSameRect: " + mLastRectangle); + System.out.println("fillSameRect: " + lastRectangle); break; } } @@ -969,7 +972,7 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_INVERT_R_RECT:// OK, not tested case PICT.OP_FILL_R_RECT:// OK, not tested // Get the frame rectangle - readRectangle(pStream, mLastRectangle); + readRectangle(pStream, lastRectangle); case PICT.OP_FRAME_SAME_R_RECT:// OK, not tested case PICT.OP_PAINT_SAME_R_RECT:// OK, not tested @@ -980,23 +983,23 @@ public class PICTImageReader extends ImageReaderBase { switch (opCode) { case PICT.OP_FRAME_R_RECT: case PICT.OP_FRAME_SAME_R_RECT: - mContext.frameRoundRect(mLastRectangle, ovSize.x, ovSize.y); + context.frameRoundRect(lastRectangle, ovSize.x, ovSize.y); break; case PICT.OP_PAINT_R_RECT: case PICT.OP_PAINT_SAME_R_RECT: - mContext.paintRoundRect(mLastRectangle, ovSize.x, ovSize.y); + context.paintRoundRect(lastRectangle, ovSize.x, ovSize.y); break; case PICT.OP_ERASE_R_RECT: case PICT.OP_ERASE_SAME_R_RECT: - mContext.eraseRoundRect(mLastRectangle, ovSize.x, ovSize.y); + context.eraseRoundRect(lastRectangle, ovSize.x, ovSize.y); break; case PICT.OP_INVERT_R_RECT: case PICT.OP_INVERT_SAME_R_RECT: - mContext.invertRoundRect(mLastRectangle, ovSize.x, ovSize.y); + context.invertRoundRect(lastRectangle, ovSize.x, ovSize.y); break; case PICT.OP_FILL_R_RECT: case PICT.OP_FILL_SAME_R_RECT: - mContext.fillRoundRect(mLastRectangle, ovSize.x, ovSize.y, fill); + context.fillRoundRect(lastRectangle, ovSize.x, ovSize.y, fill); break; } @@ -1004,34 +1007,34 @@ public class PICTImageReader extends ImageReaderBase { if (DEBUG) { switch (opCode) { case PICT.OP_FRAME_R_RECT: - System.out.println("frameRRect: " + mLastRectangle); + System.out.println("frameRRect: " + lastRectangle); break; case PICT.OP_PAINT_R_RECT: - System.out.println("paintRRect: " + mLastRectangle); + System.out.println("paintRRect: " + lastRectangle); break; case PICT.OP_ERASE_R_RECT: - System.out.println("eraseRRect: " + mLastRectangle); + System.out.println("eraseRRect: " + lastRectangle); break; case PICT.OP_INVERT_R_RECT: - System.out.println("invertRRect: " + mLastRectangle); + System.out.println("invertRRect: " + lastRectangle); break; case PICT.OP_FILL_R_RECT: - System.out.println("fillRRect: " + mLastRectangle); + System.out.println("fillRRect: " + lastRectangle); break; case PICT.OP_FRAME_SAME_R_RECT: - System.out.println("frameSameRRect: " + mLastRectangle); + System.out.println("frameSameRRect: " + lastRectangle); break; case PICT.OP_PAINT_SAME_R_RECT: - System.out.println("paintSameRRect: " + mLastRectangle); + System.out.println("paintSameRRect: " + lastRectangle); break; case PICT.OP_ERASE_SAME_R_RECT: - System.out.println("eraseSameRRect: " + mLastRectangle); + System.out.println("eraseSameRRect: " + lastRectangle); break; case PICT.OP_INVERT_SAME_R_RECT: - System.out.println("invertSameRRect: " + mLastRectangle); + System.out.println("invertSameRRect: " + lastRectangle); break; case PICT.OP_FILL_SAME_R_RECT: - System.out.println("fillSameRRect: " + mLastRectangle); + System.out.println("fillSameRRect: " + lastRectangle); break; } } @@ -1048,7 +1051,7 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_INVERT_OVAL:// OK, not tested case PICT.OP_FILL_OVAL:// OK, not tested // Get the frame rectangle - readRectangle(pStream, mLastRectangle); + readRectangle(pStream, lastRectangle); case PICT.OP_FRAME_SAME_OVAL:// OK, not tested case PICT.OP_PAINT_SAME_OVAL:// OK, not tested case PICT.OP_ERASE_SAME_OVAL:// OK, not tested @@ -1058,23 +1061,23 @@ public class PICTImageReader extends ImageReaderBase { switch (opCode) { case PICT.OP_FRAME_OVAL: case PICT.OP_FRAME_SAME_OVAL: - mContext.frameOval(mLastRectangle); + context.frameOval(lastRectangle); break; case PICT.OP_PAINT_OVAL: case PICT.OP_PAINT_SAME_OVAL: - mContext.paintOval(mLastRectangle); + context.paintOval(lastRectangle); break; case PICT.OP_ERASE_OVAL: case PICT.OP_ERASE_SAME_OVAL: - mContext.eraseOval(mLastRectangle); + context.eraseOval(lastRectangle); break; case PICT.OP_INVERT_OVAL: case PICT.OP_INVERT_SAME_OVAL: - mContext.invertOval(mLastRectangle); + context.invertOval(lastRectangle); break; case PICT.OP_FILL_OVAL: case PICT.OP_FILL_SAME_OVAL: - mContext.fillOval(mLastRectangle, fill); + context.fillOval(lastRectangle, fill); break; } @@ -1082,34 +1085,34 @@ public class PICTImageReader extends ImageReaderBase { if (DEBUG) { switch (opCode) { case PICT.OP_FRAME_OVAL: - System.out.println("frameOval: " + mLastRectangle); + System.out.println("frameOval: " + lastRectangle); break; case PICT.OP_PAINT_OVAL: - System.out.println("paintOval: " + mLastRectangle); + System.out.println("paintOval: " + lastRectangle); break; case PICT.OP_ERASE_OVAL: - System.out.println("eraseOval: " + mLastRectangle); + System.out.println("eraseOval: " + lastRectangle); break; case PICT.OP_INVERT_OVAL: - System.out.println("invertOval: " + mLastRectangle); + System.out.println("invertOval: " + lastRectangle); break; case PICT.OP_FILL_OVAL: - System.out.println("fillOval: " + mLastRectangle); + System.out.println("fillOval: " + lastRectangle); break; case PICT.OP_FRAME_SAME_OVAL: - System.out.println("frameSameOval: " + mLastRectangle); + System.out.println("frameSameOval: " + lastRectangle); break; case PICT.OP_PAINT_SAME_OVAL: - System.out.println("paintSameOval: " + mLastRectangle); + System.out.println("paintSameOval: " + lastRectangle); break; case PICT.OP_ERASE_SAME_OVAL: - System.out.println("eraseSameOval: " + mLastRectangle); + System.out.println("eraseSameOval: " + lastRectangle); break; case PICT.OP_INVERT_SAME_OVAL: - System.out.println("invertSameOval: " + mLastRectangle); + System.out.println("invertSameOval: " + lastRectangle); break; case PICT.OP_FILL_SAME_OVAL: - System.out.println("fillSameOval: " + mLastRectangle); + System.out.println("fillSameOval: " + lastRectangle); break; } } @@ -1141,7 +1144,7 @@ public class PICTImageReader extends ImageReaderBase { case PICT.OP_INVERT_ARC:// OK, not tested case PICT.OP_FILL_ARC:// OK, not tested // Get the frame rectangle - readRectangle(pStream, mLastRectangle); + readRectangle(pStream, lastRectangle); case PICT.OP_FRAME_SAME_ARC:// OK, not tested case PICT.OP_PAINT_SAME_ARC:// OK, not tested case PICT.OP_ERASE_SAME_ARC:// OK, not tested @@ -1159,23 +1162,23 @@ public class PICTImageReader extends ImageReaderBase { switch (opCode) { case PICT.OP_FRAME_ARC: case PICT.OP_FRAME_SAME_ARC: - mContext.frameArc(mLastRectangle, arcAngles.x, arcAngles.y); + context.frameArc(lastRectangle, arcAngles.x, arcAngles.y); break; case PICT.OP_PAINT_ARC: case PICT.OP_PAINT_SAME_ARC: - mContext.paintArc(mLastRectangle, arcAngles.x, arcAngles.y); + context.paintArc(lastRectangle, arcAngles.x, arcAngles.y); break; case PICT.OP_ERASE_ARC: case PICT.OP_ERASE_SAME_ARC: - mContext.eraseArc(mLastRectangle, arcAngles.x, arcAngles.y); + context.eraseArc(lastRectangle, arcAngles.x, arcAngles.y); break; case PICT.OP_INVERT_ARC: case PICT.OP_INVERT_SAME_ARC: - mContext.invertArc(mLastRectangle, arcAngles.x, arcAngles.y); + context.invertArc(lastRectangle, arcAngles.x, arcAngles.y); break; case PICT.OP_FILL_ARC: case PICT.OP_FILL_SAME_ARC: - mContext.fillArc(mLastRectangle, arcAngles.x, arcAngles.y, fill); + context.fillArc(lastRectangle, arcAngles.x, arcAngles.y, fill); break; } @@ -1183,34 +1186,34 @@ public class PICTImageReader extends ImageReaderBase { if (DEBUG) { switch (opCode) { case PICT.OP_FRAME_ARC: - System.out.println("frameArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("frameArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_PAINT_ARC: - System.out.println("paintArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("paintArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_ERASE_ARC: - System.out.println("eraseArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("eraseArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_INVERT_ARC: - System.out.println("invertArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("invertArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_FILL_ARC: - System.out.println("fillArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("fillArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_FRAME_SAME_ARC: - System.out.println("frameSameArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("frameSameArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_PAINT_SAME_ARC: - System.out.println("paintSameArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("paintSameArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_ERASE_SAME_ARC: - System.out.println("eraseSameArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("eraseSameArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_INVERT_SAME_ARC: - System.out.println("invertSameArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("invertSameArc: " + lastRectangle + ", angles:" + arcAngles); break; case PICT.OP_FILL_SAME_ARC: - System.out.println("fillSameArc: " + mLastRectangle + ", angles:" + arcAngles); + System.out.println("fillSameArc: " + lastRectangle + ", angles:" + arcAngles); break; } } @@ -1256,23 +1259,23 @@ public class PICTImageReader extends ImageReaderBase { switch (opCode) { case PICT.OP_FRAME_POLY: case PICT.OP_FRAME_SAME_POLY: - mContext.framePoly(polygon); + context.framePoly(polygon); break; case PICT.OP_PAINT_POLY: case PICT.OP_PAINT_SAME_POLY: - mContext.paintPoly(polygon); + context.paintPoly(polygon); break; case PICT.OP_ERASE_POLY: case PICT.OP_ERASE_SAME_POLY: - mContext.erasePoly(polygon); + context.erasePoly(polygon); break; case PICT.OP_INVERT_POLY: case PICT.OP_INVERT_SAME_POLY: - mContext.invertPoly(polygon); + context.invertPoly(polygon); break; case PICT.OP_FILL_POLY: case PICT.OP_FILL_SAME_POLY: - mContext.fillPoly(polygon, fill); + context.fillPoly(polygon, fill); break; } @@ -1346,23 +1349,23 @@ public class PICTImageReader extends ImageReaderBase { switch (opCode) { case PICT.OP_FRAME_RGN: case PICT.OP_FRAME_SAME_RGN: - mContext.frameRegion(new Area(region)); + context.frameRegion(new Area(region)); break; case PICT.OP_PAINT_RGN: case PICT.OP_PAINT_SAME_RGN: - mContext.paintRegion(new Area(region)); + context.paintRegion(new Area(region)); break; case PICT.OP_ERASE_RGN: case PICT.OP_ERASE_SAME_RGN: - mContext.eraseRegion(new Area(region)); + context.eraseRegion(new Area(region)); break; case PICT.OP_INVERT_RGN: case PICT.OP_INVERT_SAME_RGN: - mContext.invertRegion(new Area(region)); + context.invertRegion(new Area(region)); break; case PICT.OP_FILL_RGN: case PICT.OP_FILL_SAME_RGN: - mContext.fillRegion(new Area(region), fill); + context.fillRegion(new Area(region), fill); break; } } @@ -1461,7 +1464,7 @@ public class PICTImageReader extends ImageReaderBase { readRectangle(pStream, dstRect); mode = pStream.readUnsignedShort(); - mContext.setPenMode(mode); // TODO: Or parameter? + context.setPenMode(mode); // TODO: Or parameter? if (DEBUG) { System.out.print("bitsRect, rowBytes: " + rowBytes); @@ -1491,7 +1494,7 @@ public class PICTImageReader extends ImageReaderBase { // Draw pixel data Rectangle rect = new Rectangle(srcRect); rect.translate(-bounds.x, -bounds.y); - mContext.copyBits(image, rect, dstRect, mode, null); + context.copyBits(image, rect, dstRect, mode, null); //mGraphics.drawImage(image, // dstRect.x, dstRect.y, // dstRect.x + dstRect.width, dstRect.y + dstRect.height, @@ -1729,7 +1732,7 @@ public class PICTImageReader extends ImageReaderBase { BufferedImage image = QuickTime.decompress(pStream); if (image != null) { - mContext.copyBits(image, new Rectangle(image.getWidth(), image.getHeight()), destination, QuickDraw.SRC_COPY, null); + context.copyBits(image, new Rectangle(image.getWidth(), image.getHeight()), destination, QuickDraw.SRC_COPY, null); pStream.seek(pos + dataLength); // Might be word-align mismatch here @@ -2068,7 +2071,7 @@ public class PICTImageReader extends ImageReaderBase { // We add all new images to it. If we are just replaying, then // "pPixmapCount" will never be greater than the size of the vector - if (mImages.size() <= pPixmapCount) { + if (images.size() <= pPixmapCount) { // Create BufferedImage and add buffer it for multiple reads // DirectColorModel cm = (DirectColorModel) ColorModel.getRGBdefault(); // DataBuffer db = new DataBufferInt(pixArray, pixArray.length); @@ -2077,15 +2080,15 @@ public class PICTImageReader extends ImageReaderBase { WritableRaster raster = Raster.createPackedRaster(db, pBounds.width, pBounds.height, cmpSize, null); // TODO: last param should ideally be srcRect.getLocation() BufferedImage img = new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null); - mImages.add(img); + images.add(img); } // Draw the image - BufferedImage img = mImages.get(pPixmapCount); + BufferedImage img = images.get(pPixmapCount); if (img != null) { // TODO: FixMe.. Seems impossible to create a bufferedImage with a raster not starting at 0,0 srcRect.setLocation(0, 0); // should not require this line.. - mContext.copyBits(img, srcRect, dstRect, transferMode, null); + context.copyBits(img, srcRect, dstRect, transferMode, null); } // Line break at the end @@ -2378,7 +2381,7 @@ public class PICTImageReader extends ImageReaderBase { // We add all new images to it. If we are just replaying, then // "pPixmapCount" will never be greater than the size of the vector - if (mImages.size() <= pPixmapCount) { + if (images.size() <= pPixmapCount) { // Create BufferedImage and add buffer it for multiple reads DirectColorModel cm; WritableRaster raster; @@ -2396,15 +2399,15 @@ public class PICTImageReader extends ImageReaderBase { BufferedImage img = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); - mImages.add(img); + images.add(img); } // Draw the image - BufferedImage img = mImages.get(pPixmapCount); + BufferedImage img = images.get(pPixmapCount); if (img != null) { // TODO: FixMe.. Something wrong here, might be the copyBits methods. srcRect.setLocation(0, 0); // should not require this line.. - mContext.copyBits(img, srcRect, dstRect, transferMode, null); + context.copyBits(img, srcRect, dstRect, transferMode, null); } // Line break at the end @@ -2551,7 +2554,7 @@ public class PICTImageReader extends ImageReaderBase { * image resolution ratio. */ private int getXPtCoord(int pPoint) { - return (int) (pPoint / mScreenImageXRatio); + return (int) (pPoint / screenImageXRatio); } /* @@ -2560,7 +2563,7 @@ public class PICTImageReader extends ImageReaderBase { * image resolution ratio. */ private int getYPtCoord(int pPoint) { - return (int) (pPoint / mScreenImageYRatio); + return (int) (pPoint / screenImageYRatio); } /* @@ -2621,7 +2624,7 @@ public class PICTImageReader extends ImageReaderBase { try { // TODO: Might need to clear background - g.setTransform(AffineTransform.getScaleInstance(mScreenImageXRatio / subX, mScreenImageYRatio / subY)); + g.setTransform(AffineTransform.getScaleInstance(screenImageXRatio / subX, screenImageYRatio / subY)); // try { drawOnto(g); // } diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderSpi.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderSpi.java index 7842cd5d..5f19f0ae 100755 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderSpi.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReaderSpi.java @@ -75,8 +75,8 @@ public class PICTImageReaderSpi extends ImageReaderSpi { } ImageInputStream stream = (ImageInputStream) pSource; - stream.mark(); + try { if (isPICT(stream)) { // If PICT Clipping format, return true immediately @@ -87,6 +87,7 @@ public class PICTImageReaderSpi extends ImageReaderSpi { stream.reset(); PICTImageReader.skipNullHeader(stream); } + return isPICT(stream); } catch (EOFException ignore) { diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageWriter.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageWriter.java index 84d6267c..e2a21a17 100755 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageWriter.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageWriter.java @@ -86,9 +86,9 @@ import java.io.*; public class PICTImageWriter extends ImageWriterBase { // TODO: Inline these? - private int mRowBytes; - private byte[] mScanlineBytes; - private int mScanWidthLeft; + private int rowBytes; + private byte[] scanlineBytes; + private int scanWidthLeft; public PICTImageWriter() { this(null); @@ -171,8 +171,8 @@ public class PICTImageWriter extends ImageWriterBase { // Write rowBytes, this is 4 times the width. // Set the high bit, to indicate a PixMap. - mRowBytes = 4 * pImage.getWidth(); - imageOutput.writeShort(0x8000 | mRowBytes); + rowBytes = 4 * pImage.getWidth(); + imageOutput.writeShort(0x8000 | rowBytes); // Write bounds rectangle (same as image bounds) imageOutput.writeShort(0); @@ -235,14 +235,14 @@ public class PICTImageWriter extends ImageWriterBase { // TODO: Move to writePICTData? // TODO: Alpha support // Set up the buffers for storing scanline bytes - mScanlineBytes = new byte[3 * pImage.getWidth()]; - mScanWidthLeft = pImage.getWidth(); + scanlineBytes = new byte[3 * pImage.getWidth()]; + scanWidthLeft = pImage.getWidth(); } private void writePICTData(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) throws IOException { - ByteArrayOutputStream bytes = new FastByteArrayOutputStream(mScanlineBytes.length / 2); + ByteArrayOutputStream bytes = new FastByteArrayOutputStream(scanlineBytes.length / 2); int components = model.getNumComponents(); @@ -252,36 +252,36 @@ public class PICTImageWriter extends ImageWriterBase { // lines (h > 1) and (w < width). This should never be the case. for (int i = 0; i < h; i++) { // Reduce the counter of bytes left on the scanline. - mScanWidthLeft -= w; + scanWidthLeft -= w; // Treat the scanline. for (int j = 0; j < w; j++) { if (model instanceof ComponentColorModel && model.getColorSpace().getType() == ColorSpace.TYPE_RGB) { // TODO: Component order? // TODO: Alpha support - mScanlineBytes[x + j] = pixels[off + i * scansize * components + components * j + 2]; - mScanlineBytes[x + w + j] = pixels[off + i * scansize * components + components * j + 1]; - mScanlineBytes[x + 2 * w + j] = pixels[off + i * scansize * components + components * j]; + scanlineBytes[x + j] = pixels[off + i * scansize * components + components * j + 2]; + scanlineBytes[x + w + j] = pixels[off + i * scansize * components + components * j + 1]; + scanlineBytes[x + 2 * w + j] = pixels[off + i * scansize * components + components * j]; } else { int rgb = model.getRGB(pixels[off + i * scansize + j] & 0xFF); // Set red, green and blue components. - mScanlineBytes[x + j] = (byte) ((rgb >> 16) & 0xFF); - mScanlineBytes[x + w + j] = (byte) ((rgb >> 8) & 0xFF); - mScanlineBytes[x + 2 * w + j] = (byte) (rgb & 0xFF); + scanlineBytes[x + j] = (byte) ((rgb >> 16) & 0xFF); + scanlineBytes[x + w + j] = (byte) ((rgb >> 8) & 0xFF); + scanlineBytes[x + 2 * w + j] = (byte) (rgb & 0xFF); } } // If we have a complete scanline, then pack it and write it out. - if (mScanWidthLeft == 0) { + if (scanWidthLeft == 0) { // Pack using PackBitsEncoder/EncoderStream bytes.reset(); DataOutput packBits = new DataOutputStream(new EncoderStream(bytes, new PackBitsEncoder(), true)); - packBits.write(mScanlineBytes); + packBits.write(scanlineBytes); - if (mRowBytes > 250) { + if (rowBytes > 250) { imageOutput.writeShort(bytes.size()); } else { @@ -290,7 +290,7 @@ public class PICTImageWriter extends ImageWriterBase { bytes.writeTo(IIOUtil.createStreamAdapter(imageOutput)); - mScanWidthLeft = w; + scanWidthLeft = w; } } } @@ -298,7 +298,7 @@ public class PICTImageWriter extends ImageWriterBase { private void writePICTData(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize) throws IOException { - ByteArrayOutputStream bytes = new FastByteArrayOutputStream(mScanlineBytes.length / 2); + ByteArrayOutputStream bytes = new FastByteArrayOutputStream(scanlineBytes.length / 2); // TODO: Clean up, as we only have complete scanlines @@ -306,27 +306,27 @@ public class PICTImageWriter extends ImageWriterBase { // lines (h > 1) and (w < width). This should never be the case. for (int i = 0; i < h; i++) { // Reduce the counter of bytes left on the scanline. - mScanWidthLeft -= w; + scanWidthLeft -= w; // Treat the scanline. for (int j = 0; j < w; j++) { int rgb = model.getRGB(pixels[off + i * scansize + j]); // Set red, green and blue components. - mScanlineBytes[x + j] = (byte) ((rgb >> 16) & 0xFF); - mScanlineBytes[x + w + j] = (byte) ((rgb >> 8) & 0xFF); - mScanlineBytes[x + 2 * w + j] = (byte) (rgb & 0xFF); + scanlineBytes[x + j] = (byte) ((rgb >> 16) & 0xFF); + scanlineBytes[x + w + j] = (byte) ((rgb >> 8) & 0xFF); + scanlineBytes[x + 2 * w + j] = (byte) (rgb & 0xFF); } // If we have a complete scanline, then pack it and write it out. - if (mScanWidthLeft == 0) { + if (scanWidthLeft == 0) { // Pack using PackBitsEncoder/EncoderStream bytes.reset(); DataOutput packBits = new DataOutputStream(new EncoderStream(bytes, new PackBitsEncoder(), true)); - packBits.write(mScanlineBytes); + packBits.write(scanlineBytes); - if (mRowBytes > 250) { + if (rowBytes > 250) { imageOutput.writeShort(bytes.size()); } else { @@ -335,7 +335,7 @@ public class PICTImageWriter extends ImageWriterBase { bytes.writeTo(IIOUtil.createStreamAdapter(imageOutput)); - mScanWidthLeft = w; + scanWidthLeft = w; } } } diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/Pattern.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/Pattern.java index d7d073d0..32841877 100755 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/Pattern.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/Pattern.java @@ -42,16 +42,16 @@ import java.util.Collections; * @version $Id: Pattern.java,v 1.0 Oct 9, 2007 1:21:38 AM haraldk Exp$ */ abstract class Pattern implements Paint { - private final Paint mPaint; + private final Paint paint; Pattern(final Paint pPaint) { - mPaint = pPaint; + paint = pPaint; } public PaintContext createContext(final ColorModel pModel, final Rectangle pDeviceBounds, final Rectangle2D pUserBounds, final AffineTransform pTransform, final RenderingHints pHints) { - return mPaint.createContext( + return paint.createContext( pModel, pDeviceBounds, pUserBounds, pTransform, pHints != null ? pHints : new RenderingHints(Collections.emptyMap()) @@ -59,6 +59,6 @@ abstract class Pattern implements Paint { } public int getTransparency() { - return mPaint.getTransparency(); + return paint.getTransparency(); } } diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PenState.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PenState.java index 8fd251f0..83b456d9 100755 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PenState.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PenState.java @@ -38,15 +38,15 @@ import java.awt.*; * @version $Id: PenState.java,v 1.0 Oct 9, 2007 1:56:33 AM haraldk Exp$ */ class PenState { - public final Point mPenLocation; /* pen location */ - public final Dimension mPenSize; /* pen size */ - public final int mPenMode; /* pen's pattern mode */ - public final Pattern mPenPattern; /* pen pattern */ + public final Point penLocation; /* pen location */ + public final Dimension penSize; /* pen size */ + public final int penMode; /* pen's pattern mode */ + public final Pattern penPattern; /* pen pattern */ public PenState(final Point pPenLocation, final int pPenMode, final Pattern pPenPattern, final Dimension pPenSize) { - mPenLocation = pPenLocation; - mPenMode = pPenMode; - mPenPattern = pPenPattern; - mPenSize = pPenSize; + penLocation = pPenLocation; + penMode = pPenMode; + penPattern = pPenPattern; + penSize = pPenSize; } } diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PixMapPattern.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PixMapPattern.java index 470a04a0..d2108320 100755 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PixMapPattern.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PixMapPattern.java @@ -38,17 +38,17 @@ import java.awt.*; * @version $Id: PixMapPattern.java,v 1.0 Mar 1, 2009 11:36:10 PM haraldk Exp$ */ final class PixMapPattern extends Pattern { - private final Pattern mFallback; + private final Pattern fallback; PixMapPattern(final Paint pPaint, final Pattern pBitMapFallback) { super(pPaint); - mFallback = pBitMapFallback; + fallback = pBitMapFallback; } /** * @return the fallback B/W pattern */ public Pattern getPattern() { - return mFallback; + return fallback; } } diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java index 92d504d0..e9f52f9d 100755 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java @@ -28,6 +28,8 @@ package com.twelvemonkeys.imageio.plugins.pict; +import com.twelvemonkeys.lang.Validate; + import java.awt.*; import java.awt.image.BufferedImage; import java.awt.geom.*; @@ -101,9 +103,9 @@ class QuickDrawContext { rgnSave: Handle; {region being saved, used internally} polySave: Handle; {polygon being saved, used internally} */ - private final Graphics2D mGraphics; + private final Graphics2D graphics; - private Pattern mBackground; + private Pattern background; // http://developer.apple.com/documentation/mac/quickdraw/QuickDraw-68.html#HEADING68-0 // Upon the creation of a graphics port, QuickDraw assigns these initial @@ -113,23 +115,20 @@ class QuickDrawContext { // graphics pen. // TODO: Consider creating a Pen/PenState class? - private int mPenVisibility = 0; - private Point2D mPenPosition = new Point(); - private Pattern mPenPattern; - private Dimension2D mPenSize = new Dimension(); - private int mPenMode; + private int penVisibility = 0; + private Point2D penPosition = new Point(); + private Pattern penPattern; + private Dimension2D penSize = new Dimension(); + private int penMode; QuickDrawContext(Graphics2D pGraphics) { - if (pGraphics == null) { - throw new IllegalArgumentException("graphics == null"); - } - mGraphics = pGraphics; + graphics = Validate.notNull(pGraphics, "graphics"); setPenNormal(); } protected void dispose() { - mGraphics.dispose(); + graphics.dispose(); } // ClosePicture @@ -139,7 +138,7 @@ class QuickDrawContext { // ClipRgn public void setClipRegion(Shape pClip) { - mGraphics.setClip(pClip); + graphics.setClip(pClip); } // Font number (sic), integer @@ -160,7 +159,7 @@ class QuickDrawContext { } public void setTextSize(int pSize) { - mGraphics.setFont(mGraphics.getFont().deriveFont((float) pSize)); + graphics.setFont(graphics.getFont().deriveFont((float) pSize)); } // Numerator (Point), denominator (Point) @@ -173,16 +172,16 @@ class QuickDrawContext { // TODO: chExtra added width for nonspace characters public void setOrigin(Point2D pOrigin) { - mGraphics.translate(pOrigin.getX(), pOrigin.getY()); + graphics.translate(pOrigin.getX(), pOrigin.getY()); } public void setForeground(Color pColor) { // TODO: Is this really correct? Or does it depend on pattern mode? - mPenPattern = new BitMapPattern(pColor); + penPattern = new BitMapPattern(pColor); } public void setBackground(Color pColor) { - mBackground = new BitMapPattern(pColor); + background = new BitMapPattern(pColor); } /* @@ -197,14 +196,14 @@ class QuickDrawContext { * HidePen Visibility (decrements visibility by one!) */ public void hidePen() { - mPenVisibility--; + penVisibility--; } /** * ShowPen Visibility (increments visibility by one!) */ public void showPen() { - mPenVisibility++; + penVisibility++; } /** @@ -213,7 +212,7 @@ class QuickDrawContext { * @return {@code true} if pen is visible */ private boolean isPenVisible() { - return mPenVisibility >= 0; + return penVisibility >= 0; } /** @@ -223,7 +222,7 @@ class QuickDrawContext { * @return the current pen position */ public Point2D getPenPosition() { - return (Point2D) mPenPosition.clone(); + return (Point2D) penPosition.clone(); } /** @@ -233,8 +232,8 @@ class QuickDrawContext { * @param pSize the new size */ public void setPenSize(Dimension2D pSize) { - mPenSize.setSize(pSize); - mGraphics.setStroke(getStroke(mPenSize)); + penSize.setSize(pSize); + graphics.setStroke(getStroke(penSize)); } /** @@ -274,7 +273,7 @@ class QuickDrawContext { case QuickDraw.SUB_OVER: case QuickDraw.AD_MIN: case QuickDraw.GRAYISH_TEXT_OR: - mPenMode = pPenMode; + penMode = pPenMode; break; default: @@ -288,7 +287,7 @@ class QuickDrawContext { * @param pPattern the new pattern */ public void setPenPattern(final Pattern pPattern) { - mPenPattern = pPattern; + penPattern = pPattern; } /** @@ -299,7 +298,7 @@ class QuickDrawContext { // TODO: What about visibility? Probably not touch setPenPattern(QuickDraw.BLACK); setPenSize(new Dimension(1, 1)); - mPenMode = QuickDraw.SRC_COPY; + penMode = QuickDraw.SRC_COPY; } /* @@ -308,7 +307,7 @@ class QuickDrawContext { *BackPixPat */ public void setBackgroundPattern(Pattern pPaint) { - mBackground = pPaint; + background = pPaint; } private Composite getCompositeFor(final int pMode) { @@ -354,9 +353,9 @@ class QuickDrawContext { * Sets up context for line drawing/painting. */ protected void setupForPaint() { - mGraphics.setPaint(mPenPattern); - mGraphics.setComposite(getCompositeFor(mPenMode)); - //mGraphics.setStroke(getStroke(mPenSize)); + graphics.setPaint(penPattern); + graphics.setComposite(getCompositeFor(penMode)); + //graphics.setStroke(getStroke(penSize)); } private Stroke getStroke(final Dimension2D pPenSize) { @@ -373,19 +372,19 @@ class QuickDrawContext { * @param pPattern the pattern to use for filling. */ protected void setupForFill(final Pattern pPattern) { - mGraphics.setPaint(pPattern); - mGraphics.setComposite(getCompositeFor(QuickDraw.PAT_COPY)); + graphics.setPaint(pPattern); + graphics.setComposite(getCompositeFor(QuickDraw.PAT_COPY)); } protected void setupForErase() { - mGraphics.setPaint(mBackground); - mGraphics.setComposite(getCompositeFor(QuickDraw.PAT_COPY)); // TODO: Check spec + graphics.setPaint(background); + graphics.setComposite(getCompositeFor(QuickDraw.PAT_COPY)); // TODO: Check spec } protected void setupForInvert() { // TODO: Setup for invert - mGraphics.setColor(Color.BLACK); - mGraphics.setXORMode(Color.WHITE); + graphics.setColor(Color.BLACK); + graphics.setXORMode(Color.WHITE); } /* @@ -398,7 +397,7 @@ class QuickDrawContext { */ public void moveTo(final double pX, final double pY) { - mPenPosition.setLocation(pX, pY); + penPosition.setLocation(pX, pY); } public final void moveTo(final Point2D pPosition) { @@ -406,18 +405,18 @@ class QuickDrawContext { } public final void move(final double pDeltaX, final double pDeltaY) { - moveTo(mPenPosition.getX() + pDeltaX, mPenPosition.getY() + pDeltaY); + moveTo(penPosition.getX() + pDeltaX, penPosition.getY() + pDeltaY); } public void lineTo(final double pX, final double pY) { - Shape line = new Line2D.Double(mPenPosition.getX(), mPenPosition.getY(), pX, pY); + Shape line = new Line2D.Double(penPosition.getX(), penPosition.getY(), pX, pY); // TODO: Add line to current shape if recording... if (isPenVisible()) { // NOTE: Workaround for known Mac JDK bug: Paint, not frame - //mGraphics.setStroke(getStroke(mPenSize)); // Make sure we have correct stroke - paintShape(mGraphics.getStroke().createStrokedShape(line)); + //graphics.setStroke(getStroke(penSize)); // Make sure we have correct stroke + paintShape(graphics.getStroke().createStrokedShape(line)); } @@ -429,7 +428,7 @@ class QuickDrawContext { } public final void line(final double pDeltaX, final double pDeltaY) { - lineTo(mPenPosition.getX() + pDeltaX, mPenPosition.getY() + pDeltaY); + lineTo(penPosition.getX() + pDeltaX, penPosition.getY() + pDeltaY); } /* @@ -813,27 +812,27 @@ class QuickDrawContext { // TODO: All other operations can delegate to these! :-) private void frameShape(final Shape pShape) { setupForPaint(); - mGraphics.draw(pShape); + graphics.draw(pShape); } private void paintShape(final Shape pShape) { setupForPaint(); - mGraphics.fill(pShape); + graphics.fill(pShape); } private void fillShape(final Shape pShape, final Pattern pPattern) { setupForFill(pPattern); - mGraphics.fill(pShape); + graphics.fill(pShape); } private void invertShape(final Shape pShape) { setupForInvert(); - mGraphics.fill(pShape); + graphics.fill(pShape); } private void eraseShape(final Shape pShape) { setupForErase(); - mGraphics.fill(pShape); + graphics.fill(pShape); } /* @@ -862,12 +861,12 @@ class QuickDrawContext { * @param pMaskRgn the mask region */ public void copyBits(BufferedImage pSrcBitmap, Rectangle pSrcRect, Rectangle pDstRect, int pMode, Shape pMaskRgn) { - mGraphics.setComposite(getCompositeFor(pMode)); + graphics.setComposite(getCompositeFor(pMode)); if (pMaskRgn != null) { setClipRegion(pMaskRgn); } - mGraphics.drawImage( + graphics.drawImage( pSrcBitmap, pDstRect.x, pDstRect.y, @@ -927,7 +926,7 @@ class QuickDrawContext { * @param pString a Pascal string (a string of length less than or equal to 255 chars). */ public void drawString(String pString) { - mGraphics.drawString(pString, (float) getPenPosition().getX(), (float) getPenPosition().getY()); + graphics.drawString(pString, (float) getPenPosition().getX(), (float) getPenPosition().getY()); } /* @@ -953,14 +952,14 @@ class QuickDrawContext { // Color Constants -ÝwhiteColor =Ý30; -ÝblackColor = 33 -ÝyellowColor = 69; - magentaColor =Ý137; -ÝredColor =Ý205; -ÝcyanColor =Ý273; -ÝgreenColor =Ý341; -ÝblueColor =Ý409; +�whiteColor =�30; +�blackColor = 33 +�yellowColor = 69; + magentaColor =�137; +�redColor =�205; +�cyanColor =�273; +�greenColor =�341; +�blueColor =�409; */ // TODO: Simplify! Extract to upper level class diff --git a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/TestPICTClippingApp.java b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/TestPICTClippingApp.java index 42197511..3a521c6c 100644 --- a/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/TestPICTClippingApp.java +++ b/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/TestPICTClippingApp.java @@ -62,12 +62,12 @@ public class TestPICTClippingApp { } private static class ImageDropHandler extends TransferHandler { - private final JLabel mLabel; - private final ExecutorService mExecutor = Executors.newSingleThreadExecutor(); + private final JLabel label; + private final ExecutorService executor = Executors.newSingleThreadExecutor(); public ImageDropHandler(JLabel pLabel) { super(null); - mLabel = pLabel; + label = pLabel; } private DataFlavor getSupportedFlavor(final DataFlavor[] transferFlavors) { @@ -126,7 +126,7 @@ public class TestPICTClippingApp { if (readers.hasNext()) { final ImageReader imageReader = readers.next(); - mExecutor.execute(new Runnable() { + executor.execute(new Runnable() { public void run() { try { readAndInstallImage(stream, imageReader); @@ -186,7 +186,7 @@ public class TestPICTClippingApp { System.out.print("Scaling image... "); BufferedImage scaled = box(image, maxDimension); System.out.printf("Done (%dx%d).%n", scaled.getWidth(), scaled.getHeight()); - mLabel.setIcon(new BufferedImageIcon(scaled)); + label.setIcon(new BufferedImageIcon(scaled)); } }); } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/ICCProfile.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/ICCProfile.java index 88474984..81876f25 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/ICCProfile.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/ICCProfile.java @@ -43,7 +43,7 @@ import java.io.InputStream; * @version $Id: ICCProfile.java,v 1.0 May 20, 2008 6:24:10 PM haraldk Exp$ */ class ICCProfile extends PSDImageResource { - private ICC_Profile mProfile; + private ICC_Profile profile; ICCProfile(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -51,9 +51,9 @@ class ICCProfile extends PSDImageResource { @Override protected void readData(ImageInputStream pInput) throws IOException { - InputStream stream = IIOUtil.createStreamAdapter(pInput, mSize); + InputStream stream = IIOUtil.createStreamAdapter(pInput, size); try { - mProfile = ICC_Profile.getInstance(stream); + profile = ICC_Profile.getInstance(stream); } finally { // Make sure stream has correct position after read @@ -62,14 +62,14 @@ class ICCProfile extends PSDImageResource { } public ICC_Profile getProfile() { - return mProfile; + return profile; } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", profile: ").append(mProfile); + builder.append(", profile: ").append(profile); builder.append("]"); return builder.toString(); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDAlphaChannelInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDAlphaChannelInfo.java index 9918f429..64067411 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDAlphaChannelInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDAlphaChannelInfo.java @@ -41,7 +41,7 @@ import java.util.List; * @version $Id: PSDAlphaChannelInfo.java,v 1.0 May 2, 2008 5:33:40 PM haraldk Exp$ */ class PSDAlphaChannelInfo extends PSDImageResource { - List mNames; + List names; public PSDAlphaChannelInfo(short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -49,12 +49,12 @@ class PSDAlphaChannelInfo extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mNames = new ArrayList(); + names = new ArrayList(); - long left = mSize; + long left = size; while (left > 0) { String name = PSDUtil.readPascalString(pInput); - mNames.add(name); + names.add(name); left -= name.length() + 1; } } @@ -62,7 +62,7 @@ class PSDAlphaChannelInfo extends PSDImageResource { @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", alpha channels: ").append(mNames).append("]"); + builder.append(", alpha channels: ").append(names).append("]"); return builder.toString(); } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelInfo.java index 76beec91..603c3cf5 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelInfo.java @@ -36,8 +36,8 @@ package com.twelvemonkeys.imageio.plugins.psd; * @version $Id: PSDChannelInfo.java,v 1.0 May 6, 2008 2:46:23 PM haraldk Exp$ */ class PSDChannelInfo { - final short mChannelId; - final long mLength; + final short channelId; + final long length; // typedef struct _CLI // { @@ -45,16 +45,16 @@ class PSDChannelInfo { // LONG LengthOfChannelData; /* Channel Length Info field two */ // } CLI; public PSDChannelInfo(short pChannelId, long pLength) { - mChannelId = pChannelId; - mLength = pLength; + channelId = pChannelId; + length = pLength; } @Override public String toString() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); builder.append("["); - builder.append("channelId: ").append(mChannelId); - builder.append(", length: ").append(mLength); + builder.append("channelId: ").append(channelId); + builder.append(", length: ").append(length); builder.append("]"); return builder.toString(); } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelSourceDestinationRange.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelSourceDestinationRange.java index 65735285..b58574ac 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelSourceDestinationRange.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDChannelSourceDestinationRange.java @@ -39,29 +39,29 @@ import java.io.IOException; * @version $Id: PSDChannelSourceDestinationRange.java,v 1.0 May 6, 2008 5:14:13 PM haraldk Exp$ */ class PSDChannelSourceDestinationRange { - private String mChannel; - private short mSourceBlack; - private short mSourceWhite; - private short mDestBlack; - private short mDestWhite; + private String channel; + private short sourceBlack; + private short sourceWhite; + private short destBlack; + private short destWhite; public PSDChannelSourceDestinationRange(ImageInputStream pInput, String pChannel) throws IOException { - mChannel = pChannel; - mSourceBlack = pInput.readShort(); - mSourceWhite = pInput.readShort(); - mDestBlack = pInput.readShort(); - mDestWhite = pInput.readShort(); + channel = pChannel; + sourceBlack = pInput.readShort(); + sourceWhite = pInput.readShort(); + destBlack = pInput.readShort(); + destWhite = pInput.readShort(); } @Override public String toString() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); - builder.append("[(").append(mChannel); - builder.append("): sourceBlack: ").append(Integer.toHexString(mSourceBlack & 0xffff)); - builder.append(", sourceWhite: ").append(Integer.toHexString(mSourceWhite & 0xffff)); - builder.append(", destBlack: ").append(Integer.toHexString(mDestBlack & 0xffff)); - builder.append(", destWhite: ").append(Integer.toHexString(mDestWhite & 0xffff)); + builder.append("[(").append(channel); + builder.append("): sourceBlack: ").append(Integer.toHexString(sourceBlack & 0xffff)); + builder.append(", sourceWhite: ").append(Integer.toHexString(sourceWhite & 0xffff)); + builder.append(", destBlack: ").append(Integer.toHexString(destBlack & 0xffff)); + builder.append(", destWhite: ").append(Integer.toHexString(destWhite & 0xffff)); builder.append("]"); return builder.toString(); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDColorData.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDColorData.java index d8e67cde..3b120af8 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDColorData.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDColorData.java @@ -44,8 +44,8 @@ import java.io.IOException; * @version $Id: PSDColorData.java,v 1.0 Apr 29, 2008 5:33:01 PM haraldk Exp$ */ class PSDColorData { - final byte[] mColors; - private IndexColorModel mColorModel; + final byte[] colors; + private IndexColorModel colorModel; PSDColorData(final ImageInputStream pInput) throws IOException { int length = pInput.readInt(); @@ -57,19 +57,19 @@ class PSDColorData { } // NOTE: Spec says length may only be 768 bytes (256 RGB triplets) - mColors = new byte[length]; - pInput.readFully(mColors); + colors = new byte[length]; + pInput.readFully(colors); // NOTE: Could be a padding byte here, if not even.. } IndexColorModel getIndexColorModel() { - if (mColorModel == null) { - int[] rgb = toInterleavedRGB(mColors); - mColorModel = new InverseColorMapIndexColorModel(8, rgb.length, rgb, 0, false, -1, DataBuffer.TYPE_BYTE); + if (colorModel == null) { + int[] rgb = toInterleavedRGB(colors); + colorModel = new InverseColorMapIndexColorModel(8, rgb.length, rgb, 0, false, -1, DataBuffer.TYPE_BYTE); } - return mColorModel; + return colorModel; } private static int[] toInterleavedRGB(final byte[] pColors) { diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDDisplayInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDDisplayInfo.java index f74e5a7b..037f2a9a 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDDisplayInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDDisplayInfo.java @@ -65,10 +65,10 @@ class PSDDisplayInfo extends PSDImageResource { // BYTE Padding; /* Always zero */ //} DISPLAYINFO; - int mColorSpace; - short[] mColors; - short mOpacity; - byte mKind; + int colorSpace; + short[] colors; + short opacity; + byte kind; PSDDisplayInfo(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -76,46 +76,46 @@ class PSDDisplayInfo extends PSDImageResource { @Override protected void readData(ImageInputStream pInput) throws IOException { - if (mSize % 14 != 0) { - throw new IIOException("Display info length expected to be mod 14: " + mSize); + if (size % 14 != 0) { + throw new IIOException("Display info length expected to be mod 14: " + size); } -// long left = mSize; +// long left = size; // while (left > 0) { - mColorSpace = pInput.readShort(); + colorSpace = pInput.readShort(); // Color[4]...? - mColors = new short[4]; - mColors[0] = pInput.readShort(); - mColors[1] = pInput.readShort(); - mColors[2] = pInput.readShort(); - mColors[3] = pInput.readShort(); + colors = new short[4]; + colors[0] = pInput.readShort(); + colors[1] = pInput.readShort(); + colors[2] = pInput.readShort(); + colors[3] = pInput.readShort(); - mOpacity = pInput.readShort(); + opacity = pInput.readShort(); - mKind = pInput.readByte(); + kind = pInput.readByte(); pInput.readByte(); // Pad // left -= 14; // } - pInput.skipBytes(mSize - 14); + pInput.skipBytes(size - 14); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", ColorSpace: ").append(mColorSpace); + builder.append(", ColorSpace: ").append(colorSpace); builder.append(", Colors: {"); - builder.append(mColors[0]); + builder.append(colors[0]); builder.append(", "); - builder.append(mColors[1]); + builder.append(colors[1]); builder.append(", "); - builder.append(mColors[2]); + builder.append(colors[2]); builder.append(", "); - builder.append(mColors[3]); - builder.append("}, Opacity: ").append(mOpacity); - builder.append(", Kind: ").append(kind(mKind)); + builder.append(colors[3]); + builder.append("}, Opacity: ").append(opacity); + builder.append(", Kind: ").append(kind(kind)); builder.append("]"); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDEXIF1Data.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDEXIF1Data.java index 877bc34d..f765c22e 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDEXIF1Data.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDEXIF1Data.java @@ -18,7 +18,7 @@ import java.io.IOException; * @see Adobe TIFF developer resources */ final class PSDEXIF1Data extends PSDImageResource { - protected Directory mDirectory; + protected Directory directory; PSDEXIF1Data(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -28,13 +28,13 @@ final class PSDEXIF1Data extends PSDImageResource { protected void readData(final ImageInputStream pInput) throws IOException { // This is in essence an embedded TIFF file. // TODO: Instead, read the byte data, store for later parsing (or better yet, store offset, and read on request) - mDirectory = new EXIFReader().read(pInput); + directory = new EXIFReader().read(pInput); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", ").append(mDirectory); + builder.append(", ").append(directory); builder.append("]"); return builder.toString(); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGlobalLayerMask.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGlobalLayerMask.java index 4f336eb1..0c75b981 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGlobalLayerMask.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGlobalLayerMask.java @@ -39,25 +39,25 @@ import java.io.IOException; * @version $Id: PSDGlobalLayerMask.java,v 1.0 May 8, 2008 5:33:48 PM haraldk Exp$ */ class PSDGlobalLayerMask { - final int mColorSpace; - final int mColor1; - final int mColor2; - final int mColor3; - final int mColor4; - final int mOpacity; - final int mKind; + final int colorSpace; + final int color1; + final int color2; + final int color3; + final int color4; + final int opacity; + final int kind; PSDGlobalLayerMask(final ImageInputStream pInput) throws IOException { - mColorSpace = pInput.readUnsignedShort(); // Undocumented + colorSpace = pInput.readUnsignedShort(); // Undocumented - mColor1 = pInput.readUnsignedShort(); - mColor2 = pInput.readUnsignedShort(); - mColor3 = pInput.readUnsignedShort(); - mColor4 = pInput.readUnsignedShort(); + color1 = pInput.readUnsignedShort(); + color2 = pInput.readUnsignedShort(); + color3 = pInput.readUnsignedShort(); + color4 = pInput.readUnsignedShort(); - mOpacity = pInput.readUnsignedShort(); // 0-100 + opacity = pInput.readUnsignedShort(); // 0-100 - mKind = pInput.readUnsignedByte(); // 0: Selected (ie inverted), 1: Color protected, 128: Use value stored per layer + kind = pInput.readUnsignedByte(); // 0: Selected (ie inverted), 1: Color protected, 128: Use value stored per layer // TODO: Variable: Filler zeros @@ -68,13 +68,13 @@ class PSDGlobalLayerMask { public String toString() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); builder.append("["); - builder.append("color space: 0x").append(Integer.toHexString(mColorSpace)); - builder.append(", colors: [0x").append(Integer.toHexString(mColor1)); - builder.append(", 0x").append(Integer.toHexString(mColor2)); - builder.append(", 0x").append(Integer.toHexString(mColor3)); - builder.append(", 0x").append(Integer.toHexString(mColor4)); - builder.append("], opacity: ").append(mOpacity); - builder.append(", kind: ").append(mKind); + builder.append("color space: 0x").append(Integer.toHexString(colorSpace)); + builder.append(", colors: [0x").append(Integer.toHexString(color1)); + builder.append(", 0x").append(Integer.toHexString(color2)); + builder.append(", 0x").append(Integer.toHexString(color3)); + builder.append(", 0x").append(Integer.toHexString(color4)); + builder.append("], opacity: ").append(opacity); + builder.append(", kind: ").append(kind); builder.append("]"); return builder.toString(); } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGridAndGuideInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGridAndGuideInfo.java index 2b4e0b14..1248f7af 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGridAndGuideInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDGridAndGuideInfo.java @@ -25,12 +25,12 @@ final class PSDGridAndGuideInfo extends PSDImageResource { // gchar fDirection; /* Guide orientation */ //} GuideResource; - int mVersion; - int mGridCycleVertical; - int mGridCycleHorizontal; - int mGuideCount; + int version; + int gridCycleVertical; + int gridCycleHorizontal; + int guideCount; - GuideResource[] mGuides; + GuideResource[] guides; PSDGridAndGuideInfo(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -38,21 +38,21 @@ final class PSDGridAndGuideInfo extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mVersion = pInput.readInt(); - mGridCycleVertical = pInput.readInt(); - mGridCycleHorizontal = pInput.readInt(); - mGuideCount = pInput.readInt(); + version = pInput.readInt(); + gridCycleVertical = pInput.readInt(); + gridCycleHorizontal = pInput.readInt(); + guideCount = pInput.readInt(); - mGuides = new GuideResource[mGuideCount]; + guides = new GuideResource[guideCount]; - for (GuideResource guide : mGuides) { - guide.mLocation = pInput.readInt(); - guide.mDirection = pInput.readByte(); + for (GuideResource guide : guides) { + guide.location = pInput.readInt(); + guide.direction = pInput.readByte(); } } static class GuideResource { - int mLocation; - byte mDirection; // 0: vertical, 1: horizontal + int location; + byte direction; // 0: vertical, 1: horizontal } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDHeader.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDHeader.java index 77e6659a..b12e594a 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDHeader.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDHeader.java @@ -28,9 +28,6 @@ package com.twelvemonkeys.imageio.plugins.psd; -import org.w3c.dom.Node; - -import javax.imageio.metadata.IIOMetadataNode; import javax.imageio.stream.ImageInputStream; import javax.imageio.IIOException; import java.io.IOException; @@ -58,11 +55,11 @@ class PSDHeader { // WORD Mode; /* Color mode */ // } PSD_HEADER; - final short mChannels; - final int mWidth; - final int mHeight; - final short mBits; - final short mMode; + final short channels; + final int width; + final int height; + final short bits; + final short mode; PSDHeader(final ImageInputStream pInput) throws IOException { int signature = pInput.readInt(); @@ -84,27 +81,27 @@ class PSDHeader { byte[] reserved = new byte[6]; pInput.readFully(reserved); - mChannels = pInput.readShort(); - mHeight = pInput.readInt(); // Rows - mWidth = pInput.readInt(); // Columns - mBits = pInput.readShort(); - mMode = pInput.readShort(); + channels = pInput.readShort(); + height = pInput.readInt(); // Rows + width = pInput.readInt(); // Columns + bits = pInput.readShort(); + mode = pInput.readShort(); } @Override public String toString() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); builder.append("[Channels: "); - builder.append(mChannels); + builder.append(channels); builder.append(", width: "); - builder.append(mWidth); + builder.append(width); builder.append(", height: "); - builder.append(mHeight); + builder.append(height); builder.append(", depth: "); - builder.append(mBits); + builder.append(bits); builder.append(", mode: "); - builder.append(mMode); - switch (mMode) { + builder.append(mode); + switch (mode) { case PSD.COLOR_MODE_MONOCHROME: builder.append(" (Monochrome)"); break; diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDIPTCData.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDIPTCData.java index 59a076e9..066d04cf 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDIPTCData.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDIPTCData.java @@ -14,7 +14,7 @@ import java.io.IOException; * @version $Id: PSDIPTCData.java,v 1.0 Nov 7, 2009 9:52:14 PM haraldk Exp$ */ final class PSDIPTCData extends PSDImageResource { - Directory mDirectory; + Directory directory; PSDIPTCData(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -23,13 +23,13 @@ final class PSDIPTCData extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { // Read IPTC directory - mDirectory = new IPTCReader().read(pInput); + directory = new IPTCReader().read(pInput); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", ").append(mDirectory); + builder.append(", ").append(directory); builder.append("]"); return builder.toString(); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java index 81c41483..22e531d1 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageReader.java @@ -72,36 +72,30 @@ import java.util.List; // See http://www.codeproject.com/KB/graphics/PSDParser.aspx // See http://www.adobeforums.com/webx?14@@.3bc381dc/0 public class PSDImageReader extends ImageReaderBase { - private PSDHeader mHeader; -// private PSDColorData mColorData; -// private List mImageResources; -// private PSDGlobalLayerMask mGlobalLayerMask; -// private List mLayerInfo; - private ICC_ColorSpace mColorSpace; - protected PSDMetadata mMetadata; + private PSDHeader header; + private ICC_ColorSpace colorSpace; + protected PSDMetadata metadata; protected PSDImageReader(final ImageReaderSpi pOriginatingProvider) { super(pOriginatingProvider); } protected void resetMembers() { - mHeader = null; -// mColorData = null; -// mImageResources = null; - mMetadata = null; - mColorSpace = null; + header = null; + metadata = null; + colorSpace = null; } public int getWidth(final int pIndex) throws IOException { checkBounds(pIndex); readHeader(); - return mHeader.mWidth; + return header.width; } public int getHeight(final int pIndex) throws IOException { checkBounds(pIndex); readHeader(); - return mHeader.mHeight; + return header.height; } @Override @@ -115,39 +109,39 @@ public class PSDImageReader extends ImageReaderBase { ColorSpace cs; - switch (mHeader.mMode) { + switch (header.mode) { case PSD.COLOR_MODE_MONOCHROME: - if (mHeader.mChannels == 1 && mHeader.mBits == 1) { + if (header.channels == 1 && header.bits == 1) { return ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_BYTE_BINARY); } throw new IIOException( - String.format("Unsupported channel count/bit depth for Monochrome PSD: %d channels/%d bits", mHeader.mChannels, mHeader.mBits) + String.format("Unsupported channel count/bit depth for Monochrome PSD: %d channels/%d bits", header.channels, header.bits) ); case PSD.COLOR_MODE_INDEXED: // TODO: 16 bit indexed?! Does it exist? - if (mHeader.mChannels == 1 && mHeader.mBits == 8) { - return IndexedImageTypeSpecifier.createFromIndexColorModel(mMetadata.mColorData.getIndexColorModel()); + if (header.channels == 1 && header.bits == 8) { + return IndexedImageTypeSpecifier.createFromIndexColorModel(metadata.colorData.getIndexColorModel()); } throw new IIOException( - String.format("Unsupported channel count/bit depth for Indexed Color PSD: %d channels/%d bits", mHeader.mChannels, mHeader.mBits) + String.format("Unsupported channel count/bit depth for Indexed Color PSD: %d channels/%d bits", header.channels, header.bits) ); case PSD.COLOR_MODE_DUOTONE: // NOTE: Duotone (whatever that is) should be treated as gray scale // Fall-through case PSD.COLOR_MODE_GRAYSCALE: - if (mHeader.mChannels == 1 && mHeader.mBits == 8) { + if (header.channels == 1 && header.bits == 8) { return ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_BYTE_GRAY); } - else if (mHeader.mChannels == 1 && mHeader.mBits == 16) { + else if (header.channels == 1 && header.bits == 16) { return ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_USHORT_GRAY); } throw new IIOException( - String.format("Unsupported channel count/bit depth for Gray Scale PSD: %d channels/%d bits", mHeader.mChannels, mHeader.mBits) + String.format("Unsupported channel count/bit depth for Gray Scale PSD: %d channels/%d bits", header.channels, header.bits) ); case PSD.COLOR_MODE_RGB: @@ -157,21 +151,21 @@ public class PSDImageReader extends ImageReaderBase { cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); } - if (mHeader.mChannels == 3 && mHeader.mBits == 8) { + if (header.channels == 3 && header.bits == 8) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2}, new int[] {0, 0, 0}, DataBuffer.TYPE_BYTE, false, false); } - else if (mHeader.mChannels >= 4 && mHeader.mBits == 8) { + else if (header.channels >= 4 && header.bits == 8) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2, 3}, new int[] {0, 0, 0, 0}, DataBuffer.TYPE_BYTE, true, false); } - else if (mHeader.mChannels == 3 && mHeader.mBits == 16) { + else if (header.channels == 3 && header.bits == 16) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2}, new int[] {0, 0, 0}, DataBuffer.TYPE_USHORT, false, false); } - else if (mHeader.mChannels >= 4 && mHeader.mBits == 16) { + else if (header.channels >= 4 && header.bits == 16) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2, 3}, new int[] {0, 0, 0, 0}, DataBuffer.TYPE_USHORT, true, false); } throw new IIOException( - String.format("Unsupported channel count/bit depth for RGB PSD: %d channels/%d bits", mHeader.mChannels, mHeader.mBits) + String.format("Unsupported channel count/bit depth for RGB PSD: %d channels/%d bits", header.channels, header.bits) ); case PSD.COLOR_MODE_CMYK: @@ -180,21 +174,21 @@ public class PSDImageReader extends ImageReaderBase { cs = ColorSpaces.getColorSpace(ColorSpaces.CS_GENERIC_CMYK); } - if (mHeader.mChannels == 4 && mHeader.mBits == 8) { + if (header.channels == 4 && header.bits == 8) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2, 3}, new int[] {0, 0, 0, 0}, DataBuffer.TYPE_BYTE, false, false); } - else if (mHeader.mChannels == 5 && mHeader.mBits == 8) { + else if (header.channels == 5 && header.bits == 8) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2, 3, 4}, new int[] {0, 0, 0, 0, 0}, DataBuffer.TYPE_BYTE, true, false); } - else if (mHeader.mChannels == 4 && mHeader.mBits == 16) { + else if (header.channels == 4 && header.bits == 16) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2, 3}, new int[] {0, 0, 0, 0}, DataBuffer.TYPE_USHORT, false, false); } - else if (mHeader.mChannels == 5 && mHeader.mBits == 16) { + else if (header.channels == 5 && header.bits == 16) { return ImageTypeSpecifier.createBanded(cs, new int[] {0, 1, 2, 3, 4}, new int[] {0, 0, 0, 0, 0}, DataBuffer.TYPE_USHORT, true, false); } throw new IIOException( - String.format("Unsupported channel count/bit depth for CMYK PSD: %d channels/%d bits", mHeader.mChannels, mHeader.mBits) + String.format("Unsupported channel count/bit depth for CMYK PSD: %d channels/%d bits", header.channels, header.bits) ); case PSD.COLOR_MODE_MULTICHANNEL: @@ -204,7 +198,7 @@ public class PSDImageReader extends ImageReaderBase { // TODO: If there's a color profile embedded, it should be easy, otherwise we're out of luck... default: throw new IIOException( - String.format("Unsupported PSD MODE: %s (%d channels/%d bits)", mHeader.mMode, mHeader.mChannels, mHeader.mBits) + String.format("Unsupported PSD MODE: %s (%d channels/%d bits)", header.mode, header.channels, header.bits) ); } } @@ -219,10 +213,10 @@ public class PSDImageReader extends ImageReaderBase { ColorSpace cs = rawType.getColorModel().getColorSpace(); List types = new ArrayList(); - switch (mHeader.mMode) { + switch (header.mode) { case PSD.COLOR_MODE_RGB: // Prefer interleaved versions as they are much faster to display - if (mHeader.mChannels == 3 && mHeader.mBits == 8) { + if (header.channels == 3 && header.bits == 8) { // TODO: ColorConvertOp to CS_sRGB // TODO: Integer raster // types.add(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.INT_RGB)); @@ -233,7 +227,7 @@ public class PSDImageReader extends ImageReaderBase { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {2, 1, 0}, DataBuffer.TYPE_BYTE, false, false)); } } - else if (mHeader.mChannels >= 4 && mHeader.mBits == 8) { + else if (header.channels >= 4 && header.bits == 8) { // TODO: ColorConvertOp to CS_sRGB // TODO: Integer raster // types.add(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.INT_ARGB)); @@ -244,10 +238,10 @@ public class PSDImageReader extends ImageReaderBase { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {3, 2, 1, 0}, DataBuffer.TYPE_BYTE, true, false)); } } - else if (mHeader.mChannels == 3 && mHeader.mBits == 16) { + else if (header.channels == 3 && header.bits == 16) { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {2, 1, 0}, DataBuffer.TYPE_USHORT, false, false)); } - else if (mHeader.mChannels >= 4 && mHeader.mBits == 16) { + else if (header.channels >= 4 && header.bits == 16) { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {3, 2, 1, 0}, DataBuffer.TYPE_USHORT, true, false)); } break; @@ -258,16 +252,16 @@ public class PSDImageReader extends ImageReaderBase { // as Java2D is extremely slow displaying custom images. // Converting to RGB is also correct behaviour, according to the docs. // Doing this, will require rewriting the image reading, as the raw image data is channelled, not interleaved :-/ - if (mHeader.mChannels == 4 && mHeader.mBits == 8) { + if (header.channels == 4 && header.bits == 8) { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {3, 2, 1, 0}, DataBuffer.TYPE_BYTE, false, false)); } - else if (mHeader.mChannels == 5 && mHeader.mBits == 8) { + else if (header.channels == 5 && header.bits == 8) { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {4, 3, 2, 1, 0}, DataBuffer.TYPE_BYTE, true, false)); } - else if (mHeader.mChannels == 4 && mHeader.mBits == 16) { + else if (header.channels == 4 && header.bits == 16) { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[]{3, 2, 1, 0}, DataBuffer.TYPE_USHORT, false, false)); } - else if (mHeader.mChannels == 5 && mHeader.mBits == 16) { + else if (header.channels == 5 && header.bits == 16) { types.add(ImageTypeSpecifier.createInterleaved(cs, new int[] {4, 3, 2, 1, 0}, DataBuffer.TYPE_USHORT, true, false)); } break; @@ -286,19 +280,19 @@ public class PSDImageReader extends ImageReaderBase { // TODO: Skip this, requires storing some stream offsets readLayerAndMaskInfo(false); - if (mColorSpace == null) { + if (colorSpace == null) { ICC_Profile profile = null; - for (PSDImageResource resource : mMetadata.mImageResources) { + for (PSDImageResource resource : metadata.imageResources) { if (resource instanceof ICCProfile) { profile = ((ICCProfile) resource).getProfile(); break; } } - mColorSpace = profile == null ? null : ColorSpaces.createColorSpace(profile); + colorSpace = profile == null ? null : ColorSpaces.createColorSpace(profile); } - return mColorSpace; + return colorSpace; } public BufferedImage read(final int pIndex, final ImageReadParam pParam) throws IOException { @@ -309,13 +303,13 @@ public class PSDImageReader extends ImageReaderBase { readImageResources(false); readLayerAndMaskInfo(false); - BufferedImage image = getDestination(pParam, getImageTypes(pIndex), mHeader.mWidth, mHeader.mHeight); + BufferedImage image = getDestination(pParam, getImageTypes(pIndex), header.width, header.height); ImageTypeSpecifier rawType = getRawImageType(pIndex); checkReadParamBandSettings(pParam, rawType.getNumBands(), image.getSampleModel().getNumBands()); final Rectangle source = new Rectangle(); final Rectangle dest = new Rectangle(); - computeRegions(pParam, mHeader.mWidth, mHeader.mHeight, image, source, dest); + computeRegions(pParam, header.width, header.height, image, source, dest); /* NOTE: It seems safe to just leave this out for now. The only thing we need is to support sub sampling. @@ -360,14 +354,14 @@ public class PSDImageReader extends ImageReaderBase { int[] byteCounts = null; int compression = imageInput.readShort(); // TODO: Need to make sure compression is set in metadata, even without reading the image data! - mMetadata.mCompression = compression; + metadata.compression = compression; switch (compression) { case PSD.COMPRESSION_NONE: break; case PSD.COMPRESSION_RLE: // NOTE: Byte counts will allow us to easily skip rows before AOI - byteCounts = new int[mHeader.mChannels * mHeader.mHeight]; + byteCounts = new int[header.channels * header.height]; for (int i = 0; i < byteCounts.length; i++) { byteCounts[i] = imageInput.readUnsignedShort(); } @@ -410,7 +404,7 @@ public class PSDImageReader extends ImageReaderBase { final ColorModel destCM = pImage.getColorModel(); // TODO: This raster is 3-5 times longer than needed, depending on number of channels... - final WritableRaster rowRaster = pSourceCM.createCompatibleWritableRaster(mHeader.mWidth, 1); + final WritableRaster rowRaster = pSourceCM.createCompatibleWritableRaster(header.width, 1); final int channels = rowRaster.getNumBands(); final boolean banded = raster.getDataBuffer().getNumBanks() > 1; @@ -419,21 +413,21 @@ public class PSDImageReader extends ImageReaderBase { for (int c = 0; c < channels; c++) { int bandOffset = banded ? 0 : interleavedBands - 1 - c; - switch (mHeader.mBits) { + switch (header.bits) { case 1: byte[] row1 = ((DataBufferByte) rowRaster.getDataBuffer()).getData(); - read1bitChannel(c, mHeader.mChannels, raster.getDataBuffer(), interleavedBands, bandOffset, pSourceCM, row1, pSource, pDest, pXSub, pYSub, mHeader.mWidth, mHeader.mHeight, pByteCounts, pCompression == PSD.COMPRESSION_RLE); + read1bitChannel(c, header.channels, raster.getDataBuffer(), interleavedBands, bandOffset, pSourceCM, row1, pSource, pDest, pXSub, pYSub, header.width, header.height, pByteCounts, pCompression == PSD.COMPRESSION_RLE); break; case 8: byte[] row8 = ((DataBufferByte) rowRaster.getDataBuffer()).getData(); - read8bitChannel(c, mHeader.mChannels, raster.getDataBuffer(), interleavedBands, bandOffset, pSourceCM, row8, pSource, pDest, pXSub, pYSub, mHeader.mWidth, mHeader.mHeight, pByteCounts, c * mHeader.mHeight, pCompression == PSD.COMPRESSION_RLE); + read8bitChannel(c, header.channels, raster.getDataBuffer(), interleavedBands, bandOffset, pSourceCM, row8, pSource, pDest, pXSub, pYSub, header.width, header.height, pByteCounts, c * header.height, pCompression == PSD.COMPRESSION_RLE); break; case 16: short[] row16 = ((DataBufferUShort) rowRaster.getDataBuffer()).getData(); - read16bitChannel(c, mHeader.mChannels, raster.getDataBuffer(), interleavedBands, bandOffset, pSourceCM, row16, pSource, pDest, pXSub, pYSub, mHeader.mWidth, mHeader.mHeight, pByteCounts, c * mHeader.mHeight, pCompression == PSD.COMPRESSION_RLE); + read16bitChannel(c, header.channels, raster.getDataBuffer(), interleavedBands, bandOffset, pSourceCM, row16, pSource, pDest, pXSub, pYSub, header.width, header.height, pByteCounts, c * header.height, pCompression == PSD.COMPRESSION_RLE); break; default: - throw new IIOException(String.format("Unknown PSD bit depth: %s", mHeader.mBits)); + throw new IIOException(String.format("Unknown PSD bit depth: %s", header.bits)); } if (abortRequested()) { @@ -441,7 +435,7 @@ public class PSDImageReader extends ImageReaderBase { } } - if (mHeader.mBits == 8) { + if (header.bits == 8) { // Compose out the background of the semi-transparent pixels, as PS somehow has the background composed in decomposeAlpha(destCM, raster.getDataBuffer(), pDest.width, pDest.height, raster.getNumBands()); } @@ -713,11 +707,11 @@ public class PSDImageReader extends ImageReaderBase { private void readHeader() throws IOException { assertInput(); - if (mHeader == null) { - mHeader = new PSDHeader(imageInput); + if (header == null) { + header = new PSDHeader(imageInput); - mMetadata = new PSDMetadata(); - mMetadata.mHeader = mHeader; + metadata = new PSDMetadata(); + metadata.header = header; /* Contains the required data to define the color mode. @@ -730,8 +724,8 @@ public class PSDImageReader extends ImageReaderBase { the duotone image as a grayscale image, and keep the duotone specification around as a black box for use when saving the file. */ - if (mHeader.mMode == PSD.COLOR_MODE_INDEXED) { - mMetadata.mColorData = new PSDColorData(imageInput); + if (header.mode == PSD.COLOR_MODE_INDEXED) { + metadata.colorData = new PSDColorData(imageInput); } else { // TODO: We need to store the duotone spec if we decide to create a writer... @@ -755,14 +749,14 @@ public class PSDImageReader extends ImageReaderBase { long length = imageInput.readUnsignedInt(); if (pParseData && length > 0) { - if (mMetadata.mImageResources == null) { - mMetadata.mImageResources = new ArrayList(); + if (metadata.imageResources == null) { + metadata.imageResources = new ArrayList(); long expectedEnd = imageInput.getStreamPosition() + length; while (imageInput.getStreamPosition() < expectedEnd) { // TODO: Have PSDImageResources defer actual parsing? (Just store stream offsets) PSDImageResource resource = PSDImageResource.read(imageInput); - mMetadata.mImageResources.add(resource); + metadata.imageResources.add(resource); } if (imageInput.getStreamPosition() != expectedEnd) { @@ -796,7 +790,7 @@ public class PSDImageReader extends ImageReaderBase { for (int i = 0; i < layerInfos.length; i++) { layerInfos[i] = new PSDLayerInfo(imageInput); } - mMetadata.mLayerInfo = Arrays.asList(layerInfos); + metadata.layerInfo = Arrays.asList(layerInfos); // TODO: Clean-up imageInput.mark(); @@ -810,7 +804,7 @@ public class PSDImageReader extends ImageReaderBase { // TODO: Don't show! Store in meta data somehow... // if (layer != null) { -// showIt(layer, layerInfo.mLayerName + " " + layerInfo.mBlendMode.toString()); +// showIt(layer, layerInfo.layerName + " " + layerInfo.blendMode.toString()); // } } @@ -825,8 +819,8 @@ public class PSDImageReader extends ImageReaderBase { long layerMaskInfoLength = imageInput.readUnsignedInt(); // System.out.println("GlobalLayerMaskInfo length: " + layerMaskInfoLength); if (layerMaskInfoLength > 0) { - mMetadata.mGlobalLayerMask = new PSDGlobalLayerMask(imageInput); -// System.out.println("mGlobalLayerMask: " + mGlobalLayerMask); + metadata.globalLayerMask = new PSDGlobalLayerMask(imageInput); +// System.out.println("globalLayerMask: " + globalLayerMask); } read = imageInput.getStreamPosition() - pos; @@ -842,8 +836,8 @@ public class PSDImageReader extends ImageReaderBase { } private BufferedImage readLayerData(final PSDLayerInfo pLayerInfo, final ImageTypeSpecifier pRawType, final ImageTypeSpecifier pImageType) throws IOException { - final int width = pLayerInfo.mRight - pLayerInfo.mLeft; - final int height = pLayerInfo.mBottom - pLayerInfo.mTop; + final int width = pLayerInfo.right - pLayerInfo.left; + final int height = pLayerInfo.bottom - pLayerInfo.top; // Even if raw/imageType has no alpha, the layers may still have alpha... ImageTypeSpecifier imageType = getImageTypeForLayer(pImageType, pLayerInfo); @@ -869,19 +863,19 @@ public class PSDImageReader extends ImageReaderBase { final boolean banded = raster.getDataBuffer().getNumBanks() > 1; final int interleavedBands = banded ? 1 : raster.getNumBands(); - for (PSDChannelInfo channelInfo : pLayerInfo.mChannelInfo) { + for (PSDChannelInfo channelInfo : pLayerInfo.channelInfo) { int compression = imageInput.readUnsignedShort(); // Skip layer if we can't read it // channelId == -2 means "user supplied layer mask", whatever that is... - if (width <= 0 || height <= 0 || channelInfo.mChannelId == -2 || + if (width <= 0 || height <= 0 || channelInfo.channelId == -2 || (compression != PSD.COMPRESSION_NONE && compression != PSD.COMPRESSION_RLE)) { - imageInput.skipBytes(channelInfo.mLength - 2); + imageInput.skipBytes(channelInfo.length - 2); } else { // 0 = red, 1 = green, etc // -1 = transparency mask; -2 = user supplied layer mask - int c = channelInfo.mChannelId == -1 ? pLayerInfo.mChannelInfo.length - 1 : channelInfo.mChannelId; + int c = channelInfo.channelId == -1 ? pLayerInfo.channelInfo.length - 1 : channelInfo.channelId; // NOTE: For layers, byte counts are written per channel, while for the composite data // byte counts are written for all channels before the image data. @@ -896,7 +890,7 @@ public class PSDImageReader extends ImageReaderBase { // If RLE, the the image data starts with the byte counts // for all the scan lines in the channel (LayerBottom-LayerTop), with // each count stored as a two*byte value. - byteCounts = new int[pLayerInfo.mBottom - pLayerInfo.mTop]; + byteCounts = new int[pLayerInfo.bottom - pLayerInfo.top]; for (int i = 0; i < byteCounts.length; i++) { byteCounts[i] = imageInput.readUnsignedShort(); } @@ -911,7 +905,7 @@ public class PSDImageReader extends ImageReaderBase { int bandOffset = banded ? 0 : interleavedBands - 1 - c; - switch (mHeader.mBits) { + switch (header.bits) { case 1: byte[] row1 = ((DataBufferByte) rowRaster.getDataBuffer()).getData(); // DataBufferByte buffer1 = (DataBufferByte) raster.getDataBuffer(); @@ -935,7 +929,7 @@ public class PSDImageReader extends ImageReaderBase { read16bitChannel(c, imageType.getNumBands(), raster.getDataBuffer(), interleavedBands, bandOffset, sourceCM, row16, area, area, xsub, ysub, width, height, byteCounts, 0, compression == PSD.COMPRESSION_RLE); break; default: - throw new IIOException(String.format("Unknown PSD bit depth: %s", mHeader.mBits)); + throw new IIOException(String.format("Unknown PSD bit depth: %s", header.bits)); } if (abortRequested()) { @@ -949,17 +943,17 @@ public class PSDImageReader extends ImageReaderBase { private ImageTypeSpecifier getImageTypeForLayer(final ImageTypeSpecifier pOriginal, final PSDLayerInfo pLayerInfo) { // If layer has more channels than composite data, it's normally extra alpha... - if (pLayerInfo.mChannelInfo.length > pOriginal.getNumBands()) { + if (pLayerInfo.channelInfo.length > pOriginal.getNumBands()) { // ...but, it could also be just the user mask... boolean userMask = false; - for (PSDChannelInfo channelInfo : pLayerInfo.mChannelInfo) { - if (channelInfo.mChannelId == -2) { + for (PSDChannelInfo channelInfo : pLayerInfo.channelInfo) { + if (channelInfo.channelId == -2) { userMask = true; break; } } - int newBandNum = pLayerInfo.mChannelInfo.length - (userMask ? 1 : 0); + int newBandNum = pLayerInfo.channelInfo.length - (userMask ? 1 : 0); // If there really is more channels, then create new imageTypeSpec if (newBandNum > pOriginal.getNumBands()) { @@ -1004,22 +998,22 @@ public class PSDImageReader extends ImageReaderBase { } @Override - public IIOMetadata getImageMetadata(final int pImageIndex) throws IOException { + public IIOMetadata getImageMetadata(final int imageIndex) throws IOException { // TODO: Implement - checkBounds(pImageIndex); + checkBounds(imageIndex); readHeader(); readImageResources(true); readLayerAndMaskInfo(true); // TODO: Need to make sure compression is set in metadata, even without reading the image data! - mMetadata.mCompression = imageInput.readShort(); + metadata.compression = imageInput.readShort(); -// mMetadata.mHeader = mHeader; -// mMetadata.mColorData = mColorData; -// mMetadata.mImageResources = mImageResources; +// metadata.header = header; +// metadata.colorData = colorData; +// metadata.imageResources = imageResources; - return mMetadata; // TODO: clone if we change to mutable metadata + return metadata; // TODO: clone if we change to mutable metadata } @Override @@ -1041,14 +1035,14 @@ public class PSDImageReader extends ImageReaderBase { List thumbnails = null; - if (mMetadata.mImageResources == null) { + if (metadata.imageResources == null) { // TODO: Need flag here, to specify what resources to read... readImageResources(true); // TODO: Skip this, requires storing some stream offsets readLayerAndMaskInfo(false); } - for (PSDImageResource resource : mMetadata.mImageResources) { + for (PSDImageResource resource : metadata.imageResources) { if (resource instanceof PSDThumbnail) { if (thumbnails == null) { thumbnails = new ArrayList(); @@ -1147,15 +1141,15 @@ public class PSDImageReader extends ImageReaderBase { imageReader.setInput(stream); imageReader.readHeader(); -// System.out.println("imageReader.mHeader: " + imageReader.mHeader); +// System.out.println("imageReader.header: " + imageReader.header); imageReader.readImageResources(true); - System.out.println("imageReader.mImageResources: " + imageReader.mMetadata.mImageResources); + System.out.println("imageReader.imageResources: " + imageReader.metadata.imageResources); System.out.println(); imageReader.readLayerAndMaskInfo(true); - System.out.println("imageReader.mLayerInfo: " + imageReader.mMetadata.mLayerInfo); -// System.out.println("imageReader.mGlobalLayerMask: " + imageReader.mGlobalLayerMask); + System.out.println("imageReader.layerInfo: " + imageReader.metadata.layerInfo); +// System.out.println("imageReader.globalLayerMask: " + imageReader.globalLayerMask); System.out.println(); IIOMetadata metadata = imageReader.getImageMetadata(0); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java index fed3d818..554e85c0 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDImageResource.java @@ -47,33 +47,33 @@ public class PSDImageResource { // TODO: Refactor image resources to separate package // TODO: Change constructor to store stream offset and length only (+ possibly the name), defer reading - final short mId; - final String mName; - final long mSize; + final short id; + final String name; + final long size; PSDImageResource(final short pId, final ImageInputStream pInput) throws IOException { - mId = pId; + id = pId; - mName = PSDUtil.readPascalString(pInput); + name = PSDUtil.readPascalString(pInput); // Skip pad - int nameSize = mName.length() + 1; + int nameSize = name.length() + 1; if (nameSize % 2 != 0) { pInput.readByte(); } - mSize = pInput.readUnsignedInt(); + size = pInput.readUnsignedInt(); long startPos = pInput.getStreamPosition(); - readData(new SubImageInputStream(pInput, mSize)); + readData(new SubImageInputStream(pInput, size)); // NOTE: This should never happen, however it's safer to keep it here to - if (pInput.getStreamPosition() != startPos + mSize) { - pInput.seek(startPos + mSize); + if (pInput.getStreamPosition() != startPos + size) { + pInput.seek(startPos + size); } // Data is even-padded (word aligned) - if (mSize % 2 != 0) { + if (size % 2 != 0) { pInput.read(); } } @@ -86,7 +86,7 @@ public class PSDImageResource { */ protected void readData(final ImageInputStream pInput) throws IOException { // TODO: This design is ugly, as subclasses readData is invoked BEFORE their respective constructor... - pInput.skipBytes(mSize); + pInput.skipBytes(size); } @Override @@ -94,7 +94,7 @@ public class PSDImageResource { StringBuilder builder = toStringBuilder(); builder.append(", data length: "); - builder.append(mSize); + builder.append(size); builder.append("]"); return builder.toString(); @@ -103,16 +103,16 @@ public class PSDImageResource { protected StringBuilder toStringBuilder() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); - String fakeType = resourceTypeForId(mId); + String fakeType = resourceTypeForId(id); if (fakeType != null) { builder.append("(").append(fakeType).append(")"); } builder.append("[ID: 0x"); - builder.append(Integer.toHexString(mId)); - if (mName != null && mName.trim().length() != 0) { + builder.append(Integer.toHexString(id)); + if (name != null && name.trim().length() != 0) { builder.append(", name: \""); - builder.append(mName); + builder.append(name); builder.append("\""); } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerBlendMode.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerBlendMode.java index fb0df440..f18b6071 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerBlendMode.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerBlendMode.java @@ -40,10 +40,10 @@ import java.io.IOException; * @version $Id: PSDLayerBlendMode.java,v 1.0 May 8, 2008 4:34:35 PM haraldk Exp$ */ class PSDLayerBlendMode { - final int mBlendMode; - final int mOpacity; // 0-255 - final int mClipping; // 0: base, 1: non-base - final int mFlags; + final int blendMode; + final int opacity; // 0-255 + final int clipping; // 0: base, 1: non-base + final int flags; public PSDLayerBlendMode(final ImageInputStream pInput) throws IOException { int blendModeSig = pInput.readInt(); @@ -51,11 +51,11 @@ class PSDLayerBlendMode { throw new IIOException("Illegal PSD Blend Mode signature, expected 8BIM: " + PSDUtil.intToStr(blendModeSig)); } - mBlendMode = pInput.readInt(); + blendMode = pInput.readInt(); - mOpacity = pInput.readUnsignedByte(); - mClipping = pInput.readUnsignedByte(); - mFlags = pInput.readUnsignedByte(); + opacity = pInput.readUnsignedByte(); + clipping = pInput.readUnsignedByte(); + flags = pInput.readUnsignedByte(); pInput.readByte(); // Pad } @@ -65,10 +65,10 @@ class PSDLayerBlendMode { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); builder.append("["); - builder.append("mode: \"").append(PSDUtil.intToStr(mBlendMode)); - builder.append("\", opacity: ").append(mOpacity); - builder.append(", clipping: ").append(mClipping); - switch (mClipping) { + builder.append("mode: \"").append(PSDUtil.intToStr(blendMode)); + builder.append("\", opacity: ").append(opacity); + builder.append(", clipping: ").append(clipping); + switch (clipping) { case 0: builder.append(" (base)"); break; @@ -79,40 +79,40 @@ class PSDLayerBlendMode { builder.append(" (unknown)"); break; } - builder.append(", flags: ").append(byteToBinary(mFlags)); + builder.append(", flags: ").append(byteToBinary(flags)); /* bit 0 = transparency protected; bit 1 = visible; bit 2 = obsolete; bit 3 = 1 for Photoshop 5.0 and later, tells if bit 4 has useful information; bit 4 = pixel data irrelevant to appearance of document */ builder.append(" ("); - if ((mFlags & 0x01) != 0) { + if ((flags & 0x01) != 0) { builder.append("Transp. protected, "); } - if ((mFlags & 0x02) != 0) { + if ((flags & 0x02) != 0) { builder.append("Hidden, "); } - if ((mFlags & 0x04) != 0) { + if ((flags & 0x04) != 0) { builder.append("Obsolete bit, "); } - if ((mFlags & 0x08) != 0) { + if ((flags & 0x08) != 0) { builder.append("PS 5.0 data present, "); // "tells if next bit has useful information"... } - if ((mFlags & 0x10) != 0) { + if ((flags & 0x10) != 0) { builder.append("Pixel data irrelevant, "); } - if ((mFlags & 0x20) != 0) { + if ((flags & 0x20) != 0) { builder.append("Unknown bit 5, "); } - if ((mFlags & 0x40) != 0) { + if ((flags & 0x40) != 0) { builder.append("Unknown bit 6, "); } - if ((mFlags & 0x80) != 0) { + if ((flags & 0x80) != 0) { builder.append("Unknown bit 7, "); } // Stupidity... - if (mFlags != 0) { + if (flags != 0) { builder.delete(builder.length() - 2, builder.length()); } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerInfo.java index 56a62f26..b9e2f07e 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerInfo.java @@ -41,34 +41,34 @@ import java.util.Arrays; * @version $Id: PSDLayerInfo.java,v 1.0 Apr 29, 2008 6:01:12 PM haraldk Exp$ */ class PSDLayerInfo { - final int mTop; - final int mLeft; - final int mBottom; - final int mRight; + final int top; + final int left; + final int bottom; + final int right; - final PSDChannelInfo[] mChannelInfo; - final PSDLayerBlendMode mBlendMode; - final PSDLayerMaskData mLayerMaskData; - final PSDChannelSourceDestinationRange[] mRanges; - final String mLayerName; + final PSDChannelInfo[] channelInfo; + final PSDLayerBlendMode blendMode; + final PSDLayerMaskData layerMaskData; + final PSDChannelSourceDestinationRange[] ranges; + final String layerName; PSDLayerInfo(ImageInputStream pInput) throws IOException { - mTop = pInput.readInt(); - mLeft = pInput.readInt(); - mBottom = pInput.readInt(); - mRight = pInput.readInt(); + top = pInput.readInt(); + left = pInput.readInt(); + bottom = pInput.readInt(); + right = pInput.readInt(); int channels = pInput.readUnsignedShort(); - mChannelInfo = new PSDChannelInfo[channels]; + channelInfo = new PSDChannelInfo[channels]; for (int i = 0; i < channels; i++) { short channelId = pInput.readShort(); long length = pInput.readUnsignedInt(); - mChannelInfo[i] = new PSDChannelInfo(channelId, length); + channelInfo[i] = new PSDChannelInfo(channelId, length); } - mBlendMode = new PSDLayerBlendMode(pInput); + blendMode = new PSDLayerBlendMode(pInput); // Lenght of layer mask data long extraDataSize = pInput.readUnsignedInt(); @@ -78,10 +78,10 @@ class PSDLayerInfo { // Layer mask/adjustment layer data int layerMaskDataSize = pInput.readInt(); // May be 0, 20 or 36 bytes... if (layerMaskDataSize != 0) { - mLayerMaskData = new PSDLayerMaskData(pInput, layerMaskDataSize); + layerMaskData = new PSDLayerMaskData(pInput, layerMaskDataSize); } else { - mLayerMaskData = null; + layerMaskData = null; } int layerBlendingDataSize = pInput.readInt(); @@ -89,15 +89,15 @@ class PSDLayerInfo { throw new IIOException("Illegal PSD Layer Blending Data size: " + layerBlendingDataSize + ", expected multiple of 8"); } - mRanges = new PSDChannelSourceDestinationRange[layerBlendingDataSize / 8]; - for (int i = 0; i < mRanges.length; i++) { - mRanges[i] = new PSDChannelSourceDestinationRange(pInput, (i == 0 ? "Gray" : "Channel " + (i - 1))); + ranges = new PSDChannelSourceDestinationRange[layerBlendingDataSize / 8]; + for (int i = 0; i < ranges.length; i++) { + ranges[i] = new PSDChannelSourceDestinationRange(pInput, (i == 0 ? "Gray" : "Channel " + (i - 1))); } - mLayerName = PSDUtil.readPascalString(pInput); + layerName = PSDUtil.readPascalString(pInput); - int layerNameSize = mLayerName.length() + 1; + int layerNameSize = layerName.length() + 1; // Skip pad bytes for long word alignment if (layerNameSize % 4 != 0) { @@ -115,18 +115,18 @@ class PSDLayerInfo { public String toString() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); builder.append("["); - builder.append("top: ").append(mTop); - builder.append(", left: ").append(mLeft); - builder.append(", bottom: ").append(mBottom); - builder.append(", right: ").append(mRight); + builder.append("top: ").append(top); + builder.append(", left: ").append(left); + builder.append(", bottom: ").append(bottom); + builder.append(", right: ").append(right); - builder.append(", channels: ").append(Arrays.toString(mChannelInfo)); - builder.append(", blend mode: ").append(mBlendMode); - if (mLayerMaskData != null) { - builder.append(", layer mask data: ").append(mLayerMaskData); + builder.append(", channels: ").append(Arrays.toString(channelInfo)); + builder.append(", blend mode: ").append(blendMode); + if (layerMaskData != null) { + builder.append(", layer mask data: ").append(layerMaskData); } - builder.append(", ranges: ").append(Arrays.toString(mRanges)); - builder.append(", layer name: \"").append(mLayerName).append("\""); + builder.append(", ranges: ").append(Arrays.toString(ranges)); + builder.append(", layer name: \"").append(layerName).append("\""); builder.append("]"); return builder.toString(); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerMaskData.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerMaskData.java index 277938b6..16a4bd83 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerMaskData.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDLayerMaskData.java @@ -40,48 +40,48 @@ import java.io.IOException; * @version $Id: PSDLayerMaskData.java,v 1.0 May 6, 2008 5:15:05 PM haraldk Exp$ */ class PSDLayerMaskData { - private int mTop; - private int mLeft; - private int mBottom; - private int mRight; - private int mDefaultColor; - private int mFlags; + private int top; + private int left; + private int bottom; + private int right; + private int defaultColor; + private int flags; - private boolean mLarge; - private int mRealFlags; - private int mRealUserBackground; - private int mRealTop; - private int mRealLeft; - private int mRealBottom; - private int mRealRight; + private boolean large; + private int realFlags; + private int realUserBackground; + private int realTop; + private int realLeft; + private int realBottom; + private int realRight; PSDLayerMaskData(ImageInputStream pInput, int pSize) throws IOException { if (pSize != 20 && pSize != 36) { throw new IIOException("Illegal PSD Layer Mask data size: " + pSize + " (expeced 20 or 36)"); } - mTop = pInput.readInt(); - mLeft = pInput.readInt(); - mBottom = pInput.readInt(); - mRight = pInput.readInt(); + top = pInput.readInt(); + left = pInput.readInt(); + bottom = pInput.readInt(); + right = pInput.readInt(); - mDefaultColor = pInput.readUnsignedByte(); + defaultColor = pInput.readUnsignedByte(); - mFlags = pInput.readUnsignedByte(); + flags = pInput.readUnsignedByte(); if (pSize == 20) { pInput.readShort(); // Pad } else { // TODO: What to make out of this? - mLarge = true; + large = true; - mRealFlags = pInput.readUnsignedByte(); - mRealUserBackground = pInput.readUnsignedByte(); + realFlags = pInput.readUnsignedByte(); + realUserBackground = pInput.readUnsignedByte(); - mRealTop = pInput.readInt(); - mRealLeft = pInput.readInt(); - mRealBottom = pInput.readInt(); - mRealRight = pInput.readInt(); + realTop = pInput.readInt(); + realLeft = pInput.readInt(); + realBottom = pInput.readInt(); + realRight = pInput.readInt(); } } @@ -89,43 +89,43 @@ class PSDLayerMaskData { public String toString() { StringBuilder builder = new StringBuilder(getClass().getSimpleName()); builder.append("["); - builder.append("top: ").append(mTop); - builder.append(", left: ").append(mLeft); - builder.append(", bottom: ").append(mBottom); - builder.append(", right: ").append(mRight); - builder.append(", default color: ").append(mDefaultColor); - builder.append(", flags: ").append(Integer.toBinaryString(mFlags)); + builder.append("top: ").append(top); + builder.append(", left: ").append(left); + builder.append(", bottom: ").append(bottom); + builder.append(", right: ").append(right); + builder.append(", default color: ").append(defaultColor); + builder.append(", flags: ").append(Integer.toBinaryString(flags)); // TODO: Maybe the flag bits have oposite order? builder.append(" ("); - if ((mFlags & 0x01) != 0) { + if ((flags & 0x01) != 0) { builder.append("Pos. rel. to layer"); } else { builder.append("Pos. abs."); } - if ((mFlags & 0x02) != 0) { + if ((flags & 0x02) != 0) { builder.append(", Mask disabled"); } else { builder.append(", Mask enabled"); } - if ((mFlags & 0x04) != 0) { + if ((flags & 0x04) != 0) { builder.append(", Invert mask"); } - if ((mFlags & 0x08) != 0) { + if ((flags & 0x08) != 0) { builder.append(", Unknown bit 3"); } - if ((mFlags & 0x10) != 0) { + if ((flags & 0x10) != 0) { builder.append(", Unknown bit 4"); } - if ((mFlags & 0x20) != 0) { + if ((flags & 0x20) != 0) { builder.append(", Unknown bit 5"); } - if ((mFlags & 0x40) != 0) { + if ((flags & 0x40) != 0) { builder.append(", Unknown bit 6"); } - if ((mFlags & 0x80) != 0) { + if ((flags & 0x80) != 0) { builder.append(", Unknown bit 7"); } builder.append(")"); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java index d18c80ea..425016c4 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDMetadata.java @@ -27,12 +27,12 @@ public final class PSDMetadata extends AbstractMetadata { static final String NATIVE_METADATA_FORMAT_NAME = "com_twelvemonkeys_imageio_psd_image_1.0"; static final String NATIVE_METADATA_FORMAT_CLASS_NAME = "com.twelvemonkeys.imageio.plugins.psd.PSDMetadataFormat"; - PSDHeader mHeader; - PSDColorData mColorData; - int mCompression = -1; - List mImageResources; - PSDGlobalLayerMask mGlobalLayerMask; - List mLayerInfo; + PSDHeader header; + PSDColorData colorData; + int compression = -1; + List imageResources; + PSDGlobalLayerMask globalLayerMask; + List layerInfo; static final String[] COLOR_MODES = { "MONOCHROME", "GRAYSCALE", "INDEXED", "RGB", "CMYK", null, null, "MULTICHANNEL", "DUOTONE", "LAB" @@ -70,11 +70,11 @@ public final class PSDMetadata extends AbstractMetadata { root.appendChild(createHeaderNode()); - if (mHeader.mMode == PSD.COLOR_MODE_INDEXED) { + if (header.mode == PSD.COLOR_MODE_INDEXED) { root.appendChild(createPaletteNode()); } - if (mImageResources != null && !mImageResources.isEmpty()) { + if (imageResources != null && !imageResources.isEmpty()) { root.appendChild(createImageResourcesNode()); } @@ -86,11 +86,11 @@ public final class PSDMetadata extends AbstractMetadata { header.setAttribute("type", "PSD"); header.setAttribute("version", "1"); - header.setAttribute("channels", Integer.toString(mHeader.mChannels)); - header.setAttribute("height", Integer.toString(mHeader.mHeight)); - header.setAttribute("width", Integer.toString(mHeader.mWidth)); - header.setAttribute("bits", Integer.toString(mHeader.mBits)); - header.setAttribute("mode", COLOR_MODES[mHeader.mMode]); + header.setAttribute("channels", Integer.toString(this.header.channels)); + header.setAttribute("height", Integer.toString(this.header.height)); + header.setAttribute("width", Integer.toString(this.header.width)); + header.setAttribute("bits", Integer.toString(this.header.bits)); + header.setAttribute("mode", COLOR_MODES[this.header.mode]); return header; } @@ -99,7 +99,7 @@ public final class PSDMetadata extends AbstractMetadata { IIOMetadataNode resource = new IIOMetadataNode("ImageResources"); IIOMetadataNode node; - for (PSDImageResource imageResource : mImageResources) { + for (PSDImageResource imageResource : imageResources) { // TODO: Always add name (if set) and id (as resourceId) to all nodes? // Resource Id is useful for people with access to the PSD spec.. @@ -128,7 +128,7 @@ public final class PSDMetadata extends AbstractMetadata { node = new IIOMetadataNode("AlphaChannelInfo"); - for (String name : alphaChannelInfo.mNames) { + for (String name : alphaChannelInfo.names) { IIOMetadataNode nameNode = new IIOMetadataNode("Name"); nameNode.setAttribute("value", name); node.appendChild(nameNode); @@ -138,11 +138,11 @@ public final class PSDMetadata extends AbstractMetadata { PSDDisplayInfo displayInfo = (PSDDisplayInfo) imageResource; node = new IIOMetadataNode("DisplayInfo"); - node.setAttribute("colorSpace", DISPLAY_INFO_CS[displayInfo.mColorSpace]); + node.setAttribute("colorSpace", DISPLAY_INFO_CS[displayInfo.colorSpace]); StringBuilder builder = new StringBuilder(); - for (short color : displayInfo.mColors) { + for (short color : displayInfo.colors) { if (builder.length() > 0) { builder.append(" "); } @@ -151,79 +151,79 @@ public final class PSDMetadata extends AbstractMetadata { } node.setAttribute("colors", builder.toString()); - node.setAttribute("opacity", Integer.toString(displayInfo.mOpacity)); - node.setAttribute("kind", DISPLAY_INFO_KINDS[displayInfo.mKind]); + node.setAttribute("opacity", Integer.toString(displayInfo.opacity)); + node.setAttribute("kind", DISPLAY_INFO_KINDS[displayInfo.kind]); } else if (imageResource instanceof PSDGridAndGuideInfo) { PSDGridAndGuideInfo info = (PSDGridAndGuideInfo) imageResource; node = new IIOMetadataNode("GridAndGuideInfo"); - node.setAttribute("version", String.valueOf(info.mVersion)); - node.setAttribute("verticalGridCycle", String.valueOf(info.mGridCycleVertical)); - node.setAttribute("horizontalGridCycle", String.valueOf(info.mGridCycleHorizontal)); + node.setAttribute("version", String.valueOf(info.version)); + node.setAttribute("verticalGridCycle", String.valueOf(info.gridCycleVertical)); + node.setAttribute("horizontalGridCycle", String.valueOf(info.gridCycleHorizontal)); - for (PSDGridAndGuideInfo.GuideResource guide : info.mGuides) { + for (PSDGridAndGuideInfo.GuideResource guide : info.guides) { IIOMetadataNode guideNode = new IIOMetadataNode("Guide"); - guideNode.setAttribute("location", Integer.toString(guide.mLocation)); - guideNode.setAttribute("orientation", GUIDE_ORIENTATIONS[guide.mDirection]); + guideNode.setAttribute("location", Integer.toString(guide.location)); + guideNode.setAttribute("orientation", GUIDE_ORIENTATIONS[guide.direction]); } } else if (imageResource instanceof PSDPixelAspectRatio) { PSDPixelAspectRatio aspectRatio = (PSDPixelAspectRatio) imageResource; node = new IIOMetadataNode("PixelAspectRatio"); - node.setAttribute("version", String.valueOf(aspectRatio.mVersion)); - node.setAttribute("aspectRatio", String.valueOf(aspectRatio.mAspect)); + node.setAttribute("version", String.valueOf(aspectRatio.version)); + node.setAttribute("aspectRatio", String.valueOf(aspectRatio.aspect)); } else if (imageResource instanceof PSDPrintFlags) { PSDPrintFlags flags = (PSDPrintFlags) imageResource; node = new IIOMetadataNode("PrintFlags"); - node.setAttribute("labels", String.valueOf(flags.mLabels)); - node.setAttribute("cropMarks", String.valueOf(flags.mCropMasks)); - node.setAttribute("colorBars", String.valueOf(flags.mColorBars)); - node.setAttribute("registrationMarks", String.valueOf(flags.mRegistrationMarks)); - node.setAttribute("negative", String.valueOf(flags.mNegative)); - node.setAttribute("flip", String.valueOf(flags.mFlip)); - node.setAttribute("interpolate", String.valueOf(flags.mInterpolate)); - node.setAttribute("caption", String.valueOf(flags.mCaption)); + node.setAttribute("labels", String.valueOf(flags.labels)); + node.setAttribute("cropMarks", String.valueOf(flags.cropMasks)); + node.setAttribute("colorBars", String.valueOf(flags.colorBars)); + node.setAttribute("registrationMarks", String.valueOf(flags.registrationMarks)); + node.setAttribute("negative", String.valueOf(flags.negative)); + node.setAttribute("flip", String.valueOf(flags.flip)); + node.setAttribute("interpolate", String.valueOf(flags.interpolate)); + node.setAttribute("caption", String.valueOf(flags.caption)); } else if (imageResource instanceof PSDPrintFlagsInformation) { PSDPrintFlagsInformation information = (PSDPrintFlagsInformation) imageResource; node = new IIOMetadataNode("PrintFlagsInformation"); - node.setAttribute("version", String.valueOf(information.mVersion)); - node.setAttribute("cropMarks", String.valueOf(information.mCropMasks)); - node.setAttribute("field", String.valueOf(information.mField)); - node.setAttribute("bleedWidth", String.valueOf(information.mBleedWidth)); - node.setAttribute("bleedScale", String.valueOf(information.mBleedScale)); + node.setAttribute("version", String.valueOf(information.version)); + node.setAttribute("cropMarks", String.valueOf(information.cropMasks)); + node.setAttribute("field", String.valueOf(information.field)); + node.setAttribute("bleedWidth", String.valueOf(information.bleedWidth)); + node.setAttribute("bleedScale", String.valueOf(information.bleedScale)); } else if (imageResource instanceof PSDPrintScale) { PSDPrintScale printScale = (PSDPrintScale) imageResource; node = new IIOMetadataNode("PrintScale"); - node.setAttribute("style", PRINT_SCALE_STYLES[printScale.mStyle]); - node.setAttribute("xLocation", String.valueOf(printScale.mXLocation)); - node.setAttribute("yLocation", String.valueOf(printScale.mYlocation)); - node.setAttribute("scale", String.valueOf(printScale.mScale)); + node.setAttribute("style", PRINT_SCALE_STYLES[printScale.style]); + node.setAttribute("xLocation", String.valueOf(printScale.xLocation)); + node.setAttribute("yLocation", String.valueOf(printScale.ylocation)); + node.setAttribute("scale", String.valueOf(printScale.scale)); } else if (imageResource instanceof PSDResolutionInfo) { PSDResolutionInfo information = (PSDResolutionInfo) imageResource; node = new IIOMetadataNode("ResolutionInfo"); - node.setAttribute("horizontalResolution", String.valueOf(information.mHRes)); - node.setAttribute("horizontalResolutionUnit", RESOLUTION_UNITS[information.mHResUnit]); - node.setAttribute("widthUnit", DIMENSION_UNITS[information.mWidthUnit]); - node.setAttribute("verticalResolution", String.valueOf(information.mVRes)); - node.setAttribute("verticalResolutionUnit", RESOLUTION_UNITS[information.mVResUnit]); - node.setAttribute("heightUnit", DIMENSION_UNITS[information.mHeightUnit]); + node.setAttribute("horizontalResolution", String.valueOf(information.hRes)); + node.setAttribute("horizontalResolutionUnit", RESOLUTION_UNITS[information.hResUnit]); + node.setAttribute("widthUnit", DIMENSION_UNITS[information.widthUnit]); + node.setAttribute("verticalResolution", String.valueOf(information.vRes)); + node.setAttribute("verticalResolutionUnit", RESOLUTION_UNITS[information.vResUnit]); + node.setAttribute("heightUnit", DIMENSION_UNITS[information.heightUnit]); } else if (imageResource instanceof PSDUnicodeAlphaNames) { PSDUnicodeAlphaNames alphaNames = (PSDUnicodeAlphaNames) imageResource; node = new IIOMetadataNode("UnicodeAlphaNames"); - for (String name : alphaNames.mNames) { + for (String name : alphaNames.names) { IIOMetadataNode nameNode = new IIOMetadataNode("Name"); nameNode.setAttribute("value", name); node.appendChild(nameNode); @@ -233,11 +233,11 @@ public final class PSDMetadata extends AbstractMetadata { PSDVersionInfo information = (PSDVersionInfo) imageResource; node = new IIOMetadataNode("VersionInfo"); - node.setAttribute("version", String.valueOf(information.mVersion)); - node.setAttribute("hasRealMergedData", String.valueOf(information.mHasRealMergedData)); - node.setAttribute("writer", information.mWriter); - node.setAttribute("reader", information.mReader); - node.setAttribute("fileVersion", String.valueOf(information.mFileVersion)); + node.setAttribute("version", String.valueOf(information.version)); + node.setAttribute("hasRealMergedData", String.valueOf(information.hasRealMergedData)); + node.setAttribute("writer", information.writer); + node.setAttribute("reader", information.reader); + node.setAttribute("fileVersion", String.valueOf(information.fileVersion)); } else if (imageResource instanceof PSDThumbnail) { // TODO: Revise/rethink this... @@ -253,9 +253,9 @@ public final class PSDMetadata extends AbstractMetadata { node = new IIOMetadataNode("DirectoryResource"); node.setAttribute("type", "IPTC"); - node.setUserObject(iptc.mDirectory); + node.setUserObject(iptc.directory); - appendEntries(node, "IPTC", iptc.mDirectory); + appendEntries(node, "IPTC", iptc.directory); } else if (imageResource instanceof PSDEXIF1Data) { // TODO: Revise/rethink this... @@ -264,9 +264,9 @@ public final class PSDMetadata extends AbstractMetadata { node = new IIOMetadataNode("DirectoryResource"); node.setAttribute("type", "EXIF"); // TODO: Set byte[] data instead - node.setUserObject(exif.mDirectory); + node.setUserObject(exif.directory); - appendEntries(node, "EXIF", exif.mDirectory); + appendEntries(node, "EXIF", exif.directory); } else if (imageResource instanceof PSDXMPData) { // TODO: Revise/rethink this... Would it be possible to parse XMP as IIOMetadataNodes? Or is that just stupid... @@ -275,25 +275,25 @@ public final class PSDMetadata extends AbstractMetadata { node = new IIOMetadataNode("DirectoryResource"); node.setAttribute("type", "XMP"); - appendEntries(node, "XMP", xmp.mDirectory); + appendEntries(node, "XMP", xmp.directory); // Set the entire XMP document as user data - node.setUserObject(xmp.mData); + node.setUserObject(xmp.data); } else { // Generic resource.. node = new IIOMetadataNode("ImageResource"); - String value = PSDImageResource.resourceTypeForId(imageResource.mId); + String value = PSDImageResource.resourceTypeForId(imageResource.id); if (!"UnknownResource".equals(value)) { node.setAttribute("name", value); } - node.setAttribute("length", String.valueOf(imageResource.mSize)); + node.setAttribute("length", String.valueOf(imageResource.size)); // TODO: Set user object: byte array } // TODO: More resources - node.setAttribute("resourceId", String.format("0x%04x", imageResource.mId)); + node.setAttribute("resourceId", String.format("0x%04x", imageResource.id)); resource.appendChild(node); } @@ -343,7 +343,7 @@ public final class PSDMetadata extends AbstractMetadata { node = new IIOMetadataNode("ColorSpaceType"); String cs; - switch (mHeader.mMode) { + switch (header.mode) { case PSD.COLOR_MODE_MONOCHROME: case PSD.COLOR_MODE_GRAYSCALE: case PSD.COLOR_MODE_DUOTONE: // Rationale: Spec says treat as gray... @@ -357,7 +357,7 @@ public final class PSDMetadata extends AbstractMetadata { cs = "CMYK"; break; case PSD.COLOR_MODE_MULTICHANNEL: - cs = getMultiChannelCS(mHeader.mChannels); + cs = getMultiChannelCS(header.channels); break; case PSD.COLOR_MODE_LAB: cs = "Lab"; @@ -370,7 +370,7 @@ public final class PSDMetadata extends AbstractMetadata { // TODO: Channels might be 5 for RGB + A + Mask... Probably not correct node = new IIOMetadataNode("NumChannels"); - node.setAttribute("value", Integer.toString(mHeader.mChannels)); + node.setAttribute("value", Integer.toString(header.channels)); chroma_node.appendChild(node); // TODO: Check if this is correct with bitmap (monchrome) @@ -378,7 +378,7 @@ public final class PSDMetadata extends AbstractMetadata { node.setAttribute("value", "true"); chroma_node.appendChild(node); - if (mHeader.mMode == PSD.COLOR_MODE_INDEXED) { + if (header.mode == PSD.COLOR_MODE_INDEXED) { node = createPaletteNode(); chroma_node.appendChild(node); } @@ -411,7 +411,7 @@ public final class PSDMetadata extends AbstractMetadata { private IIOMetadataNode createPaletteNode() { IIOMetadataNode node = new IIOMetadataNode("Palette"); - IndexColorModel cm = mColorData.getIndexColorModel(); + IndexColorModel cm = colorData.getIndexColorModel(); for (int i = 0; i < cm.getMapSize(); i++) { IIOMetadataNode entry = new IIOMetadataNode("PaletteEntry"); @@ -442,7 +442,7 @@ public final class PSDMetadata extends AbstractMetadata { node = new IIOMetadataNode("CompressionTypeName"); String compression; - switch (mCompression) { + switch (this.compression) { case PSD.COMPRESSION_NONE: compression = "none"; break; @@ -478,13 +478,13 @@ public final class PSDMetadata extends AbstractMetadata { dataNode.appendChild(node); node = new IIOMetadataNode("SampleFormat"); - node.setAttribute("value", mHeader.mMode == PSD.COLOR_MODE_INDEXED ? "Index" : "UnsignedIntegral"); + node.setAttribute("value", header.mode == PSD.COLOR_MODE_INDEXED ? "Index" : "UnsignedIntegral"); dataNode.appendChild(node); - String bitDepth = Integer.toString(mHeader.mBits); // bits per plane + String bitDepth = Integer.toString(header.bits); // bits per plane // TODO: Channels might be 5 for RGB + A + Mask... - String[] bps = new String[mHeader.mChannels]; + String[] bps = new String[header.channels]; Arrays.fill(bps, bitDepth); node = new IIOMetadataNode("BitsPerSample"); @@ -509,7 +509,7 @@ public final class PSDMetadata extends AbstractMetadata { Iterator ratios = getResources(PSDPixelAspectRatio.class); if (ratios.hasNext()) { PSDPixelAspectRatio ratio = ratios.next(); - aspect = (float) ratio.mAspect; + aspect = (float) ratio.aspect; } node.setAttribute("value", Float.toString(aspect)); @@ -525,11 +525,11 @@ public final class PSDMetadata extends AbstractMetadata { PSDResolutionInfo resolutionInfo = resolutionInfos.next(); node = new IIOMetadataNode("HorizontalPixelSize"); - node.setAttribute("value", Float.toString(asMM(resolutionInfo.mHResUnit, resolutionInfo.mHRes))); + node.setAttribute("value", Float.toString(asMM(resolutionInfo.hResUnit, resolutionInfo.hRes))); dimensionNode.appendChild(node); node = new IIOMetadataNode("VerticalPixelSize"); - node.setAttribute("value", Float.toString(asMM(resolutionInfo.mVResUnit, resolutionInfo.mVRes))); + node.setAttribute("value", Float.toString(asMM(resolutionInfo.vResUnit, resolutionInfo.vRes))); dimensionNode.appendChild(node); } @@ -583,7 +583,7 @@ public final class PSDMetadata extends AbstractMetadata { PSDEXIF1Data data = exif.next(); // Get the EXIF DateTime (aka ModifyDate) tag if present - Entry dateTime = data.mDirectory.getEntryById(TIFF.TAG_DATE_TIME); + Entry dateTime = data.directory.getEntryById(TIFF.TAG_DATE_TIME); if (dateTime != null) { node = new IIOMetadataNode("ImageCreationTime"); // As TIFF, but could just as well be ImageModificationTime // Format: "YYYY:MM:DD hh:mm:ss" @@ -629,7 +629,7 @@ public final class PSDMetadata extends AbstractMetadata { if (textResource instanceof PSDIPTCData) { PSDIPTCData iptc = (PSDIPTCData) textResource; - appendTextEntriesFlat(text, iptc.mDirectory, new FilterIterator.Filter() { + appendTextEntriesFlat(text, iptc.directory, new FilterIterator.Filter() { public boolean accept(final Entry pEntry) { Integer tagId = (Integer) pEntry.getIdentifier(); @@ -645,7 +645,7 @@ public final class PSDMetadata extends AbstractMetadata { else if (textResource instanceof PSDEXIF1Data) { PSDEXIF1Data exif = (PSDEXIF1Data) textResource; - appendTextEntriesFlat(text, exif.mDirectory, new FilterIterator.Filter() { + appendTextEntriesFlat(text, exif.directory, new FilterIterator.Filter() { public boolean accept(final Entry pEntry) { Integer tagId = (Integer) pEntry.getIdentifier(); @@ -714,14 +714,14 @@ public final class PSDMetadata extends AbstractMetadata { } private boolean hasAlpha() { - return mHeader.mMode == PSD.COLOR_MODE_RGB && mHeader.mChannels >= 4 || - mHeader.mMode == PSD.COLOR_MODE_CMYK & mHeader.mChannels >= 5; + return header.mode == PSD.COLOR_MODE_RGB && header.channels >= 4 || + header.mode == PSD.COLOR_MODE_CMYK & header.channels >= 5; } Iterator getResources(final Class pResourceType) { // NOTE: The cast here is wrong, strictly speaking, but it does not matter... @SuppressWarnings({"unchecked"}) - Iterator iterator = (Iterator) mImageResources.iterator(); + Iterator iterator = (Iterator) imageResources.iterator(); return new FilterIterator(iterator, new FilterIterator.Filter() { public boolean accept(final T pElement) { @@ -731,12 +731,12 @@ public final class PSDMetadata extends AbstractMetadata { } Iterator getResources(final int... pResourceTypes) { - Iterator iterator = mImageResources.iterator(); + Iterator iterator = imageResources.iterator(); return new FilterIterator(iterator, new FilterIterator.Filter() { public boolean accept(final PSDImageResource pResource) { for (int type : pResourceTypes) { - if (type == pResource.mId) { + if (type == pResource.id) { return true; } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPixelAspectRatio.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPixelAspectRatio.java index 612e309a..fd09b4bf 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPixelAspectRatio.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPixelAspectRatio.java @@ -12,8 +12,8 @@ import java.io.IOException; */ final class PSDPixelAspectRatio extends PSDImageResource { // 4 bytes (version = 1), 8 bytes double, x / y of a pixel - int mVersion; - double mAspect; + int version; + double aspect; PSDPixelAspectRatio(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -21,7 +21,7 @@ final class PSDPixelAspectRatio extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mVersion = pInput.readInt(); - mAspect = pInput.readDouble(); + version = pInput.readInt(); + aspect = pInput.readDouble(); } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlags.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlags.java index 606fd156..9d054b52 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlags.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlags.java @@ -11,14 +11,14 @@ import java.io.IOException; * @version $Id: PSDPrintFlagsInfo.java,v 1.0 Jul 28, 2009 5:16:27 PM haraldk Exp$ */ final class PSDPrintFlags extends PSDImageResource { - boolean mLabels; - boolean mCropMasks; - boolean mColorBars; - boolean mRegistrationMarks; - boolean mNegative; - boolean mFlip; - boolean mInterpolate; - boolean mCaption; + boolean labels; + boolean cropMasks; + boolean colorBars; + boolean registrationMarks; + boolean negative; + boolean flip; + boolean interpolate; + boolean caption; PSDPrintFlags(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -26,30 +26,30 @@ final class PSDPrintFlags extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mLabels = pInput.readBoolean(); - mCropMasks = pInput.readBoolean(); - mColorBars = pInput.readBoolean(); - mRegistrationMarks = pInput.readBoolean(); - mNegative = pInput.readBoolean(); - mFlip = pInput.readBoolean(); - mInterpolate = pInput.readBoolean(); - mCaption = pInput.readBoolean(); + labels = pInput.readBoolean(); + cropMasks = pInput.readBoolean(); + colorBars = pInput.readBoolean(); + registrationMarks = pInput.readBoolean(); + negative = pInput.readBoolean(); + flip = pInput.readBoolean(); + interpolate = pInput.readBoolean(); + caption = pInput.readBoolean(); - pInput.skipBytes(mSize - 8); + pInput.skipBytes(size - 8); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", labels: ").append(mLabels); - builder.append(", crop masks: ").append(mCropMasks); - builder.append(", color bars: ").append(mColorBars); - builder.append(", registration marks: ").append(mRegistrationMarks); - builder.append(", negative: ").append(mNegative); - builder.append(", flip: ").append(mFlip); - builder.append(", interpolate: ").append(mInterpolate); - builder.append(", caption: ").append(mCaption); + builder.append(", labels: ").append(labels); + builder.append(", crop masks: ").append(cropMasks); + builder.append(", color bars: ").append(colorBars); + builder.append(", registration marks: ").append(registrationMarks); + builder.append(", negative: ").append(negative); + builder.append(", flip: ").append(flip); + builder.append(", interpolate: ").append(interpolate); + builder.append(", caption: ").append(caption); builder.append("]"); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlagsInformation.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlagsInformation.java index d5de5eb2..c63c8811 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlagsInformation.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintFlagsInformation.java @@ -11,11 +11,11 @@ import java.io.IOException; * @version $Id: PSDPrintFlagsInfo.java,v 1.0 Jul 28, 2009 5:16:27 PM haraldk Exp$ */ final class PSDPrintFlagsInformation extends PSDImageResource { - int mVersion; - boolean mCropMasks; - int mField; - long mBleedWidth; - int mBleedScale; + int version; + boolean cropMasks; + int field; + long bleedWidth; + int bleedScale; PSDPrintFlagsInformation(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -23,24 +23,24 @@ final class PSDPrintFlagsInformation extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mVersion = pInput.readUnsignedShort(); - mCropMasks = pInput.readBoolean(); - mField = pInput.readUnsignedByte(); // TODO: Is this really pad? - mBleedWidth = pInput.readUnsignedInt(); - mBleedScale = pInput.readUnsignedShort(); + version = pInput.readUnsignedShort(); + cropMasks = pInput.readBoolean(); + field = pInput.readUnsignedByte(); // TODO: Is this really pad? + bleedWidth = pInput.readUnsignedInt(); + bleedScale = pInput.readUnsignedShort(); - pInput.skipBytes(mSize - 10); + pInput.skipBytes(size - 10); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", version: ").append(mVersion); - builder.append(", crop masks: ").append(mCropMasks); - builder.append(", field: ").append(mField); - builder.append(", bleed width: ").append(mBleedWidth); - builder.append(", bleed scale: ").append(mBleedScale); + builder.append(", version: ").append(version); + builder.append(", crop masks: ").append(cropMasks); + builder.append(", field: ").append(field); + builder.append(", bleed width: ").append(bleedWidth); + builder.append(", bleed scale: ").append(bleedScale); builder.append("]"); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintScale.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintScale.java index 35d14b1f..e89e5613 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintScale.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDPrintScale.java @@ -16,10 +16,10 @@ final class PSDPrintScale extends PSDImageResource { // 4 bytes y location (floating point). // 4 bytes scale (floating point) - short mStyle; - float mXLocation; - float mYlocation; - float mScale; + short style; + float xLocation; + float ylocation; + float scale; PSDPrintScale(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -27,9 +27,9 @@ final class PSDPrintScale extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mStyle = pInput.readShort(); - mXLocation = pInput.readFloat(); - mYlocation = pInput.readFloat(); - mScale = pInput.readFloat(); + style = pInput.readShort(); + xLocation = pInput.readFloat(); + ylocation = pInput.readFloat(); + scale = pInput.readFloat(); } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDResolutionInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDResolutionInfo.java index 629f3a9c..f3943f73 100755 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDResolutionInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDResolutionInfo.java @@ -50,12 +50,12 @@ class PSDResolutionInfo extends PSDImageResource { // WORD HeightUnit; /* 1=in, 2=cm, 3=pt, 4=picas, 5=columns */ // } RESOLUTIONINFO; - float mHRes; - short mHResUnit; - short mWidthUnit; - float mVRes; - short mVResUnit; - short mHeightUnit; + float hRes; + short hResUnit; + short widthUnit; + float vRes; + short vResUnit; + short heightUnit; PSDResolutionInfo(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -63,32 +63,32 @@ class PSDResolutionInfo extends PSDImageResource { @Override protected void readData(ImageInputStream pInput) throws IOException { - if (mSize != 16) { - throw new IIOException("Resolution info length expected to be 16: " + mSize); + if (size != 16) { + throw new IIOException("Resolution info length expected to be 16: " + size); } - mHRes = PSDUtil.fixedPointToFloat(pInput.readInt()); - mHResUnit = pInput.readShort(); - mWidthUnit = pInput.readShort(); - mVRes = PSDUtil.fixedPointToFloat(pInput.readInt()); - mVResUnit = pInput.readShort(); - mHeightUnit = pInput.readShort(); + hRes = PSDUtil.fixedPointToFloat(pInput.readInt()); + hResUnit = pInput.readShort(); + widthUnit = pInput.readShort(); + vRes = PSDUtil.fixedPointToFloat(pInput.readInt()); + vResUnit = pInput.readShort(); + heightUnit = pInput.readShort(); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", hRes: ").append(mHRes); + builder.append(", hRes: ").append(hRes); builder.append(" "); - builder.append(resUnit(mHResUnit)); + builder.append(resUnit(hResUnit)); builder.append(", width unit: "); - builder.append(dimUnit(mWidthUnit)); - builder.append(", vRes: ").append(mVRes); + builder.append(dimUnit(widthUnit)); + builder.append(", vRes: ").append(vRes); builder.append(" "); - builder.append(resUnit(mVResUnit)); + builder.append(resUnit(vResUnit)); builder.append(", height unit: "); - builder.append(dimUnit(mHeightUnit)); + builder.append(dimUnit(heightUnit)); builder.append("]"); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDThumbnail.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDThumbnail.java index be49a19f..7f003301 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDThumbnail.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDThumbnail.java @@ -16,9 +16,9 @@ import java.io.IOException; * @version $Id: PSDThumbnail.java,v 1.0 Jul 29, 2009 4:41:06 PM haraldk Exp$ */ class PSDThumbnail extends PSDImageResource { - private BufferedImage mThumbnail; - private int mWidth; - private int mHeight; + private BufferedImage thumbnail; + private int width; + private int height; public PSDThumbnail(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -50,8 +50,8 @@ class PSDThumbnail extends PSDImageResource { throw new IIOException(String.format("Unsupported thumbnail format (%s) in PSD document", format)); } - mWidth = pInput.readInt(); - mHeight = pInput.readInt(); + width = pInput.readInt(); + height = pInput.readInt(); // This data isn't really useful, unless we're dealing with raw bytes int widthBytes = pInput.readInt(); @@ -59,7 +59,7 @@ class PSDThumbnail extends PSDImageResource { // Consistency check int sizeCompressed = pInput.readInt(); - if (sizeCompressed != (mSize - 28)) { + if (sizeCompressed != (size - 28)) { throw new IIOException("Corrupt thumbnail in PSD document"); } @@ -72,26 +72,26 @@ class PSDThumbnail extends PSDImageResource { // TODO: Defer decoding until getThumbnail? // TODO: Support BGR if id == RES_THUMBNAIL_PS4? Or is that already supported in the JPEG? - mThumbnail = ImageIO.read(IIOUtil.createStreamAdapter(pInput, sizeCompressed)); + thumbnail = ImageIO.read(IIOUtil.createStreamAdapter(pInput, sizeCompressed)); } public final int getWidth() { - return mWidth; + return width; } public final int getHeight() { - return mHeight; + return height; } public final BufferedImage getThumbnail() { - return mThumbnail; + return thumbnail; } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", ").append(mThumbnail); + builder.append(", ").append(thumbnail); builder.append("]"); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDUnicodeAlphaNames.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDUnicodeAlphaNames.java index 6901a8a3..21f752c1 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDUnicodeAlphaNames.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDUnicodeAlphaNames.java @@ -13,7 +13,7 @@ import java.util.List; * @version $Id: PSDUnicodeAlphaNames.java,v 1.0 Nov 7, 2009 9:16:56 PM haraldk Exp$ */ final class PSDUnicodeAlphaNames extends PSDImageResource { - List mNames; + List names; PSDUnicodeAlphaNames(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -21,12 +21,12 @@ final class PSDUnicodeAlphaNames extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mNames = new ArrayList(); + names = new ArrayList(); - long left = mSize; + long left = size; while (left > 0) { String name = PSDUtil.readUnicodeString(pInput); - mNames.add(name); + names.add(name); left -= name.length() * 2 + 4; } } diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDVersionInfo.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDVersionInfo.java index 5e1e7ea2..10210ce8 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDVersionInfo.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDVersionInfo.java @@ -12,11 +12,11 @@ import java.io.IOException; */ final class PSDVersionInfo extends PSDImageResource { - int mVersion; - boolean mHasRealMergedData; - String mWriter; - String mReader; - int mFileVersion; + int version; + boolean hasRealMergedData; + String writer; + String reader; + int fileVersion; PSDVersionInfo(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -32,24 +32,24 @@ final class PSDVersionInfo extends PSDImageResource { 4 bytes file version. */ - mVersion = pInput.readInt(); - mHasRealMergedData = pInput.readBoolean(); + version = pInput.readInt(); + hasRealMergedData = pInput.readBoolean(); - mWriter = PSDUtil.readUnicodeString(pInput); - mReader = PSDUtil.readUnicodeString(pInput); + writer = PSDUtil.readUnicodeString(pInput); + reader = PSDUtil.readUnicodeString(pInput); - mFileVersion = pInput.readInt(); + fileVersion = pInput.readInt(); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - builder.append(", version: ").append(mVersion); - builder.append(", hasRealMergedData: ").append(mHasRealMergedData); - builder.append(", writer: ").append(mWriter); - builder.append(", reader: ").append(mReader); - builder.append(", file version: ").append(mFileVersion); + builder.append(", version: ").append(version); + builder.append(", hasRealMergedData: ").append(hasRealMergedData); + builder.append(", writer: ").append(writer); + builder.append(", reader: ").append(reader); + builder.append(", file version: ").append(fileVersion); builder.append("]"); return builder.toString(); diff --git a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDXMPData.java b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDXMPData.java index 605e78ef..209cdb6b 100644 --- a/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDXMPData.java +++ b/imageio/imageio-psd/src/main/java/com/twelvemonkeys/imageio/plugins/psd/PSDXMPData.java @@ -22,8 +22,8 @@ import java.nio.charset.Charset; * @see Adobe XMP Developer Center */ final class PSDXMPData extends PSDImageResource { - protected byte[] mData; - Directory mDirectory; + protected byte[] data; + Directory directory; PSDXMPData(final short pId, final ImageInputStream pInput) throws IOException { super(pId, pInput); @@ -31,21 +31,21 @@ final class PSDXMPData extends PSDImageResource { @Override protected void readData(final ImageInputStream pInput) throws IOException { - mData = new byte[(int) mSize]; // TODO: Fix potential overflow, or document why that can't happen (read spec) - //pInput.readFully(mData); + data = new byte[(int) size]; // TODO: Fix potential overflow, or document why that can't happen (read spec) + //pInput.readFully(data); - mDirectory = new XMPReader().read(pInput); + directory = new XMPReader().read(pInput); } @Override public String toString() { StringBuilder builder = toStringBuilder(); - int length = Math.min(256, mData.length); - String data = StringUtil.decode(mData, 0, length, "UTF-8").replace('\n', ' ').replaceAll("\\s+", " "); + int length = Math.min(256, data.length); + String data = StringUtil.decode(this.data, 0, length, "UTF-8").replace('\n', ' ').replaceAll("\\s+", " "); builder.append(", data: \"").append(data); - if (length < mData.length) { + if (length < this.data.length) { builder.append("..."); } @@ -60,6 +60,6 @@ final class PSDXMPData extends PSDImageResource { * @return the XMP metadata. */ public Reader getData() { - return new InputStreamReader(new ByteArrayInputStream(mData), Charset.forName("UTF-8")); + return new InputStreamReader(new ByteArrayInputStream(data), Charset.forName("UTF-8")); } } diff --git a/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/JPEGImageReaderTestCase.java b/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/JPEGImageReaderTestCase.java index 8b552a9c..350b4165 100644 --- a/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/JPEGImageReaderTestCase.java +++ b/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/JPEGImageReaderTestCase.java @@ -22,7 +22,7 @@ import java.io.IOException; public class JPEGImageReaderTestCase extends ImageReaderAbstractTestCase { private static final boolean IS_JAVA_6 = SystemUtil.isClassAvailable("java.util.Deque"); - protected JPEGImageReaderSpi mProvider = new JPEGImageReaderSpi(); + protected JPEGImageReaderSpi provider = new JPEGImageReaderSpi(); @Override protected List getTestData() { @@ -33,7 +33,7 @@ public class JPEGImageReaderTestCase extends ImageReaderAbstractTestCase getFormatNames() { - return Arrays.asList(mProvider.getFormatNames()); + return Arrays.asList(provider.getFormatNames()); } @Override protected List getSuffixes() { - return Arrays.asList(mProvider.getFileSuffixes()); + return Arrays.asList(provider.getFileSuffixes()); } @Override protected List getMIMETypes() { - return Arrays.asList(mProvider.getMIMETypes()); + return Arrays.asList(provider.getMIMETypes()); } @Override diff --git a/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/PNGImageReaderTestCase.java b/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/PNGImageReaderTestCase.java index 33719b6c..7fb57ff3 100644 --- a/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/PNGImageReaderTestCase.java +++ b/imageio/imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/PNGImageReaderTestCase.java @@ -19,7 +19,7 @@ import java.util.List; * @version $Id: PNGImageReaderTestCase.java,v 1.0 Oct 9, 2009 3:37:25 PM haraldk Exp$ */ public class PNGImageReaderTestCase extends ImageReaderAbstractTestCase { - protected PNGImageReaderSpi mProvider = new PNGImageReaderSpi(); + protected PNGImageReaderSpi provider = new PNGImageReaderSpi(); @Override protected List getTestData() { @@ -30,7 +30,7 @@ public class PNGImageReaderTestCase extends ImageReaderAbstractTestCase getFormatNames() { - return Arrays.asList(mProvider.getFormatNames()); + return Arrays.asList(provider.getFormatNames()); } @Override protected List getSuffixes() { - return Arrays.asList(mProvider.getFileSuffixes()); + return Arrays.asList(provider.getFileSuffixes()); } @Override protected List getMIMETypes() { - return Arrays.asList(mProvider.getMIMETypes()); + return Arrays.asList(provider.getMIMETypes()); } @Override diff --git a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/Catalog.java b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/Catalog.java index 51a6f288..c791ac29 100755 --- a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/Catalog.java +++ b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/Catalog.java @@ -50,12 +50,12 @@ import java.util.Date; // TODO: Consider moving this one to io.ole2 public final class Catalog implements Iterable { - private final CatalogHeader mHeader; - private final CatalogItem[] mItems; + private final CatalogHeader header; + private final CatalogItem[] items; Catalog(final CatalogHeader pHeader, final CatalogItem[] pItems) { - mHeader = pHeader; - mItems = pItems; + header = pHeader; + items = pItems; } /** @@ -95,32 +95,32 @@ public final class Catalog implements Iterable { } public final int getThumbnailCount() { - return mHeader.mThumbCount; + return header.mThumbCount; } public final int getMaxThumbnailWidth() { - return mHeader.mThumbWidth; + return header.mThumbWidth; } public final int getMaxThumbnailHeight() { - return mHeader.mThumbHeight; + return header.mThumbHeight; } final CatalogItem getItem(final int pIndex) { - return mItems[pIndex]; + return items[pIndex]; } final CatalogItem getItem(final String pName) { - return mItems[getIndex(pName)]; + return items[getIndex(pName)]; } final int getItemId(final int pIndex) { - return mItems[pIndex].getItemId(); + return items[pIndex].getItemId(); } public final int getIndex(final String pName) { - for (int i = 0; i < mItems.length; i++) { - CatalogItem item = mItems[i]; + for (int i = 0; i < items.length; i++) { + CatalogItem item = items[i]; if (item.getName().equals(pName)) { return i; @@ -139,12 +139,12 @@ public final class Catalog implements Iterable { } final String getName(int pItemId) { - return mItems[pItemId - 1].getName(); + return items[pItemId - 1].getName(); } @Override public String toString() { - return String.format("%s[%s]", getClass().getSimpleName(), mHeader); + return String.format("%s[%s]", getClass().getSimpleName(), header); } public Iterator iterator() { @@ -152,11 +152,11 @@ public final class Catalog implements Iterable { int mCurrentIdx; public boolean hasNext() { - return mCurrentIdx < mItems.length; + return mCurrentIdx < items.length; } public CatalogItem next() { - return mItems[mCurrentIdx++]; + return items[mCurrentIdx++]; } public void remove() { diff --git a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java index 67249499..13152c22 100644 --- a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java +++ b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReader.java @@ -64,14 +64,14 @@ import java.util.SortedSet; */ public class ThumbsDBImageReader extends ImageReaderBase { private static final int THUMBNAIL_OFFSET = 12; - private Entry mRoot; - private Catalog mCatalog; + private Entry root; + private Catalog catalog; - private BufferedImage[] mThumbnails; - private final ImageReader mReader; - private int mCurrentImage = -1; + private BufferedImage[] thumbnails; + private final ImageReader reader; + private int currentImage = -1; - private boolean mLoadEagerly; + private boolean loadEagerly; public ThumbsDBImageReader() { this(new ThumbsDBImageReaderSpi()); @@ -79,14 +79,14 @@ public class ThumbsDBImageReader extends ImageReaderBase { protected ThumbsDBImageReader(final ThumbsDBImageReaderSpi pProvider) { super(pProvider); - mReader = createJPEGReader(pProvider); + reader = createJPEGReader(pProvider); initReaderListeners(); } protected void resetMembers() { - mRoot = null; - mCatalog = null; - mThumbnails = null; + root = null; + catalog = null; + thumbnails = null; } private static ImageReader createJPEGReader(final ThumbsDBImageReaderSpi pProvider) { @@ -94,12 +94,12 @@ public class ThumbsDBImageReader extends ImageReaderBase { } public void dispose() { - mReader.dispose(); + reader.dispose(); super.dispose(); } public boolean isLoadEagerly() { - return mLoadEagerly; + return loadEagerly; } /** @@ -113,7 +113,7 @@ public class ThumbsDBImageReader extends ImageReaderBase { * @param pLoadEagerly {@code true} if the reader should read all thumbs on first read */ public void setLoadEagerly(final boolean pLoadEagerly) { - mLoadEagerly = pLoadEagerly; + loadEagerly = pLoadEagerly; } /** @@ -135,19 +135,19 @@ public class ThumbsDBImageReader extends ImageReaderBase { // Quick look-up BufferedImage image = null; - if (pIndex < mThumbnails.length) { - image = mThumbnails[pIndex]; + if (pIndex < thumbnails.length) { + image = thumbnails[pIndex]; } if (image == null) { // Read the image, it's a JFIF stream, inside the OLE 2 CompoundDocument init(pIndex); - image = mReader.read(0, pParam); - mReader.reset(); + image = reader.read(0, pParam); + reader.reset(); if (pParam == null) { - mThumbnails[pIndex] = image; // TODO: Caching is not kosher, as images are mutable!! + thumbnails[pIndex] = image; // TODO: Caching is not kosher, as images are mutable!! } } else { @@ -193,7 +193,7 @@ public class ThumbsDBImageReader extends ImageReaderBase { public BufferedImage read(final String pName, final ImageReadParam pParam) throws IOException { initCatalog(); - int index = mCatalog.getIndex(pName); + int index = catalog.getIndex(pName); if (index < 0) { throw new FileNotFoundException("Name not found in \"Catalog\" entry: " + pName); } @@ -203,39 +203,40 @@ public class ThumbsDBImageReader extends ImageReaderBase { public void abort() { super.abort(); - mReader.abort(); + reader.abort(); } @Override - public void setInput(Object pInput, boolean pSeekForwardOnly, boolean pIgnoreMetadata) { - super.setInput(pInput, pSeekForwardOnly, pIgnoreMetadata); + public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) { + super.setInput(input, seekForwardOnly, ignoreMetadata); if (imageInput != null) { imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN); } } private void init(final int pIndex) throws IOException { - if (mCurrentImage == -1 || pIndex != mCurrentImage || mReader.getInput() == null) { + if (currentImage == -1 || pIndex != currentImage || reader.getInput() == null) { init(); checkBounds(pIndex); - mCurrentImage = pIndex; + currentImage = pIndex; initReader(pIndex); } } private void initReader(final int pIndex) throws IOException { - String name = mCatalog.getStreamName(pIndex); - Entry entry = mRoot.getChildEntry(name); + init(); + String name = catalog.getStreamName(pIndex); + Entry entry = root.getChildEntry(name); // TODO: It might be possible to speed this up, with less wrapping... // Use in-memory input stream for max speed, images are small ImageInputStream input = new MemoryCacheImageInputStream(entry.getInputStream()); input.skipBytes(THUMBNAIL_OFFSET); - mReader.setInput(input); + reader.setInput(input); } private void initReaderListeners() { - mReader.addIIOReadProgressListener(new ProgressListenerBase() { + reader.addIIOReadProgressListener(new ProgressListenerBase() { @Override public void imageComplete(ImageReader pSource) { processImageComplete(); @@ -243,7 +244,7 @@ public class ThumbsDBImageReader extends ImageReaderBase { @Override public void imageStarted(ImageReader pSource, int pImageIndex) { - processImageStarted(mCurrentImage); + processImageStarted(currentImage); } @Override @@ -262,66 +263,66 @@ public class ThumbsDBImageReader extends ImageReaderBase { private void init() throws IOException { assertInput(); - if (mRoot == null) { - mRoot = new CompoundDocument(imageInput).getRootEntry(); - SortedSet children = mRoot.getChildEntries(); + if (root == null) { + root = new CompoundDocument(imageInput).getRootEntry(); + SortedSet children = root.getChildEntries(); - mThumbnails = new BufferedImage[children.size() - 1]; + thumbnails = new BufferedImage[children.size() - 1]; initCatalog(); // NOTE: This is usually slower, unless you need all images // TODO: Use as many threads as there are CPU cores? :-) - if (mLoadEagerly) { - for (int i = 0; i < mThumbnails.length; i++) { + if (loadEagerly) { + for (int i = 0; i < thumbnails.length; i++) { initReader(i); - ImageReader reader = mReader; + ImageReader reader = this.reader; // TODO: If stream was detached, we could probably create a // new reader, then fire this off in a separate thread... - mThumbnails[i] = reader.read(0, null); + thumbnails[i] = reader.read(0, null); } } } } private void initCatalog() throws IOException { - if (mCatalog == null) { - Entry catalog = mRoot.getChildEntry("Catalog"); + if (catalog == null) { + Entry catalog = root.getChildEntry("Catalog"); if (catalog.length() <= 16L) { // TODO: Throw exception? Return empty catalog? } - mCatalog = Catalog.read(catalog.getInputStream()); + this.catalog = Catalog.read(catalog.getInputStream()); } } - public int getNumImages(boolean pAllowSearch) throws IOException { - if (pAllowSearch) { + public int getNumImages(boolean allowSearch) throws IOException { + if (allowSearch) { init(); } - return mCatalog != null ? mCatalog.getThumbnailCount() : super.getNumImages(false); + return catalog != null ? catalog.getThumbnailCount() : super.getNumImages(false); } public int getWidth(int pIndex) throws IOException { init(pIndex); - BufferedImage image = mThumbnails[pIndex]; - return image != null ? image.getWidth() : mReader.getWidth(0); + BufferedImage image = thumbnails[pIndex]; + return image != null ? image.getWidth() : reader.getWidth(0); } public int getHeight(int pIndex) throws IOException { init(pIndex); - BufferedImage image = mThumbnails[pIndex]; - return image != null ? image.getHeight() : mReader.getHeight(0); + BufferedImage image = thumbnails[pIndex]; + return image != null ? image.getHeight() : reader.getHeight(0); } public Iterator getImageTypes(int pIndex) throws IOException { init(pIndex); initReader(pIndex); - return mReader.getImageTypes(0); + return reader.getImageTypes(0); } public boolean isPresent(final String pFileName) { @@ -344,7 +345,7 @@ public class ThumbsDBImageReader extends ImageReaderBase { } extension = extension.toLowerCase(); - return !"psd".equals(extension) && !"svg".equals(extension) && mCatalog != null && mCatalog.getIndex(pFileName) != -1; + return !"psd".equals(extension) && !"svg".equals(extension) && catalog != null && catalog.getIndex(pFileName) != -1; } /// Test code below @@ -357,7 +358,7 @@ public class ThumbsDBImageReader extends ImageReaderBase { if (pArgs.length > 1) { long start = System.currentTimeMillis(); reader.init(); - for (Catalog.CatalogItem item : reader.mCatalog) { + for (Catalog.CatalogItem item : reader.catalog) { reader.read(item.getName(), null); } long end = System.currentTimeMillis(); @@ -371,8 +372,8 @@ public class ThumbsDBImageReader extends ImageReaderBase { long start = System.currentTimeMillis(); reader.init(); - for (Catalog.CatalogItem item : reader.mCatalog) { - addImage(panel, reader, reader.mCatalog.getIndex(item.getName()), item.getName()); + for (Catalog.CatalogItem item : reader.catalog) { + addImage(panel, reader, reader.catalog.getIndex(item.getName()), item.getName()); } long end = System.currentTimeMillis(); System.out.println("Time: " + (end - start) + " ms"); diff --git a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReaderSpi.java b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReaderSpi.java index 362c7559..1c704285 100755 --- a/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReaderSpi.java +++ b/imageio/imageio-thumbsdb/src/main/java/com/twelvemonkeys/imageio/plugins/thumbsdb/ThumbsDBImageReaderSpi.java @@ -49,7 +49,7 @@ import java.util.Locale; * @version $Id: ThumbsDBImageReaderSpi.java,v 1.0 28.feb.2006 19:21:05 haku Exp$ */ public class ThumbsDBImageReaderSpi extends ImageReaderSpi { - private ImageReaderSpi mJPEGProvider; + private ImageReaderSpi jpegProvider; /** * Creates a {@code ThumbsDBImageReaderSpi}. @@ -81,7 +81,7 @@ public class ThumbsDBImageReaderSpi extends ImageReaderSpi { maybeInitJPEGProvider(); // If this is a OLE 2 CompoundDocument, we could try... // TODO: How do we know it's thumbs.db format (structure), without reading quite a lot? - return mJPEGProvider != null && CompoundDocument.canRead(pInput); + return jpegProvider != null && CompoundDocument.canRead(pInput); } public ImageReader createReaderInstance(Object extension) throws IOException { @@ -98,7 +98,7 @@ public class ThumbsDBImageReaderSpi extends ImageReaderSpi { // - Class path lookup of properties file with reader? // This way we could deregister immediately - if (mJPEGProvider == null) { + if (jpegProvider == null) { ImageReaderSpi provider = null; try { Iterator providers = getJPEGProviders(); @@ -117,7 +117,7 @@ public class ThumbsDBImageReaderSpi extends ImageReaderSpi { // In any case, we deregister the provider if there isn't one IIORegistry.getDefaultInstance().deregisterServiceProvider(this, ImageReaderSpi.class); } - mJPEGProvider = provider; + jpegProvider = provider; } } @@ -149,12 +149,12 @@ public class ThumbsDBImageReaderSpi extends ImageReaderSpi { */ ImageReader createJPEGReader() { maybeInitJPEGProvider(); - if (mJPEGProvider == null) { + if (jpegProvider == null) { throw new IllegalStateException("No suitable JPEG reader provider found"); } try { - return mJPEGProvider.createReaderInstance(); + return jpegProvider.createReaderInstance(); } catch (IOException e) { // NOTE: The default Sun version never throws IOException here @@ -170,7 +170,7 @@ public class ThumbsDBImageReaderSpi extends ImageReaderSpi { // public void onRegistration(ServiceRegistry registry, Class category) { // System.out.println("ThumbsDBImageReaderSpi.onRegistration"); // maybeInitJPEGProvider(); -// if (mJPEGProvider == null) { +// if (jpegProvider == null) { // System.out.println("Deregistering"); // registry.deregisterServiceProvider(this, ImageReaderSpi.class); // }