X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a58a12e9b7196c339c1c1d282ede158a70644e07..cf31a1d7b60feddf23cc30259c6d909d4736ca56:/src/msw/dib.cpp diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index a629483022..c48d865d23 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -33,9 +33,9 @@ #endif #ifndef WX_PRECOMP -#include "wx/setup.h" -#include "wx/defs.h" #include "wx/bitmap.h" +#include "wx/log.h" +#include "wx/intl.h" #endif #include @@ -48,12 +48,8 @@ #include "wx/msw/dib.h" -#ifndef __TWIN32__ -#ifndef wxUSE_NORLANDER_HEADERS -#ifdef __GNUWIN32__ -#include "wx/msw/gnuwin32/extra.h" -#endif -#endif +#ifdef __GNUWIN32_OLD__ + #include "wx/msw/gnuwin32/extra.h" #endif #ifndef SEEK_CUR @@ -113,7 +109,7 @@ static BOOL WriteDIB(LPTSTR szFile, HANDLE hdib) if (!hdib) return FALSE; - fh = OpenFile(wxFNCONV(szFile), &of, OF_CREATE | OF_READWRITE); + fh = OpenFile(wxConvertWX2MB(szFile), &of, OF_CREATE | OF_READWRITE); if (fh == -1) return FALSE; @@ -163,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)); } /**************************************************************************** @@ -368,7 +364,7 @@ static DWORD PASCAL lread(int fh, void far *pv, DWORD ul) ul -= MAXREAD; hp += MAXREAD; } - if (_lread(fh, (LPSTR) hp, (WORD) ul) != (WORD) ul) + if (_lread(fh, (LPSTR) hp, (WXUINT) ul) != (WXUINT) ul) return 0; return ulT; } @@ -398,7 +394,7 @@ static DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul) ul -= MAXREAD; hp += MAXREAD; } - if (_lwrite(fh, (LPSTR) hp, (WORD) ul) != (WORD) ul) + if (_lwrite(fh, (LPSTR) hp, (WXUINT) ul) != (WXUINT) ul) return 0; return ulT; } @@ -433,7 +429,7 @@ BOOL wxReadDIB(LPTSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette) /* Open the file and get a handle to it's BITMAPINFO */ - fh = OpenFile (wxFNCONV(lpFileName), &of, OF_READ); + fh = OpenFile (wxConvertWX2MB(lpFileName), &of, OF_READ); if (fh == -1) { wxLogError(_("Can't open file '%s'"), lpFileName); return (0); @@ -532,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) { @@ -623,6 +619,9 @@ static BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB, result = TRUE; } } + + GlobalUnlock (hDIB); // glt + return(result); } @@ -669,7 +668,7 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo) lpRGB = (RGBQUAD FAR *)((LPSTR)lpInfo + lpInfo->biSize); /* copy colors from the color table to the LogPalette structure */ - for (i = 0; i < lpInfo->biClrUsed; i++, lpRGB++) + for (i = 0; (DWORD)i < lpInfo->biClrUsed; i++, lpRGB++) { npPal->palPalEntry[i].peRed = lpRGB->rgbRed; npPal->palPalEntry[i].peGreen = lpRGB->rgbGreen; @@ -696,25 +695,28 @@ HPALETTE wxMakeDIBPalette(LPBITMAPINFOHEADER lpInfo) 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) @@ -929,8 +931,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) @@ -942,4 +946,3 @@ bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap) else return FALSE; } -