Define types for the bit depth

That boolean is not really a boolean, its just a variable to store
the bit depth as some DWORD. 0 = 256 color, 1 = High Color (16-bit).
This commit is contained in:
Joshua Peisach 2023-08-18 16:38:56 -04:00
parent 7c4551effe
commit 6542c09754
No known key found for this signature in database
GPG Key ID: 41C3D4189AFEDB5A
2 changed files with 18 additions and 14 deletions

View File

@ -15,7 +15,7 @@ MxBitmap::MxBitmap()
this->m_bmiHeader = NULL; this->m_bmiHeader = NULL;
this->m_paletteData = NULL; this->m_paletteData = NULL;
this->m_data = NULL; this->m_data = NULL;
this->m_bmiColorsProvided = FALSE; this->m_bitDepth = LOWCOLOR;
this->m_palette = NULL; this->m_palette = NULL;
} }
@ -96,7 +96,7 @@ MxResult MxBitmap::ImportColorsToPalette(RGBQUAD* p_rgbquad, MxPalette* p_palett
} }
// OFFSET: LEGO1 0x100bcaa0 // OFFSET: LEGO1 0x100bcaa0
MxResult MxBitmap::vtable1c(int p_width, int p_height, MxPalette *p_palette, int p_option) MxResult MxBitmap::vtable1c(int p_width, int p_height, MxPalette *p_palette, int p_bitDepth)
{ {
MxResult ret = FAILURE; MxResult ret = FAILURE;
MxLong size = ((p_width + 3) & -4) * p_height; MxLong size = ((p_width + 3) & -4) * p_height;
@ -118,7 +118,7 @@ MxResult MxBitmap::vtable1c(int p_width, int p_height, MxPalette *p_palette, int
m_bmiHeader->biSizeImage = size; m_bmiHeader->biSizeImage = size;
if (!ImportColorsToPalette(m_paletteData, p_palette)) { if (!ImportColorsToPalette(m_paletteData, p_palette)) {
if (!vtable3c(p_option)) { if (!vtable3c(p_bitDepth)) {
ret = SUCCESS; ret = SUCCESS;
} }
} }
@ -235,13 +235,13 @@ MxPalette *MxBitmap::CreatePalette()
pal = NULL; pal = NULL;
success = FALSE; success = FALSE;
if(this->m_bmiColorsProvided == FALSE) { if(this->m_bitDepth == LOWCOLOR) {
ppal = new MxPalette(this->m_paletteData); ppal = new MxPalette(this->m_paletteData);
if (ppal) { if (ppal) {
pal = ppal; pal = ppal;
} }
} else { } else {
if(this->m_bmiColorsProvided != TRUE) { if(this->m_bitDepth != HIGHCOLOR) {
if(!success && pal) { if(!success && pal) {
delete pal; delete pal;
} }
@ -260,12 +260,12 @@ void MxBitmap::ImportPalette(MxPalette* p_palette)
{ {
// This is weird but it matches. Maybe m_bmiColorsProvided had more // This is weird but it matches. Maybe m_bmiColorsProvided had more
// potential values than just true/false at some point? // potential values than just true/false at some point?
switch (this->m_bmiColorsProvided) { switch (this->m_bitDepth) {
case FALSE: case LOWCOLOR:
ImportColorsToPalette(this->m_paletteData, p_palette); ImportColorsToPalette(this->m_paletteData, p_palette);
break; break;
case TRUE: case HIGHCOLOR:
if (this->m_palette) { if (this->m_palette) {
delete this->m_palette; delete this->m_palette;
} }
@ -275,17 +275,17 @@ void MxBitmap::ImportPalette(MxPalette* p_palette)
} }
// OFFSET: LEGO1 0x100bd2d0 // OFFSET: LEGO1 0x100bd2d0
MxResult MxBitmap::vtable3c(MxBool p_option) MxResult MxBitmap::vtable3c(MxBool p_bitDepth)
{ {
MxResult ret = FAILURE; MxResult ret = FAILURE;
MxPalette *pal = NULL; MxPalette *pal = NULL;
if (m_bmiColorsProvided == p_option) { if (m_bitDepth == p_bitDepth) {
// no change: do nothing. // no change: do nothing.
ret = SUCCESS; ret = SUCCESS;
} else { } else {
// TODO: Another switch used for this boolean value? Is it not a bool? // TODO: Another switch used for this boolean value? Is it not a bool?
switch (p_option) { switch (p_bitDepth) {
case 0: case 0:
ImportColorsToPalette(m_paletteData, m_palette); ImportColorsToPalette(m_paletteData, m_palette);
if (m_palette) if (m_palette)
@ -306,7 +306,7 @@ MxResult MxBitmap::vtable3c(MxBool p_option)
buf[i] = i; buf[i] = i;
} }
m_bmiColorsProvided = p_option; m_bitDepth = p_bitDepth;
ret = SUCCESS; ret = SUCCESS;
} }
break; break;
@ -329,5 +329,5 @@ MxResult MxBitmap::CopyColorData(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest,
p_ySrc = (this->m_bmiHeader->biHeight - p_destHeight) - p_ySrc; p_ySrc = (this->m_bmiHeader->biHeight - p_destHeight) - p_ySrc;
} }
return StretchDIBits(p_hdc, p_xDest, p_yDest, p_destWidth, p_destHeight, p_xSrc, p_ySrc, p_destWidth, p_destHeight, this->m_data, (BITMAPINFO*)this->m_info, this->m_bmiColorsProvided, SRCCOPY); return StretchDIBits(p_hdc, p_xDest, p_yDest, p_destWidth, p_destHeight, p_xSrc, p_ySrc, p_destWidth, p_destHeight, this->m_data, (BITMAPINFO*)this->m_info, this->m_bitDepth, SRCCOPY);
} }

View File

@ -21,6 +21,10 @@ struct MxBITMAPINFO {
RGBQUAD bmiColors[256]; RGBQUAD bmiColors[256];
}; };
// These values are the bit depth, set in the registry
#define LOWCOLOR 0 // 256 color
#define HIGHCOLOR 1 // High Color (16-bit)
class MxBitmap : public MxCore class MxBitmap : public MxCore
{ {
public: public:
@ -47,7 +51,7 @@ class MxBitmap : public MxCore
BITMAPINFOHEADER *m_bmiHeader; // 0xc BITMAPINFOHEADER *m_bmiHeader; // 0xc
RGBQUAD *m_paletteData; // 0x10 RGBQUAD *m_paletteData; // 0x10
LPVOID *m_data; // 0x14 LPVOID *m_data; // 0x14
MxBool m_bmiColorsProvided; // 0x18 MxBool m_bitDepth; // 0x18
MxPalette *m_palette; // 0x1c MxPalette *m_palette; // 0x1c
}; };