GRAPHICS: Add ColorQuantizer class #6379
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofSurface
(which is why I didn't dare to put it inGraphics
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.