From 80176b02f978fe15b87c98ba871f7ca048d368de Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 4 Jan 2025 00:05:09 +0100 Subject: [PATCH] . --- source/3_image.cpp | 13 +++++++++++-- source/9_image.cpp | 10 +++++++++- source/w_image.cpp | 8 +++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/source/3_image.cpp b/source/3_image.cpp index ad2e043..f31d89f 100644 --- a/source/3_image.cpp +++ b/source/3_image.cpp @@ -19,7 +19,7 @@ #include "ui_win.hpp" -#include +//#include // -------------------------------------------------------------------------- // ----- UIW_IMAGE ---------------------------------------------------------- @@ -203,6 +203,8 @@ int UIW_IMAGE::LoadImageFromFile(void) // Load the bitmap. ZIL_UINT32 dibSize = bitmapFileHeader.bfSize - sizeof(BITMAPFILEHEADER); ZIL_UINT32 tdibSize = dibSize; +#define GlobalAllocPtr(flags, cb) \ + (GlobalLock(GlobalAlloc((flags), (cb)))) ZIL_UINT8 *dib = (ZIL_UINT8 *)GlobalAllocPtr(GMEM_MOVEABLE, dibSize); ZIL_UINT8 *tdib = dib; for ( ; dibSize; dibSize -= tdibSize, tdib += tdibSize) @@ -222,7 +224,14 @@ int UIW_IMAGE::LoadImageFromFile(void) ReleaseDC(NULL, hDC); // Clean up. - GlobalFreePtr(dib); +#define GlobalPtrHandle(lp) \ + ((HGLOBAL)LOWORD(GlobalHandle(HIWORD(lp)))) +#define GlobalUnlockPtr(lp) \ + GlobalUnlock(GlobalPtrHandle(lp)) +#define GlobalFreePtr(lp) \ + (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp))) + GlobalUnlockPtr(dib); + GlobalFree(LOWORD(GlobalHandle(HIWORD(dib)))); delete bitmapInfo; woStatus &= ~WOS_READ_ERROR; return (image ? TRUE : FALSE); diff --git a/source/9_image.cpp b/source/9_image.cpp index f360e30..eb8bcdb 100644 --- a/source/9_image.cpp +++ b/source/9_image.cpp @@ -19,7 +19,7 @@ #include "ui_win.hpp" -#include +//#include // -------------------------------------------------------------------------- // ----- UIW_IMAGE ---------------------------------------------------------- @@ -202,6 +202,8 @@ int UIW_IMAGE::LoadImageFromFile(void) // Load the bitmap. ZIL_UINT32 dibSize = bitmapFileHeader.bfSize - sizeof(BITMAPFILEHEADER); ZIL_UINT32 tdibSize = dibSize; +#define GlobalAllocPtr(flags, cb) \ + (GlobalLock(GlobalAlloc((flags), (cb)))) ZIL_UINT8 *dib = (ZIL_UINT8 *)GlobalAllocPtr(GMEM_MOVEABLE, dibSize); ZIL_UINT8 *tdib = dib; for ( ; dibSize; dibSize -= tdibSize, tdib += tdibSize) @@ -221,6 +223,12 @@ int UIW_IMAGE::LoadImageFromFile(void) ReleaseDC(NULL, hDC); // Clean up. +#define GlobalPtrHandle(lp) \ + ((HGLOBAL)LOWORD(GlobalHandle(HIWORD(lp)))) +#define GlobalUnlockPtr(lp) \ + GlobalUnlock(GlobalPtrHandle(lp)) +#define GlobalFreePtr(lp) \ + (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp))) GlobalFreePtr(dib); delete bitmapInfo; woStatus &= ~WOS_READ_ERROR; diff --git a/source/w_image.cpp b/source/w_image.cpp index a94909d..19e0958 100644 --- a/source/w_image.cpp +++ b/source/w_image.cpp @@ -3,10 +3,14 @@ // Zinc Software Incorporated. Pleasant Grove, Utah USA #include "ui_win.hpp" -#include +//#include #if defined(__WATCOMC__) #undef GlobalFreePtr +#define GlobalPtrHandle(lp) \ + ((HGLOBAL)LOWORD(GlobalHandle(HIWORD(lp)))) +#define GlobalUnlockPtr(lp) \ + GlobalUnlock(GlobalPtrHandle(lp)) #define GlobalFreePtr(lp) (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp))) #endif @@ -195,6 +199,8 @@ int UIW_IMAGE::LoadImageFromFile(void) // Load the bitmap. ZIL_UINT32 dibSize = bitmapFileHeader.bfSize - sizeof(BITMAPFILEHEADER); ZIL_UINT32 tdibSize = dibSize; +#define GlobalAllocPtr(flags, cb) \ + (GlobalLock(GlobalAlloc((flags), (cb)))) ZIL_UINT8 huge *dib = (ZIL_UINT8 huge *)GlobalAllocPtr(GMEM_MOVEABLE, dibSize); ZIL_UINT8 huge *tdib = dib; for ( ; dibSize; dibSize -= tdibSize, tdib += tdibSize)