diff --git a/docs/changes.txt b/docs/changes.txt index 3e5033920a..e352dc8c83 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -635,6 +635,7 @@ wxMSW: - Fix crash when adding/removing the same path to/from wxFileSystemWatcher. - Draw "classic" disabled owner drawn buttons better (Artur Wieczorek). - Fix width of the vertical toolbars (Artur Wieczorek). +- Fix loading of top to bottom BMP files in wxBitmap (Artur Wieczorek). wxOSX: diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index 439cc916a7..cc9c9de4c0 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -393,15 +393,28 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) { -#if wxUSE_WXDIB wxCHECK_MSG( bitmap, false, wxT("NULL bitmap in LoadFile") ); +#if wxUSE_WXDIB + // Try loading using native Windows LoadImage() first. wxDIB dib(name); + if ( dib.IsOk() ) + return bitmap->CopyFromDIB(dib); +#endif // wxUSE_WXDIB + + // Some valid bitmap files are not supported by LoadImage(), e.g. those + // with negative height. Try to use our own bitmap loading code which does + // support them. +#if wxUSE_IMAGE + wxImage img(name, wxBITMAP_TYPE_BMP); + if ( img.IsOk() ) + { + *bitmap = wxBitmap(img); + return true; + } +#endif // wxUSE_IMAGE - return dib.IsOk() && bitmap->CopyFromDIB(dib); -#else return false; -#endif } bool wxBMPFileHandler::SaveFile(const wxBitmap *bitmap,