IMAGE: Replace palette byte arrays with Palette class#6447
IMAGE: Replace palette byte arrays with Palette class#6447bluegr merged 2 commits intoscummvm:masterfrom
Conversation
4d167d3 to
0c68a44
Compare
| { | ||
| byte *newData = nullptr; | ||
| if (newSize > 0) { | ||
| newData = new byte[newSize * 3](); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
So adding a flag to ask for preserving the contents could avoid a useless copy
There was a problem hiding this comment.
Ok, preserve flag is added.
0c68a44 to
a26f237
Compare
a26f237 to
b108495
Compare
|
Nice work, thanks! The Hopkins commit addresses an issue discussed in PR #6456 |
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.