[Scummvm-git-logs] scummvm master -> a39a752663dfd748e15a78813e2d5c5572e88a9d
dreammaster
noreply at scummvm.org
Thu Oct 23 10:15:16 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
a39a752663 BAGEL: MINIGAMES: Simplify CreateDIBPalette
Commit: a39a752663dfd748e15a78813e2d5c5572e88a9d
https://github.com/scummvm/scummvm/commit/a39a752663dfd748e15a78813e2d5c5572e88a9d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-10-23T03:15:08-07:00
Commit Message:
BAGEL: MINIGAMES: Simplify CreateDIBPalette
Changed paths:
engines/bagel/hodjnpodj/hnplibs/dibapi.cpp
engines/bagel/mfc/afxwin.h
engines/bagel/mfc/palette.cpp
diff --git a/engines/bagel/hodjnpodj/hnplibs/dibapi.cpp b/engines/bagel/hodjnpodj/hnplibs/dibapi.cpp
index 7e7bfbca633..385f0719b3d 100644
--- a/engines/bagel/hodjnpodj/hnplibs/dibapi.cpp
+++ b/engines/bagel/hodjnpodj/hnplibs/dibapi.cpp
@@ -182,8 +182,6 @@ bool PaintDIB(HDC hDC, LPRECT lpDCRect, HDIB hDIB,
bool CreateDIBPalette(HDIB hDIB, CPalette *pPal) {
uint16 wNumColors;
- HANDLE hLogPal;
- LPLOGPALETTE lpPal;
bool bResult = false;
// If handle to DIB is invalid, return false
@@ -195,32 +193,7 @@ bool CreateDIBPalette(HDIB hDIB, CPalette *pPal) {
if (wNumColors != 0) {
const Graphics::Palette *pal = hDIB->grabPalette();
-
- // Allocate memory block for logical palette
- hLogPal = GlobalAlloc(GPTR, sizeof(LOGPALETTE)
- + sizeof(PALETTEENTRY)
- * wNumColors);
- assert(hLogPal);
-
- lpPal = (LPLOGPALETTE) GlobalLock((HGLOBAL)hLogPal);
-
- // Set version and number of palette entries
- lpPal->palVersion = PALVERSION;
- lpPal->palNumEntries = wNumColors;
-
- for (uint i = 0; i < wNumColors; i++) {
- pal->get(i,
- lpPal->palPalEntry[i].peRed,
- lpPal->palPalEntry[i].peGreen,
- lpPal->palPalEntry[i].peBlue);
- lpPal->palPalEntry[i].peFlags = 0;
- }
-
- // Create the palette and get handle to it
- bResult = pPal->CreatePalette(lpPal);
-
- GlobalUnlock((HGLOBAL)hLogPal);
- GlobalFree((HGLOBAL)hLogPal);
+ bResult = pPal->SetPaletteEntries(*pal);
}
return bResult;
diff --git a/engines/bagel/mfc/afxwin.h b/engines/bagel/mfc/afxwin.h
index b5102e0791d..0726c039387 100644
--- a/engines/bagel/mfc/afxwin.h
+++ b/engines/bagel/mfc/afxwin.h
@@ -667,6 +667,7 @@ public:
struct Impl : public CGdiObjectImpl,
public Graphics::Palette {
Impl(const LPLOGPALETTE pal);
+ Impl(const Graphics::Palette &pal);
~Impl() override {}
};
diff --git a/engines/bagel/mfc/palette.cpp b/engines/bagel/mfc/palette.cpp
index 9c9b8c0140a..cb4deeaa5bd 100644
--- a/engines/bagel/mfc/palette.cpp
+++ b/engines/bagel/mfc/palette.cpp
@@ -88,8 +88,12 @@ unsigned int CPalette::SetPaletteEntries(unsigned int nStartIndex, unsigned int
}
unsigned int CPalette::SetPaletteEntries(const Graphics::Palette &pal) {
- Graphics::Palette *impl = static_cast<Impl *>(m_hObject);
- *impl = pal;
+ DeleteObject();
+ m_hObject = new Impl(pal);
+
+ // This is where it becomes permanent
+ AfxHookObject();
+
return pal.size();
}
@@ -128,5 +132,9 @@ CPalette::Impl::Impl(const LPLOGPALETTE pal) :
}
}
+CPalette::Impl::Impl(const Graphics::Palette &pal) :
+ CGdiObjectImpl(), Graphics::Palette(pal) {
+}
+
} // namespace MFC
} // namespace Bagel
More information about the Scummvm-git-logs
mailing list