summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
Diffstat (limited to 'wx+')
-rw-r--r--wx+/grid.cpp6
-rw-r--r--wx+/image_resources.cpp4
-rw-r--r--wx+/image_tools.cpp22
-rw-r--r--wx+/image_tools.h6
4 files changed, 21 insertions, 17 deletions
diff --git a/wx+/grid.cpp b/wx+/grid.cpp
index 183fc3c3..7573fcb9 100644
--- a/wx+/grid.cpp
+++ b/wx+/grid.cpp
@@ -1323,10 +1323,10 @@ void Grid::updateWindowSizes(bool updateScrollbar)
auto setScrollbars2 = [&](int logWidth, int logHeight) //replace SetScrollbars, which loses precision of pixelsPerUnitX for some brain-dead reason
{
- mainWin_->SetVirtualSize(logWidth, logHeight); //set before calling SetScrollRate():
- //else SetScrollRate() would fail to preserve scroll position when "new virtual pixel-pos > old virtual height"
+ mainWin_->SetVirtualSize(logWidth, logHeight); //set before calling SetScrollRate():
+ //else SetScrollRate() would fail to preserve scroll position when "new virtual pixel-pos > old virtual height"
- int ppsuX = 0; //pixel per scroll unit
+ int ppsuX = 0; //pixel per scroll unit
int ppsuY = 0;
GetScrollPixelsPerUnit(&ppsuX, &ppsuY);
diff --git a/wx+/image_resources.cpp b/wx+/image_resources.cpp
index 089acf4e..3a7ba3ee 100644
--- a/wx+/image_resources.cpp
+++ b/wx+/image_resources.cpp
@@ -89,8 +89,8 @@ void GlobalResources::init(const Zstring& filepath)
wxImage img(streamIn, wxBITMAP_TYPE_PNG);
//end this alpha/no-alpha/mask/wxDC::DrawBitmap/RTL/high-contrast-scheme interoperability nightmare here and now!!!!
- //=> there's only one type of png image: with alpha channel, no mask!!!
- convertToVanillaImage(img);
+ //=> there's only one type of png image: with alpha channel, no mask!!!
+ convertToVanillaImage(img);
bitmaps.emplace(name, img);
}
diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp
index 859c9e5a..4b76fac0 100644
--- a/wx+/image_tools.cpp
+++ b/wx+/image_tools.cpp
@@ -190,17 +190,21 @@ void zen::convertToVanillaImage(wxImage& img)
{
if (!img.HasAlpha())
{
+ const int width = img.GetWidth ();
+ const int height = img.GetHeight();
+ if (width <= 0 || height <= 0) return;
+
unsigned char mask_r = 0;
unsigned char mask_g = 0;
unsigned char mask_b = 0;
const bool haveMask = img.HasMask() && img.GetOrFindMaskColour(&mask_r, &mask_g, &mask_b);
- //check for mask before calling wxImage::GetOrFindMaskColour() to skip needlessly searching for new mask color
+ //check for mask before calling wxImage::GetOrFindMaskColour() to skip needlessly searching for new mask color
img.SetAlpha();
- ::memset(img.GetAlpha(), wxIMAGE_ALPHA_OPAQUE, img.GetWidth() * img.GetHeight());
+ ::memset(img.GetAlpha(), wxIMAGE_ALPHA_OPAQUE, width * height);
- //wxWidgets, as always, tries to be more clever than it really is and fucks up wxStaticBitmap if wxBitmap is fully opaque:
- img.GetAlpha()[img.GetWidth() * img.GetHeight() - 1] = 254;
+ //wxWidgets, as always, tries to be more clever than it really is and fucks up wxStaticBitmap if wxBitmap is fully opaque:
+ img.GetAlpha()[width * height - 1] = 254;
if (haveMask)
{
@@ -208,7 +212,7 @@ void zen::convertToVanillaImage(wxImage& img)
unsigned char* alphaPtr = img.GetAlpha();
const unsigned char* dataPtr = img.GetData();
- const int pixelCount = img.GetWidth() * img.GetHeight();
+ const int pixelCount = width * height;
for (int i = 0; i < pixelCount; ++ i)
{
const unsigned char r = *dataPtr++;
@@ -222,8 +226,8 @@ void zen::convertToVanillaImage(wxImage& img)
}
}
}
- else
- {
- assert(!img.HasMask());
- }
+ else
+ {
+ assert(!img.HasMask());
+ }
} \ No newline at end of file
diff --git a/wx+/image_tools.h b/wx+/image_tools.h
index b53d42ea..5e21bd40 100644
--- a/wx+/image_tools.h
+++ b/wx+/image_tools.h
@@ -181,10 +181,10 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs)
if (imLhs.HasAlpha() != imRhs.HasAlpha())
return false;
- if (!std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData()))
- return false;
+ if (!std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData()))
+ return false;
- if (imLhs.HasAlpha())
+ if (imLhs.HasAlpha())
if (!std::equal(imLhs.GetAlpha(), imLhs.GetAlpha() + pixelCount, imRhs.GetAlpha()))
return false;
bgstack15