* 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 *
/* 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)
#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 *);
/****************************************************************************
* *
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));
/****************************************************************************
* *
- * 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 *
* *
****************************************************************************/
-static WORD PaletteSize(VOID FAR * pv)
+WORD wxPaletteSize(VOID FAR * pv)
{
LPBITMAPINFOHEADER lpbi;
WORD NumColors;
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);
}
/* 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 {
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;
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);
}
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;
LPSTR wxFindDIBBits (LPSTR lpbi)
{
- return (lpbi + *(LPDWORD)lpbi + PaletteSize (lpbi));
+ return (lpbi + *(LPDWORD)lpbi + wxPaletteSize (lpbi));
}
//---------------------------------------------------------------------
// 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;