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_paletteData = NULL;
this->m_data = NULL;
this->m_bmiColorsProvided = FALSE;
this->m_bitDepth = LOWCOLOR;
this->m_palette = NULL;
}
@ -96,7 +96,7 @@ MxResult MxBitmap::ImportColorsToPalette(RGBQUAD* p_rgbquad, MxPalette* p_palett
}
// 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;
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;
if (!ImportColorsToPalette(m_paletteData, p_palette)) {
if (!vtable3c(p_option)) {
if (!vtable3c(p_bitDepth)) {
ret = SUCCESS;
}
}
@ -235,13 +235,13 @@ MxPalette *MxBitmap::CreatePalette()
pal = NULL;
success = FALSE;
if(this->m_bmiColorsProvided == FALSE) {
if(this->m_bitDepth == LOWCOLOR) {
ppal = new MxPalette(this->m_paletteData);
if (ppal) {
pal = ppal;
}
} else {
if(this->m_bmiColorsProvided != TRUE) {
if(this->m_bitDepth != HIGHCOLOR) {
if(!success && pal) {
delete pal;
}
@ -260,12 +260,12 @@ void MxBitmap::ImportPalette(MxPalette* p_palette)
{
// This is weird but it matches. Maybe m_bmiColorsProvided had more
// potential values than just true/false at some point?
switch (this->m_bmiColorsProvided) {
case FALSE:
switch (this->m_bitDepth) {
case LOWCOLOR:
ImportColorsToPalette(this->m_paletteData, p_palette);
break;
case TRUE:
case HIGHCOLOR:
if (this->m_palette) {
delete this->m_palette;
}
@ -275,17 +275,17 @@ void MxBitmap::ImportPalette(MxPalette* p_palette)
}
// OFFSET: LEGO1 0x100bd2d0
MxResult MxBitmap::vtable3c(MxBool p_option)
MxResult MxBitmap::vtable3c(MxBool p_bitDepth)
{
MxResult ret = FAILURE;
MxPalette *pal = NULL;
if (m_bmiColorsProvided == p_option) {
if (m_bitDepth == p_bitDepth) {
// no change: do nothing.
ret = SUCCESS;
} else {
// TODO: Another switch used for this boolean value? Is it not a bool?
switch (p_option) {
switch (p_bitDepth) {
case 0:
ImportColorsToPalette(m_paletteData, m_palette);
if (m_palette)
@ -306,7 +306,7 @@ MxResult MxBitmap::vtable3c(MxBool p_option)
buf[i] = i;
}
m_bmiColorsProvided = p_option;
m_bitDepth = p_bitDepth;
ret = SUCCESS;
}
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;
}
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];
};
// 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
{
public:
@ -47,7 +51,7 @@ class MxBitmap : public MxCore
BITMAPINFOHEADER *m_bmiHeader; // 0xc
RGBQUAD *m_paletteData; // 0x10
LPVOID *m_data; // 0x14
MxBool m_bmiColorsProvided; // 0x18
MxBool m_bitDepth; // 0x18
MxPalette *m_palette; // 0x1c
};