mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-01 00:00:02 -04:00
New code style. No functional changes.
This commit is contained in:
+167
-164
@@ -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<BufferedImage> mImages = new ArrayList<BufferedImage>();
|
||||
private long mImageStartStreamPos;
|
||||
protected int mPicSize;
|
||||
private List<BufferedImage> images = new ArrayList<BufferedImage>();
|
||||
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);
|
||||
// }
|
||||
|
||||
+2
-1
@@ -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) {
|
||||
|
||||
+28
-28
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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.<RenderingHints.Key, Object>emptyMap())
|
||||
@@ -59,6 +59,6 @@ abstract class Pattern implements Paint {
|
||||
}
|
||||
|
||||
public int getTransparency() {
|
||||
return mPaint.getTransparency();
|
||||
return paint.getTransparency();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+57
-58
@@ -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
|
||||
|
||||
+5
-5
@@ -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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user