-
-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve debug output #1115
Improve debug output #1115
Conversation
Include hex opcode and file offset in debug output. Condense scan line messages in readOpDirectBits().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thanks for taking the time to prepare all these PRs! Much appreciated!
I agree with the main intent of this PR, to clean up the debug output.
However, I need you to fix a few things:
- Set your code style correctly, using 4 spaces as tab/indent, no tabs, 8 spaces continuation indent (but please only reformat the lines you have changed 😀 )
- Remove the outcommented code, we don't need it (I know I have sinned against this myself, but let's make it better)
if (DEBUG) { | ||
System.out.println("--- opCode 0x"+Integer.toHexString(opCode)+" at pos 0x"+Long.toHexString(pStream.getStreamPosition()-2)+" ---"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so fond of the "---" pre-/postfix, keep it clean. 😀
Also, please use System.out.printf
or String.format
instead of the string concatenation. Use %04x
or %08x
as format strings, and skip the toHexString
methods.
// // Line break at the end | ||
// if (DEBUG) { | ||
// System.out.println(); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just remove these line, no need to comment out. We have version control. 😀
if (DEBUG && (scanline<6 || scanline>=srcRect.height-5)) { | ||
if (scanline==5 && srcRect.height>10) { | ||
System.out.println("..."); | ||
} else { | ||
System.out.print("Line " + scanline + ", byteCount: " + packedBytesCount); | ||
System.out.print(" dstBytes: " + dstBytes.length); | ||
System.out.println(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I follow the logic here...
What is the intended output and why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this was just to reduce "noise" from the debug output. And the point of hyphens was so you could see each opcode, see for example following:
Done reading PICT header!
--- opCode 0x1e at pos 0x228 ---
opDefHilite
--- opCode 0x1 at pos 0x22a ---
clipRgn: java.awt.Rectangle[x=0,y=0,width=64,height=64]
--- opCode 0x9a at pos 0x236 ---
directBitsRect, rowBytes: 256, it is a PixMap, bounds: java.awt.Rectangle[x=0,y=0,width=64,height=64], pmVersion: 0, packType: 4, packSize: 0
hRes: 72.0, vRes: 72.0, RGBDirect, pixelSize:32, cmpCount:3, cmpSize:8, srcRect:java.awt.Rectangle[x=0,y=0,width=64,height=64], dstRect:java.awt.Rectangle[x=0,y=0,width=64,height=64], mode: 0
Line 0, byteCount: 4 dstBytes: 192
Line 1, byteCount: 4 dstBytes: 192
Line 2, byteCount: 4 dstBytes: 192
Line 3, byteCount: 4 dstBytes: 192
Line 4, byteCount: 4 dstBytes: 192
...
Line 59, byteCount: 4 dstBytes: 192
Line 60, byteCount: 4 dstBytes: 192
Line 61, byteCount: 4 dstBytes: 192
Line 62, byteCount: 4 dstBytes: 192
Line 63, byteCount: 4 dstBytes: 192
--- opCode 0xff at pos 0x550 ---
Done reading PICT body!
Happy to leave both of these out and follow your preferred style though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I see! :-)
Makes sense. I think however it would be easier to read with something like:
if (DEBUG && (scanline<6 || scanline>=srcRect.height-5)) { | |
if (scanline==5 && srcRect.height>10) { | |
System.out.println("..."); | |
} else { | |
System.out.print("Line " + scanline + ", byteCount: " + packedBytesCount); | |
System.out.print(" dstBytes: " + dstBytes.length); | |
System.out.println(); | |
} | |
if (DEBUG) { | |
if (scanline < 5 || scanline >= srcRect.height - 5) { | |
System.out.print("Line " + scanline + ", byteCount: " + packedBytesCount); | |
System.out.print(" dstBytes: " + dstBytes.length); | |
System.out.println(); | |
} | |
else if (scanline == 5) { | |
// Truncate any remaining scanlines... | |
System.out.println("..."); | |
} | |
} |
Or, with my preferred style these days (this code is old):
if (DEBUG && (scanline<6 || scanline>=srcRect.height-5)) { | |
if (scanline==5 && srcRect.height>10) { | |
System.out.println("..."); | |
} else { | |
System.out.print("Line " + scanline + ", byteCount: " + packedBytesCount); | |
System.out.print(" dstBytes: " + dstBytes.length); | |
System.out.println(); | |
} | |
if (DEBUG) { | |
if (scanline < 5 || scanline >= srcRect.height - 5) { | |
System.out.printf("Line %d, byteCount: %d dstBytes: %d%n", scanline, packedBytesCount, dstBytes.length); | |
} | |
else if (scanline == 5) { | |
// Truncate any remaining scanlines... | |
System.out.println("..."); | |
} | |
} |
// // Line break at the end | ||
// if (DEBUG) { | ||
// System.out.println(); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove it.
@@ -2558,7 +2565,7 @@ private void verboseRegionCmd(String pCmd, Rectangle pBounds, Area pRegion) { | |||
// for (int i = 1; pPolygon != null && i < pPolygon.npoints; i++) { | |||
// System.out.print(", (" + pPolygon.xpoints[i] + "," + pPolygon.ypoints[i] + ")"); | |||
// } | |||
System.out.println(); | |||
// System.out.println(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
@@ -2653,6 +2660,7 @@ public static void main(final String[] pArgs) { | |||
try { | |||
ImageInputStream input = ImageIO.createImageInputStream(file); | |||
String title = file.getName(); | |||
System.out.println("======= "+title+" ======="); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need this.
Ok, I think I've made all these changes but I'm not 100% sure as I'm still not very familiar with GitHub! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reformat the changes according to the code style, and this PR is good! 👍🏻
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
Outdated
Show resolved
Hide resolved
…lugins/pict/PICTImageReader.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said, the code changes in this PR are all good, but the formatting has to match the code style.
It's easier if you just set it up correctly from the start. 😀
But I made it very easy for you now, just accept the suggested changes here from the Github UI (web}.
Update: I figured I could just commit the changes directly, so I did. 😀
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
Outdated
Show resolved
Hide resolved
…lugins/pict/PICTImageReader.java
…lugins/pict/PICTImageReader.java
Great thank you! Like you, I take code formatting very seriously, but I have my own personal style I adhere to. But when checking in changes to existing code the rule is always: follow the existing style :-) |
Include hex opcode and file offset in debug output. Condense scan line messages in readOpDirectBits().