X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3897b707bd39c491c820849953431e4a5751fced..5e3841bf8069fbcc2b1da3ef36af4f569c604265:/src/msw/dib.cpp diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 40531079da..2eac920130 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -159,9 +159,9 @@ WORD wxPaletteSize(VOID FAR * pv) NumColors = DibNumColors(lpbi); if (lpbi->biSize == sizeof(BITMAPCOREHEADER)) - return NumColors * sizeof(RGBTRIPLE); + return (WORD)(NumColors * sizeof(RGBTRIPLE)); else - return NumColors * sizeof(RGBQUAD); + return (WORD)(NumColors * sizeof(RGBQUAD)); } /**************************************************************************** @@ -353,7 +353,7 @@ static HANDLE DibFromBitmap(HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hp static DWORD PASCAL lread(int fh, void far *pv, DWORD ul) { DWORD ulT = ul; -#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) || defined(__WXWINE__) +#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) BYTE *hp = (BYTE *) pv; #else BYTE huge *hp = (BYTE huge *) pv; @@ -383,7 +383,7 @@ static DWORD PASCAL lread(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__) +#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__) BYTE *hp = (BYTE *) pv; #else BYTE huge *hp = (BYTE huge *) pv; @@ -528,7 +528,7 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) } /* offset to the bits from start of DIB header */ - offBits = (WORD)lpbi->biSize + nNumColors * sizeof(RGBQUAD); + offBits = (WORD)(lpbi->biSize + nNumColors * sizeof(RGBQUAD)); if (bf.bfOffBits != 0L) { @@ -639,9 +639,6 @@ static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, ****************************************************************************/ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo) { -#ifdef __WXWINE__ - return (FALSE); -#else LPLOGPALETTE npPal; RGBQUAD far *lpRGB; HPALETTE hLogPal; @@ -659,7 +656,7 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo) npPal = (LPLOGPALETTE)malloc(sizeof(LOGPALETTE) + (WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY)); if (!npPal) - return(FALSE); + return NULL; npPal->palVersion = 0x300; npPal->palNumEntries = (WORD)lpInfo->biClrUsed; @@ -689,31 +686,32 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo) */ else return((HPALETTE) GetStockObject(DEFAULT_PALETTE)); -#endif - } bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal) { - HBITMAP hBitmap; - HPALETTE hPalette; + HBITMAP hBitmap = NULL; + HPALETTE hPalette = NULL; bool success = (wxReadDIB(filename, &hBitmap, &hPalette) != 0); if (!success) { - DeleteObject(hPalette); + if (hPalette) + DeleteObject(hPalette); return FALSE; } if (hPalette) { +#if wxUSE_PALETTE if (pal) { *pal = new wxPalette; (*pal)->SetHPALETTE((WXHPALETTE) hPalette); } else +#endif // wxUSE_PALETTE DeleteObject(hPalette); } else if (pal) @@ -928,8 +926,10 @@ HANDLE wxBitmapToDIB (HBITMAP hBitmap, HPALETTE hPal) bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap) { HPALETTE hPalette = 0; +#if wxUSE_PALETTE if (colourmap) hPalette = (HPALETTE) colourmap->GetHPALETTE(); +#endif // wxUSE_PALETTE HANDLE dibHandle = wxBitmapToDIB((HBITMAP) bitmap->GetHBITMAP(), hPalette); if (dibHandle) @@ -941,4 +941,3 @@ bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap) else return FALSE; } -