X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d80207c3445ece64793fc499818d4c7a3584e01f..fa03793d3bf2b76a753483ddf12abfd35eebe7a0:/src/msw/dib.cpp diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index a4db58f8df..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)