summaryrefslogtreecommitdiff
path: root/wx+/image_tools.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2015-10-02 14:55:19 +0200
committerDaniel Wilhelm <daniel@wili.li>2015-10-02 14:55:19 +0200
commit46fc289a8776ba253e97d01d6948fb1031ea1973 (patch)
treeb16a99c60f21b04c001f29862bf2ee16ae3a0e00 /wx+/image_tools.cpp
parent6.15 (diff)
downloadFreeFileSync-46fc289a8776ba253e97d01d6948fb1031ea1973.tar.gz
FreeFileSync-46fc289a8776ba253e97d01d6948fb1031ea1973.tar.bz2
FreeFileSync-46fc289a8776ba253e97d01d6948fb1031ea1973.zip
7.0
Diffstat (limited to 'wx+/image_tools.cpp')
-rw-r--r--wx+/image_tools.cpp22
1 files changed, 13 insertions, 9 deletions
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
bgstack15