fuzziqersoftware / resource_dasm

Classic Mac OS resource fork and application disassembler, with reverse-engineering tools for specific applications
MIT License
114 stars 13 forks source link

Incorrect canvas size for some PICTs #72

Closed Iritscen closed 1 year ago

Iritscen commented 1 year ago

Thanks for these great tools, I'm glad I found them! I used resource_dasm to extract the resources from the DOCMaker readme for Marathon Infinity and convert its PICTs, but the tool got tripped up converting a couple of the resources, attached. As you'll see, the resulting bitmaps seem to contain only the top-left quadrant of the original image. I've called this an "incorrect canvas size" in the issue title; not sure if that's an accurate description of the problem.

P.S.: Almost all of the other PICT resources in the app fail conversion with the error "(subheader has incorrect version (00000000 or 0000)); attempting rendering using picttoppm", however picttoppm converts them correctly. Do you want me to open another issue with samples of those problem PICTs, or is it considered acceptable behavior to punt those to picttoppm since it handles the resources successfully?

badpicts.zip

fuzziqersoftware commented 1 year ago

Thanks for the report - this is fixed in revision 76682958. The issue was that in PICT command 0C00 (extended header), we didn't change the canvas size if the extended header specified a different size than the main header. This seems to be a fairly rare case, but fixing it corrects about 120 PICTs in my testing dataset, which is a notable improvement.

fuzziqersoftware commented 1 year ago

Ah, I missed the second part - yeah, for the other PICTs that fail completely, please upload them here and I'll take a look.

Iritscen commented 1 year ago

Sure, here you go. Three of these PICTs actually fail conversion in picttoppm too. And yet all of them QuickLook correctly in the Finder and can be opened in Preview!

worsepicts.zip

fuzziqersoftware commented 1 year ago

Thanks - looks like these all have invalid extended headers. I guess QuickDraw just ignores the extended header if its version field has an incorrect value in it, so I made resource_dasm do the same (revision da55fe54) and now all of these render properly.

fuzziqersoftware commented 1 year ago

Feel free to reopen this issue if you find more PICTs that don't work - one of the goals of this project is maximum compatibility.