X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/33ac7e6f01acbac1cff0ad400d8ea7f0bfd0a62f..cf31a1d7b60feddf23cc30259c6d909d4736ca56:/src/msw/dib.cpp diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 5a9017faf0..c48d865d23 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -695,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) @@ -928,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) @@ -941,4 +946,3 @@ bool wxSaveBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette *colourmap) else return FALSE; } -