Skip to content
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

GRAPHICS: Add ColorQuantizer class #6379

Merged
merged 2 commits into from
Jan 1, 2025

Conversation

eriktorbjorn
Copy link
Member

This simply moves the new ColorQuantizer class out of the SCUMM engine and into the Graphics namespace where I think it belongs.

The SCUMM engine uses this so that the later Mac versions can present the savegame thumbail (at least 16 bpp) in 256 colors, minus whatever is allocated for the Mac GUI itself. There are several methods of reducing an image down to a palette, but this particular one uses an octree.

I honestly don't know how well it works though it seems fine for the aforementioned thumbnails. But I figured that if it's in Graphics it will be easier for others to reuse and improve on it. I first envisioned it as being part of Surface (which is why I didn't dare to put it in Graphics straight away, because I was worried about conflicts with other changes there. But now it makes more sense to me to have it as its own class, because all the world is not a surface.

The implementation is heavily based on "Color Quantization using Octrees" by Dean Clark, published in - I think - the January 1996 issue of Dr. Dobb's Journal.

This simply moves the new ColorQuantizer class out of the SCUMM engine
and into the Graphics namespace where I think it belongs. It reduces a
potentially large number of colors into a reasonable palette of the
desired size.

The SCUMM engine uses this so that the Mac versions can present the
thumbnail image (which is at least 16 bpp) stored in savegames.
Copy link
Member

@bluegr bluegr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! LGTM

@bluegr
Copy link
Member

bluegr commented Jan 1, 2025

Looks good now, thanks!

@bluegr bluegr merged commit 5d3b85a into scummvm:master Jan 1, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants