X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ef3ab009984534c308ca0ee94cd3fcbccdc63448..3c1a88d8b8518eda184be388723f46cfd54c3ac6:/src/msw/dib.cpp?ds=sidebyside diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 3d91a3250c..2bc530afeb 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -11,7 +11,7 @@ * WriteDIB() - Writes a global handle in CF_DIB format* * to a file. * * * - * PaletteSize() - Calculates the palette size in bytes * + * wxPaletteSize() - Calculates the palette size in bytes * * of given DIB * * * * DibNumColors() - Determines the number of colors in DIB * @@ -69,7 +69,7 @@ /* Header signatutes for various resources */ #define BFT_ICON 0x4349 /* 'IC' */ #define BFT_BITMAP 0x4d42 /* 'BM' */ -#define BFT_CURSOR 0x5450 /* 'PT' */ +#define BFT_CURSOR 0x5450 /* 'PT(' */ /* macro to determine if resource is a DIB */ #define ISDIB(bft) ((bft) == BFT_BITMAP) @@ -83,14 +83,14 @@ #define PALVERSION 0x300 #define MAXPALETTE 256 /* max. # supported palette entries */ -DWORD PASCAL lread(int fh, VOID FAR *pv, DWORD ul); -DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul); +static DWORD PASCAL lread(int fh, VOID FAR *pv, DWORD ul); +static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul); -BOOL WriteDIB (LPTSTR szFile,HANDLE hdib); -WORD PaletteSize (VOID FAR * pv); -WORD DibNumColors (VOID FAR * pv); -// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal); -BOOL PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *); +static BOOL WriteDIB (LPTSTR szFile,HANDLE hdib); +WORD wxPaletteSize (VOID FAR * pv); // This is non-static as some apps use it externally +static WORD DibNumColors (VOID FAR * pv); +// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal); +static BOOL PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *); /**************************************************************************** * * @@ -128,7 +128,7 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib) hdr.bfReserved1 = 0; hdr.bfReserved2 = 0; hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize + - PaletteSize(lpbi); + wxPaletteSize(lpbi); /* Write the file header */ _lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER)); @@ -143,7 +143,7 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib) /**************************************************************************** * * - * FUNCTION : PaletteSize(VOID FAR * pv) * + * FUNCTION : wxPaletteSize(VOID FAR * pv) * * * * PURPOSE : Calculates the palette size in bytes. If the info. block * * is of the BITMAPCOREHEADER type, the number of colors is * @@ -154,7 +154,7 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib) * * ****************************************************************************/ -static WORD PaletteSize(VOID FAR * pv) +WORD wxPaletteSize(VOID FAR * pv) { LPBITMAPINFOHEADER lpbi; WORD NumColors; @@ -259,7 +259,7 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp bi.biClrUsed = 0; bi.biClrImportant = 0; - dwLen = bi.biSize + PaletteSize(&bi); + dwLen = bi.biSize + wxPaletteSize(&bi); hdc = GetDC((HWND) NULL); hpal = SelectPalette(hdc, hpal, FALSE); @@ -299,7 +299,7 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp } /* realloc the buffer big enough to hold all the bits */ - dwLen = bi.biSize + PaletteSize(&bi) + bi.biSizeImage; + dwLen = bi.biSize + wxPaletteSize(&bi) + bi.biSizeImage; if (h = GlobalReAlloc(hdib, dwLen, 0)) hdib = h; else { @@ -324,7 +324,7 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp hbm, 0, (WORD) bi.biHeight, - (LPSTR) lpbi + (WORD) lpbi->biSize + PaletteSize(lpbi), + (LPSTR) lpbi + (WORD) lpbi->biSize + wxPaletteSize(lpbi), (LPBITMAPINFO) lpbi, DIB_RGB_COLORS) == 0) { GlobalUnlock(hdib); hdib = NULL; @@ -436,8 +436,8 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) fh = OpenFile (wxFNCONV(lpFileName), &of, OF_READ); if (fh == -1) { - wsprintf(str,_T("Can't open file '%s'"), lpFileName); - MessageBox(NULL, str, _T("Error"), MB_ICONSTOP | MB_OK); + wsprintf(str,wxT("Can't open file '%s'"), lpFileName); + MessageBox(NULL, str, wxT("Error"), MB_ICONSTOP | MB_OK); return (0); } @@ -731,7 +731,9 @@ bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal) bitmap->SetWidth(bm.bmWidth); bitmap->SetHeight(bm.bmHeight); bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel); +#if WXWIN_COMPATIBILITY_2 bitmap->SetOk(TRUE); +#endif // WXWIN_COMPATIBILITY_2 return TRUE; } else return FALSE; @@ -815,7 +817,7 @@ static void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr, LPSTR wxFindDIBBits (LPSTR lpbi) { - return (lpbi + *(LPDWORD)lpbi + PaletteSize (lpbi)); + return (lpbi + *(LPDWORD)lpbi + wxPaletteSize (lpbi)); } //--------------------------------------------------------------------- @@ -868,7 +870,7 @@ HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal) // into this memory, and find out where the bitmap bits go. hDIB = GlobalAlloc (GHND, sizeof (BITMAPINFOHEADER) + - PaletteSize ((LPSTR) &bmInfoHdr) + bmInfoHdr.biSizeImage); + wxPaletteSize ((LPSTR) &bmInfoHdr) + bmInfoHdr.biSizeImage); if (!hDIB) return NULL;