From 45d81c75ffad5bdc543311c256076f2516ac44f7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Jun 2022 17:51:24 +0100 Subject: [PATCH] Make wxBMPHandler::DoLoadDib() a free function This function doesn't have to be a member, so remove it from the header. No real changes yet, but this will make it simpler to change it in the upcoming commits. --- include/wx/imagbmp.h | 3 --- src/common/imagbmp.cpp | 14 ++++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/wx/imagbmp.h b/include/wx/imagbmp.h index a4a6527eed..3184cf5f37 100644 --- a/include/wx/imagbmp.h +++ b/include/wx/imagbmp.h @@ -58,9 +58,6 @@ protected: virtual bool DoCanRead( wxInputStream& stream ) wxOVERRIDE; bool SaveDib(wxImage *image, wxOutputStream& stream, bool verbose, bool IsBmp, bool IsMask); - bool DoLoadDib(wxImage *image, int width, int height, int bpp, int ncolors, - int comp, wxFileOffset bmpOffset, wxInputStream& stream, - bool verbose, bool IsBmp, bool hasPalette, int colEntrySize = 4); bool LoadDib(wxImage *image, wxInputStream& stream, bool verbose, bool IsBmp); #endif // wxUSE_STREAMS diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 1cd654f960..c1b1a2b360 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -494,6 +494,9 @@ bool wxBMPHandler::SaveDib(wxImage *image, } +namespace +{ + struct BMPPalette { static void Free(BMPPalette* pal) { delete [] pal; } @@ -501,11 +504,12 @@ struct BMPPalette unsigned char r, g, b; }; -bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height, +// Read the data in BMP format into the given image. +bool LoadBMPData(wxImage * image, int width, int height, int bpp, int ncolors, int comp, wxFileOffset bmpOffset, wxInputStream& stream, bool verbose, bool IsBmp, bool hasPalette, - int colEntrySize) + int colEntrySize = 4) { wxInt32 aDword, rmask = 0, gmask = 0, bmask = 0, amask = 0; int rshift = 0, gshift = 0, bshift = 0, ashift = 0; @@ -1027,6 +1031,8 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height, return err == wxSTREAM_NO_ERROR || err == wxSTREAM_EOF; } +} // anonymous namespace + bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, bool verbose, bool IsBmp) { @@ -1212,7 +1218,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, } //read DIB; this is the BMP image or the XOR part of an icon image - if ( !DoLoadDib(image, width, height, bpp, ncolors, comp, offset, stream, + if ( !LoadBMPData(image, width, height, bpp, ncolors, comp, offset, stream, verbose, IsBmp, true, usesV1 ? 3 : 4) ) { @@ -1228,7 +1234,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, //read Icon mask which is monochrome //there is no palette, so we will create one wxImage mask; - if ( !DoLoadDib(&mask, width, height, 1, 2, BI_RGB, offset, stream, + if ( !LoadBMPData(&mask, width, height, 1, 2, BI_RGB, offset, stream, verbose, IsBmp, false) ) { if (verbose)