X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c455ab932f89cc166fc38d3f2c2f942f6a130649..a1925afc905df6260036832e58d2f3919caad03f:/src/msw/dibutils.cpp diff --git a/src/msw/dibutils.cpp b/src/msw/dibutils.cpp index 3acbd1fbea..e8f639f22c 100644 --- a/src/msw/dibutils.cpp +++ b/src/msw/dibutils.cpp @@ -21,9 +21,9 @@ #endif #ifndef WX_PRECOMP -#include #include "wx/setup.h" #include "wx/defs.h" +#include "wx/string.h" #endif #include @@ -50,10 +50,31 @@ #define BFT_BITMAP 0x4d42 /* 'BM' */ #define BFT_CURSOR 0x5450 /* 'PT' */ +#ifndef SEEK_CUR /* flags for _lseek */ #define SEEK_CUR 1 #define SEEK_END 2 #define SEEK_SET 0 +#endif + +/* Copied from PNGhandler for coompilation with MingW32, RR */ + +#ifndef GlobalAllocPtr +#define GlobalPtrHandle(lp) \ + ((HGLOBAL)GlobalHandle(lp)) + +#define GlobalLockPtr(lp) \ + ((BOOL)GlobalLock(GlobalPtrHandle(lp))) +#define GlobalUnlockPtr(lp) \ + GlobalUnlock(GlobalPtrHandle(lp)) + +#define GlobalAllocPtr(flags, cb) \ + (GlobalLock(GlobalAlloc((flags), (cb)))) +#define GlobalReAllocPtr(lp, cbNew, flags) \ + (GlobalUnlockPtr(lp), GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags)))) +#define GlobalFreePtr(lp) \ + (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp))) +#endif /* @@ -125,12 +146,12 @@ void ClearSystemPalette(void) * bits.... */ -int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) +int DibWriteFile(LPTSTR szFile, LPBITMAPINFOHEADER lpbi) { HFILE fh; OFSTRUCT of; - fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE); + fh = OpenFile(wxConvFile.cWX2MB(szFile), &of, OF_WRITE | OF_CREATE); if (!fh) { // printf("la regamos0"); @@ -145,7 +166,7 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) bmf.bfSize = sizeof(bmf) + size; bmf.bfReserved1 = 0; bmf.bfReserved2 = 0; - bmf.bfOffBits = sizeof(bmf) + (char far*)(DibPtr(lpbi)) - (char far*)lpbi; + bmf.bfOffBits = sizeof(bmf) + (char FAR*)(DibPtr(lpbi)) - (char FAR*)lpbi; #if defined( __WATCOMC__) || defined(__VISUALC__) || defined(__SC__) || defined(__SALFORDC__) || defined(__MWERKS__) if (_hwrite(fh, (LPCSTR)(&bmf), sizeof(bmf))<0 || _hwrite(fh, (LPCSTR)lpbi, size)<0) { @@ -166,7 +187,7 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) return 1; } -PDIB DibOpenFile(LPSTR szFile) +PDIB DibOpenFile(LPTSTR szFile) { HFILE fh; DWORD dwLen; @@ -181,7 +202,7 @@ PDIB DibOpenFile(LPSTR szFile) #define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of) #endif - fh = OpenFile(szFile, &of, OF_READ); + fh = OpenFile(wxConvFile.cWX2MB(szFile), &of, OF_READ); if (fh == -1) { @@ -190,6 +211,8 @@ PDIB DibOpenFile(LPSTR szFile) // TODO: Unicode version #ifdef __WIN16__ h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP); +#elif wxUSE_UNICODE + h = FindResourceW(GetCurrentInstance(), szFile, RT_BITMAP); #else h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP); #endif @@ -684,7 +707,7 @@ BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal) HPALETTE MakePalette(const BITMAPINFO FAR* Info, UINT flags) { HPALETTE hPalette; - const RGBQUAD far* rgb = Info->bmiColors; + const RGBQUAD FAR* rgb = Info->bmiColors; WORD nColors = Info->bmiHeader.biClrUsed; if (nColors) {