From eae19c84757426685a3456a211fa23546404047c Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Wed, 12 Jul 2023 21:07:54 -0400 Subject: [PATCH] Match MxBitmap::vtable+40 (CopyColorData) It's basically a call to StretchDIBits, which copies color data for a rectangle --- LEGO1/mxbitmap.cpp | 12 +++++++++--- LEGO1/mxbitmap.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/LEGO1/mxbitmap.cpp b/LEGO1/mxbitmap.cpp index 6ad26f94..d7185c71 100644 --- a/LEGO1/mxbitmap.cpp +++ b/LEGO1/mxbitmap.cpp @@ -122,8 +122,14 @@ int MxBitmap::vtable3c(MxBool) return 0; } -// OFFSET: LEGO1 0x100bd3e0 STUB -int MxBitmap::vtable40(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight) +// OFFSET: LEGO1 0x100bd3e0 +MxResult MxBitmap::CopyColorData(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight) { - return 0; + // Compression fix? + if ((this->m_bmiHeader->biCompression != 16) && (0 < this->m_bmiHeader->biHeight)) { + p_ySrc = (this->m_bmiHeader->biHeight - p_destHeight) - p_ySrc; + } + // TODO: 0xcc0020 is probably a common raster code variable + // see https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-bitblt#parameters + return StretchDIBits(p_hdc, p_xDest, p_yDest, p_destWidth, p_destHeight, p_xSrc, p_ySrc, p_destWidth, p_destHeight, this->m_data, this->m_info, this->m_unk18, 0xcc0020); } \ No newline at end of file diff --git a/LEGO1/mxbitmap.h b/LEGO1/mxbitmap.h index 66550f7e..b6886d51 100644 --- a/LEGO1/mxbitmap.h +++ b/LEGO1/mxbitmap.h @@ -24,7 +24,7 @@ class MxBitmap : public MxCore __declspec(dllexport) virtual MxPalette *CreatePalette(); // vtable+34 virtual void vtable38(void*); virtual int vtable3c(MxBool); - virtual int vtable40(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight); + virtual MxResult MxBitmap::CopyColorData(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight); // vtable+40 private: BITMAPINFO *m_info;