steffest / DPaint-js

Webbased image editor, modeled after the legendary Deluxe Paint with a focus on retro Amiga file formats: read and write Amiga icon files and IFF ILBM images
https://www.stef.be/dpaint/
MIT License
481 stars 28 forks source link

Concept code: fix PBM image loading #13

Closed michaelshmitty closed 1 year ago

michaelshmitty commented 1 year ago

Hi Stef!

This includes some code that fixes loading PBM image type files. I tried to isolate the code as much as possible so you can decide how much of it you want to use / merge.

Like ILBM, PBM files use the IFF format but have the PBM FORM chunk identifier instead of ILBM. (Note the space in PBM as the FORM chunk identifiers seem to adhere to a standard length of 4 bytes.)

From what I can tell PBM is used by the PC version of Deluxe Paint because the hardware did not support some of the more advanced ILBM features. I ran into this problem when trying to load some of Mark Ferrari (of LucasFilm fame)'s original artwork.

Compressed PBM before the fix

Screenshot 2023-06-04 at 21 22 50

Compressed example after the fix

Screenshot 2023-06-04 at 21 21 24

Uncompressed example before the fix

Screenshot 2023-06-04 at 21 23 10

Uncompressed example after the fix

Screenshot 2023-06-04 at 21 20 53

I can get you the original files for testing if you want. I don't want to post them here.

In order to better understand and attempt to fix the problem I made an isolated PBM-js library that only parses PBM files. It also supports color cycling, albeit not in a very optimal way.

Note about linting I've added ESLint as a dev dependency to the project and applied it to the files I've worked on in this PR. Some informational console.log statements got removed as well as some unused variables. Whitespace got adjusted as well. I did override the default of 2 spaces tabs to 4 spaces tabs to honor that convention in this project. The linter also reported an error here: https://github.com/steffest/DPaint-js/blob/master/_script/fileformats/iff.js#L276 AdfViewer is undefined and I wasn't able to find any reference to it in the code.

The linting stuff is in a completely separate commit so feel free to ignore that if you want!

Cheers and thanks for this awesome project! Michael

steffest commented 1 year ago

Awesome! Thanks! I was busy implementing the color cycling part, including how to edit them in the color palette so this is a perfect combo. Thanks again. GREATLY appreciated!

steffest commented 1 year ago

Wheeh! Look at those cycles going ! :-)

https://github.com/steffest/DPaint-js/assets/763047/4d518a28-011d-4373-b9a2-e13786b63e92

michaelshmitty commented 1 year ago

Wheeh! Look at those cycles going ! :-) 2023-06-05.09-57-51.mp4

Ooooh nice!