gbdev / gbdev/rgbds

Allow indexed PLTEs with 4N colors to specify N embedded GBC palettes

Open
#1,067 19 comments 0 reactions 0 assignees View on GitHub
enhancement rgbgfx
Dominant language
C++
Stars
1.6k
Forks
193
Avg merge
22h 17m
Merged PRs (30d)
26

Description

Say I have an indexed image with 16 input colors, and I want each input color to be reduced modulo `2**bit_depth` in the output. For example, input colors 1, 5, 9, and 13 would become 1 in the output. I have relied on this behavior of a different tool in a previous project targeting an 8-bit console with 2bpp character graphics. Would it be reasonable to add `-c modulo`, which is `-c embedded` without the fatal error on an out-of-bounds color value?

If there's no serious objection, I plan to attempt the PR myself.

Test case: `testcase1.png` has 8 colors and uses all 8. `testcase2.png` has 8 colors and uses the first 4; all color index values have been reduced modulo 4. `testcase3.png` has 4 colors. Converting them with `-c modulo` should produce the same character data as converting `testcase3.png` with `-c embedded`. (I've used two of them as test cases for #1064 as well.)

![testcase1](https://user-images.githubusercontent.com/13617183/193051747-5e576855-8b5c-435e-afd1-80c96cda2dd9.png)
![testcase2](https://user-images.githubusercontent.com/13617183/193051749-c1b8b8cf-f47d-42a8-9638-b28cb01c072c.png)
![testcase3](https://user-images.githubusercontent.com/13617183/193051752-34e30f66-8f84-43e1-a3ad-1e63e80a2467.png)

Contributor guide

Open the contributing guide

Research direction

Start at the CLI handling for -c embedded and the tests using testcase1.png, testcase2.png, and testcase3.png. Verify that -c modulo accepts 4N-color indexed PLTEs, reduces indices modulo the bit depth, and produces the same character data as -c embedded for testcase3.png.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.