X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c455ab932f89cc166fc38d3f2c2f942f6a130649..18c98e42eeb75317f75c9ba20b09a5bd531a690c:/src/msw/dib.cpp diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 73c68707c8..3d13eb4ba0 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -6,7 +6,7 @@ * * * FUNCTIONS : * * * - * ReadDIB() - Reads a DIB * + * wxReadDIB() - Reads a DIB * * * * WriteDIB() - Writes a global handle in CF_DIB format* * to a file. * @@ -49,10 +49,12 @@ #include "wx/msw/dib.h" #ifndef __TWIN32__ +#ifndef wxUSE_NORLANDER_HEADERS #ifdef __GNUWIN32__ #include "wx/msw/gnuwin32/extra.h" #endif #endif +#endif #ifndef SEEK_CUR /* flags for _lseek */ @@ -67,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) @@ -81,16 +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 (LPSTR 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 *); -HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER); -BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette); +static BOOL WriteDIB (LPTSTR szFile,HANDLE hdib); +static WORD PaletteSize (VOID FAR * pv); +static WORD DibNumColors (VOID FAR * pv); +// HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal); +static BOOL PASCAL MakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *); /**************************************************************************** * * @@ -103,7 +103,7 @@ BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette); * * ****************************************************************************/ -BOOL WriteDIB(LPSTR szFile, HANDLE hdib) +static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib) { BITMAPFILEHEADER hdr; LPBITMAPINFOHEADER lpbi; @@ -113,7 +113,7 @@ BOOL WriteDIB(LPSTR szFile, HANDLE hdib) if (!hdib) return FALSE; - fh = OpenFile(szFile, &of, OF_CREATE | OF_READWRITE); + fh = OpenFile(wxFNCONV(szFile), &of, OF_CREATE | OF_READWRITE); if (fh == -1) return FALSE; @@ -154,7 +154,7 @@ BOOL WriteDIB(LPSTR szFile, HANDLE hdib) * * ****************************************************************************/ -WORD PaletteSize(VOID FAR * pv) +static WORD PaletteSize(VOID FAR * pv) { LPBITMAPINFOHEADER lpbi; WORD NumColors; @@ -179,7 +179,7 @@ WORD PaletteSize(VOID FAR * pv) * * ****************************************************************************/ -WORD DibNumColors(VOID FAR *pv) +static WORD DibNumColors(VOID FAR *pv) { int bits; BITMAPINFOHEADER *lpbi; @@ -226,7 +226,7 @@ WORD DibNumColors(VOID FAR *pv) ****************************************************************************/ #if NOTHING -HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal) +static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal) { BITMAP bm; BITMAPINFOHEADER bi; @@ -354,7 +354,7 @@ HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal) * * ****************************************************************************/ -DWORD PASCAL lread(int fh, void far *pv, DWORD ul) +static DWORD PASCAL lread(int fh, void far *pv, DWORD ul) { DWORD ulT = ul; #if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__) @@ -384,7 +384,7 @@ DWORD PASCAL lread(int fh, void far *pv, DWORD ul) * * ****************************************************************************/ -DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul) +static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul) { DWORD ulT = ul; #if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__) @@ -418,7 +418,7 @@ DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul) * FALSE - otherwise * ****************************************************************************/ -BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) +BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) { int fh; LPBITMAPINFOHEADER lpbi; @@ -426,7 +426,7 @@ BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) BITMAPFILEHEADER bf; WORD nNumColors; BOOL result = FALSE; - char str[128]; + wxChar str[128]; WORD offBits; HDC hDC; BOOL bCoreHead = FALSE; @@ -434,10 +434,10 @@ BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) /* Open the file and get a handle to it's BITMAPINFO */ - fh = OpenFile (lpFileName, &of, OF_READ); + fh = OpenFile (wxFNCONV(lpFileName), &of, OF_READ); if (fh == -1) { - wsprintf(str,"Can't open file '%s'", lpFileName); - MessageBox(NULL, str, "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); } @@ -586,7 +586,7 @@ ErrExit2: * not valid * ****************************************************************************/ -BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, +static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, HPALETTE * phPal, HBITMAP * phBitmap) { LPBITMAPINFOHEADER lpInfo; @@ -601,7 +601,7 @@ BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, lpInfo = (LPBITMAPINFOHEADER) GlobalLock(hDIB); #endif - hPalette = MakeDIBPalette(lpInfo); + hPalette = wxMakeDIBPalette(lpInfo); if ( hPalette ) { // Need to realize palette for converting DIB to bitmap. @@ -630,7 +630,7 @@ BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, /**************************************************************************** * * - * FUNCTION : MakeDIBPalette(lpInfo) * + * FUNCTION : wxMakeDIBPalette(lpInfo) * * * * PURPOSE : Given a BITMAPINFOHEADER, create a palette based on * the color table. @@ -640,12 +640,12 @@ BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, * zero - unable to create palette * * ****************************************************************************/ -HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER lpInfo) +HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo) { #ifdef __WXWINE__ return (FALSE); #else - NPLOGPALETTE npPal; + LPLOGPALETTE npPal; RGBQUAD far *lpRGB; HPALETTE hLogPal; WORD i; @@ -659,7 +659,7 @@ HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER lpInfo) npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + (WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY)); */ - npPal = (NPLOGPALETTE)malloc(sizeof(LOGPALETTE) + + npPal = (LPLOGPALETTE)malloc(sizeof(LOGPALETTE) + (WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY)); if (!npPal) return(FALSE); @@ -696,12 +696,12 @@ HPALETTE MakeDIBPalette(LPBITMAPINFOHEADER lpInfo) } -bool wxLoadIntoBitmap(char *filename, wxBitmap *bitmap, wxPalette **pal) +bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal) { HBITMAP hBitmap; HPALETTE hPalette; - bool success = (ReadDIB(filename, &hBitmap, &hPalette) != 0); + bool success = (wxReadDIB(filename, &hBitmap, &hPalette) != 0); if (!success) { @@ -737,7 +737,7 @@ bool wxLoadIntoBitmap(char *filename, wxBitmap *bitmap, wxPalette **pal) else return FALSE; } -wxBitmap *wxLoadBitmap(char *filename, wxPalette **pal) +wxBitmap *wxLoadBitmap(wxChar *filename, wxPalette **pal) { wxBitmap *bitmap = new wxBitmap; if (wxLoadIntoBitmap(filename, bitmap, pal)) @@ -780,7 +780,7 @@ wxBitmap *wxLoadBitmap(char *filename, wxPalette **pal) // //--------------------------------------------------------------------- -void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr, +static void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr, DWORD dwWidth, DWORD dwHeight, int nBPP) @@ -813,7 +813,7 @@ void InitBitmapInfoHeader (LPBITMAPINFOHEADER lpBmInfoHdr, -LPSTR FindDIBBits (LPSTR lpbi) +LPSTR wxFindDIBBits (LPSTR lpbi) { return (lpbi + *(LPDWORD)lpbi + PaletteSize (lpbi)); } @@ -838,7 +838,7 @@ LPSTR FindDIBBits (LPSTR lpbi) // //--------------------------------------------------------------------- -HANDLE BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal) +HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal) { BITMAP Bitmap; BITMAPINFOHEADER bmInfoHdr; @@ -880,7 +880,7 @@ HANDLE BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal) #endif *lpbmInfoHdr = bmInfoHdr; - lpBits = FindDIBBits ((LPSTR) lpbmInfoHdr); + lpBits = wxFindDIBBits ((LPSTR) lpbmInfoHdr); // Now, we need a DC to hold our bitmap. If the app passed us @@ -926,13 +926,13 @@ HANDLE BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal) return hDIB; } -bool wxSaveBitmap(char *filename, wxBitmap *bitmap, wxPalette *colourmap) +bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap) { HPALETTE hPalette = 0; if (colourmap) hPalette = (HPALETTE) colourmap->GetHPALETTE(); - HANDLE dibHandle = BitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette); + HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette); if (dibHandle) { bool success = (WriteDIB(filename, dibHandle) != 0);