{"id":18191141,"url":"https://github.com/issotm/no-packsaran","last_synced_at":"2025-04-07T15:22:01.348Z","repository":{"id":252317528,"uuid":"839901251","full_name":"ISSOtm/no-packsaran","owner":"ISSOtm","description":"A program to generate images that defeat naive palette packing algorithms","archived":false,"fork":false,"pushed_at":"2024-08-08T23:33:51.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T17:53:23.783Z","etag":null,"topics":["game-boy-advance","game-boy-color","gameboy-advance","gameboy-color","genesis","mega-drive","megadrive","pc-engine","pcengine","super-nes","super-nintendo","super-nintendo-entertainment-system","turbografx-16","wonderswan","wonderswan-color"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ISSOtm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-08T14:52:07.000Z","updated_at":"2024-08-10T20:30:28.000Z","dependencies_parsed_at":"2024-08-09T01:28:11.285Z","dependency_job_id":"523db5e8-5049-49d9-96f9-6bd1ea12e2bc","html_url":"https://github.com/ISSOtm/no-packsaran","commit_stats":null,"previous_names":["issotm/no-packsaran"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISSOtm%2Fno-packsaran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISSOtm%2Fno-packsaran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISSOtm%2Fno-packsaran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISSOtm%2Fno-packsaran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ISSOtm","download_url":"https://codeload.github.com/ISSOtm/no-packsaran/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675597,"owners_count":20977378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game-boy-advance","game-boy-color","gameboy-advance","gameboy-color","genesis","mega-drive","megadrive","pc-engine","pcengine","super-nes","super-nintendo","super-nintendo-entertainment-system","turbografx-16","wonderswan","wonderswan-color"],"created_at":"2024-11-03T05:03:10.165Z","updated_at":"2025-04-07T15:22:01.323Z","avatar_url":"https://github.com/ISSOtm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# No Packsaran!\n\nA program to make images that are hard to generate palettes for.\n\n(See the [Acknowledgements](#acknowledgements) below for a link to a packing algorithm that processes them with flying colours (pun intended))\n\n## Context and Motivation\n\nOlder game consoles often can't display images containing “raw” pixel values, instead relying on the creation of several “colour palettes” that get applied to portions to the image.\nComplicating matters is that said consoles often could only contain few of these palettes.\n\nWhile the transformation from the latter to the former is trivial, which makes rendering simple, the inverse operation is difficult (and sometimes outright impossible within the consoles' constraints).\n\n\u003e [!TIP]\n\u003e The problem is a generalisation of bin-packing, which has been proven to be NP-hard.\n\u003e \n\u003e In layman's terms: there are many images for which calculating the smallest number of palettes necessary to render it takes a *lot* of time.\n\nNonetheless, many programs have been developed over the years that attempt to tackle this exact problem, so that people can make games for those consoles.\n(Two examples of those are RGBGFX, part of [RGBDS]; and [SuperFamiconv]).\nThese programs use various algorithms to try packing palettes, often naive ones.\n\nThe goal of **No Packsaran!** is to help spread awareness that these algorithms can be flawed, [including by seemingly innocuous images](https://github.com/Rangi42/tilemap-studio/issues/86).\n\nPlease don't use these to shame any of the tools' authors!\nInstead, send them a PR that improve the packing algorithm—I'm sure that would make them happy :)\n\n## How to use\n\nThis program is written in [Rust], so you'll need that.\nOnce Cargo is set up, the usual `cargo run` command (from your terminal) will get you started; use `cargo run -- --help` to obtain the CLI help.\n\nAlternatively, these are the two images that get generated with default settings:\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003ecargo run -- any_fit\u003c/code\u003e\u003c/summary\u003e\n\n![any_fit image](any_fit.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003ecargo run -- best_fusion\u003c/code\u003e\u003c/summary\u003e\n\n![best_fusion image](best_fusion.png)\n\n\u003c/details\u003e\n\nIf you need different settings (currently, the bit depth and size of the tiles can be changed), you will have to run the program yourself.\n\n## Acknowledgements\n\nThe techniques implemented in this program are described in the paper [Algorithms for the Pagination Problem, a Bin Packing with Overlapping Items](https://arxiv.org/abs/1605.00558), by Aristide Grange, Imed Kacem, and Sébastien Martin.\n\nThat paper also contains an algorithm, Overload-And-Remove, that can be implemented [without too much difficulty](https://github.com/gbdev/rgbds/blob/fb6f861a08231f26d386e21b4a434f645ae3b357/src/gfx/pal_packing.cpp#L355-L537), and performs much better than the usual greedy algorithms, while remaining fast.\n\n## License\n\nThis program is licensed under the GNU Affero General Public License v3.0 or, at your option, any later version.\n\n![AGPLv3 logo](https://www.gnu.org/graphics/agplv3-with-text-162x68.png)\n\nCopyright 2024, Eldred “ISSOtm” Habert.\nFeel free to reach me at my commit email for any questions.\n\n[RGBDS]: https://rgbds.gbdev.io\n[Rust]: https://rust-lang.org\n[SuperFamiconv]: https://github.com/Optiroc/SuperFamiconv#readme\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fissotm%2Fno-packsaran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fissotm%2Fno-packsaran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fissotm%2Fno-packsaran/lists"}