fix MxPalette::GetDefaultPalette

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
This commit is contained in:
Joshua Peisach 2023-06-29 17:17:37 -04:00 committed by GitHub
parent db0b0a28ae
commit 63f2215737
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,16 +27,18 @@ MxResult MxPalette::GetEntries(LPPALETTEENTRY p_entries)
void MxPalette::GetDefaultPalette(LPPALETTEENTRY p_entries) void MxPalette::GetDefaultPalette(LPPALETTEENTRY p_entries)
{ {
HDC hdc = GetDC((HWND) NULL); HDC hdc = GetDC((HWND) NULL);
int rasterCaps = GetDeviceCaps(hdc, RASTERCAPS); PALETTEENTRY *src;
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));
}
}
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); ReleaseDC((HWND) NULL, hdc);
} }