X Tutup
Skip to content

IMAGE: Replace palette byte arrays with Palette class#6447

Merged
bluegr merged 2 commits intoscummvm:masterfrom
OMGPizzaGuy:image-palette
Feb 26, 2025
Merged

IMAGE: Replace palette byte arrays with Palette class#6447
bluegr merged 2 commits intoscummvm:masterfrom
OMGPizzaGuy:image-palette

Conversation

@OMGPizzaGuy
Copy link
Member

These changes expand use of the Graphics::Palette class to the internals for many of the ImageDecoder classes.
The palette clear method is changed from zeroing out the entries to deleting them. I do not believe this method previously in use.
The NeoDecoder was not changed due to more complex uses of a passed in palette variable.
The XBMDecoder was not changed due to the use of a static const palette.

Do we have good method to test these changes? I was able to test BMP with testbed, but I am unsure what other paletted images I can check with.

{
byte *newData = nullptr;
if (newSize > 0) {
newData = new byte[newSize * 3]();
Copy link
Member

@lephilousophe lephilousophe Feb 22, 2025

Choose a reason for hiding this comment

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

It may be interesting to switch to malloc/free and use realloc here.
And maybe adding a flag to ask for old palette preservation: that would avoid a useless copy.

Copy link
Member Author

@OMGPizzaGuy OMGPizzaGuy Feb 25, 2025

Choose a reason for hiding this comment

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

Realloc would handle a copy for us. We could look into switching, but it feels a bit outside the scope of this PR.
I'm not worried about optimizing out an extra copy though; resizing a palette should be a rare occurrence, especially from anything other than of than empty palette.

Copy link
Member

Choose a reason for hiding this comment

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

So adding a flag to ask for preserving the contents could avoid a useless copy

Copy link
Member Author

@OMGPizzaGuy OMGPizzaGuy Feb 25, 2025

Choose a reason for hiding this comment

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

Ok, preserve flag is added.

@bluegr
Copy link
Member

bluegr commented Feb 26, 2025

Nice work, thanks!

The Hopkins commit addresses an issue discussed in PR #6456

@bluegr bluegr merged commit cc0981f into scummvm:master Feb 26, 2025
7 of 8 checks passed
pmandin added a commit to pmandin/scummvm that referenced this pull request Jun 15, 2025
@OMGPizzaGuy OMGPizzaGuy deleted the image-palette branch July 1, 2025 01:46
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

X Tutup