From 63f2215737d3bcd286f67dcf1a04fdf8a234d41b Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Thu, 29 Jun 2023 17:17:37 -0400 Subject: [PATCH] fix MxPalette::GetDefaultPalette Co-authored-by: Anonymous Maarten --- LEGO1/mxpalette.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/LEGO1/mxpalette.cpp b/LEGO1/mxpalette.cpp index 7e0de560..668ff908 100644 --- a/LEGO1/mxpalette.cpp +++ b/LEGO1/mxpalette.cpp @@ -27,16 +27,18 @@ MxResult MxPalette::GetEntries(LPPALETTEENTRY p_entries) void MxPalette::GetDefaultPalette(LPPALETTEENTRY p_entries) { HDC hdc = GetDC((HWND) NULL); - int rasterCaps = GetDeviceCaps(hdc, RASTERCAPS); - if ((rasterCaps & RC_PALETTE) != 0) { - int paletteSize = GetDeviceCaps(hdc, SIZEPALETTE); - if (paletteSize == 256) { - GetSystemPaletteEntries(hdc, 0, 256, p_entries); - p_entries += 10; - memcpy(p_entries, this->m_entries, sizeof(this->m_entries)); - } + PALETTEENTRY *src; + + if ((rasterCaps & RC_PALETTE) != 0 && GetDeviceCaps(hdc, SIZEPALETTE) == 256) { + GetSystemPaletteEntries(hdc, 0, 256, p_entries); + count = 256 - 2 * 10; + src = &g_defaultPalette[10]; + p_entries += 10; + } else { + src = g_defaultPalette; + count = 256; } - + memcpy(dest, p_entries, count * sizeof(PALETTEENTRY)); ReleaseDC((HWND) NULL, hdc); }