Fix/match MxBitmap::SetBitDepth

This commit is contained in:
Christian Semmler 2023-12-25 20:54:44 -05:00
parent 77755570f2
commit a25bcecf47
No known key found for this signature in database
GPG key ID: 086DAA1360BEEE5C

View file

@ -296,8 +296,9 @@ MxResult MxBitmap::SetBitDepth(MxBool p_isHighColor)
if (m_isHighColor == p_isHighColor) { if (m_isHighColor == p_isHighColor) {
// no change: do nothing. // no change: do nothing.
ret = SUCCESS; ret = SUCCESS;
goto done;
} }
else {
switch (p_isHighColor) { switch (p_isHighColor) {
case FALSE: case FALSE:
ImportColorsToPalette(m_paletteData, m_palette); ImportColorsToPalette(m_paletteData, m_palette);
@ -306,11 +307,13 @@ MxResult MxBitmap::SetBitDepth(MxBool p_isHighColor)
m_palette = NULL; m_palette = NULL;
break; break;
case TRUE: {
case TRUE:
pal = NULL; pal = NULL;
pal = new MxPalette(m_paletteData); pal = new MxPalette(m_paletteData);
if (pal) {
if (!pal)
goto done;
m_palette = pal; m_palette = pal;
// TODO: what is this? zeroing out top half of palette? // TODO: what is this? zeroing out top half of palette?
@ -318,14 +321,16 @@ MxResult MxBitmap::SetBitDepth(MxBool p_isHighColor)
for (MxU16 i = 0; i < 256; i++) { for (MxU16 i = 0; i < 256; i++) {
buf[i] = i; buf[i] = i;
} }
break;
}
default:
goto done;
}
m_isHighColor = p_isHighColor; m_isHighColor = p_isHighColor;
ret = SUCCESS; ret = SUCCESS;
}
break;
}
}
done:
// If we were unsuccessful overall but did manage to alloc // If we were unsuccessful overall but did manage to alloc
// the MxPalette, free it. // the MxPalette, free it.
if (ret && pal) if (ret && pal)