Improve debug output (#1115)

Include hex opcode and file offset in debug output. Condense scan line messages in readOpDirectBits().

---------

Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
This commit is contained in:
Rolf Howarth 2025-03-31 21:38:09 +02:00 committed by GitHub
parent 8989ba07d8
commit f8b919ee58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -392,6 +392,9 @@ public final class PICTImageReader extends ImageReaderBase {
} }
opCode = pStream.readUnsignedShort(); opCode = pStream.readUnsignedShort();
} }
if (DEBUG) {
System.out.printf("opCode 0x%04x at pos %08x:\n", opCode, pStream.getStreamPosition() - 2);
}
// See what we got and react in consequence // See what we got and react in consequence
switch (opCode) { switch (opCode) {
@ -1876,11 +1879,6 @@ public final class PICTImageReader extends ImageReaderBase {
srcRect.setLocation(0, 0); // Raster always start at 0,0 srcRect.setLocation(0, 0); // Raster always start at 0,0
context.copyBits(img, srcRect, dstRect, transferMode, region); context.copyBits(img, srcRect, dstRect, transferMode, region);
} }
// Line break at the end
if (DEBUG) {
System.out.println();
}
} }
/** /**
@ -2074,10 +2072,16 @@ public final class PICTImageReader extends ImageReaderBase {
} }
if (DEBUG) { if (DEBUG) {
if (scanline < 5 || scanline >= srcRect.height - 5) {
System.out.print("Line " + scanline + ", byteCount: " + packedBytesCount); System.out.print("Line " + scanline + ", byteCount: " + packedBytesCount);
System.out.print(" dstBytes: " + dstBytes.length); System.out.print(" dstBytes: " + dstBytes.length);
System.out.println(); System.out.println();
} }
else if (scanline == 5) {
// Truncate any remaining scanlines...
System.out.println("...");
}
}
// Unpack them all // Unpack them all
Decoder decoder = packType == 3 ? new PackBitsDecoder(2, false) : new PackBitsDecoder(); Decoder decoder = packType == 3 ? new PackBitsDecoder(2, false) : new PackBitsDecoder();
@ -2189,11 +2193,6 @@ public final class PICTImageReader extends ImageReaderBase {
srcRect.setLocation(0, 0); // Raster always starts at 0,0 srcRect.setLocation(0, 0); // Raster always starts at 0,0
context.copyBits(img, srcRect, dstRect, transferMode, region); context.copyBits(img, srcRect, dstRect, transferMode, region);
} }
// Line break at the end
if (DEBUG) {
System.out.println();
}
} }
/* /*
@ -2558,7 +2557,6 @@ public final class PICTImageReader extends ImageReaderBase {
// for (int i = 1; pPolygon != null && i < pPolygon.npoints; i++) { // for (int i = 1; pPolygon != null && i < pPolygon.npoints; i++) {
// System.out.print(", (" + pPolygon.xpoints[i] + "," + pPolygon.ypoints[i] + ")"); // System.out.print(", (" + pPolygon.xpoints[i] + "," + pPolygon.ypoints[i] + ")");
// } // }
System.out.println();
} }
@Override @Override
@ -2653,6 +2651,7 @@ public final class PICTImageReader extends ImageReaderBase {
try { try {
ImageInputStream input = ImageIO.createImageInputStream(file); ImageInputStream input = ImageIO.createImageInputStream(file);
String title = file.getName(); String title = file.getName();
System.out.println("Processing " + file);
System.out.println("canRead: " + reader.getOriginatingProvider().canDecodeInput(input)); System.out.println("canRead: " + reader.getOriginatingProvider().canDecodeInput(input));
@ -2668,9 +2667,11 @@ public final class PICTImageReader extends ImageReaderBase {
showIt(image, title); showIt(image, title);
System.out.println("image = " + image); System.out.println("image = " + image);
System.out.println();
} }
catch (IOException e) { catch (IOException e) {
System.err.println("Could not read " + file.getAbsolutePath() + ": " + e); System.err.println("Could not read " + file.getAbsolutePath() + ": " + e);
e.printStackTrace();
} }
} }
} }