summaryrefslogtreecommitdiff
path: root/wx+/image_tools.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2016-03-16 21:31:24 +0100
committerDaniel Wilhelm <daniel@wili.li>2016-03-16 21:31:24 +0100
commit89621addb4a7c87d2e3f3e7462e3c690cf71de71 (patch)
tree008b5dea7624ee1eeb57ff82c45fdf1afcab3b08 /wx+/image_tools.h
parent7.5 (diff)
downloadFreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.gz
FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.bz2
FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.zip
7.6
Diffstat (limited to 'wx+/image_tools.h')
-rw-r--r--wx+/image_tools.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/wx+/image_tools.h b/wx+/image_tools.h
index 43c1a625..5e99653c 100644
--- a/wx+/image_tools.h
+++ b/wx+/image_tools.h
@@ -4,8 +4,8 @@
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
// **************************************************************************
-#ifndef IMAGE_TOOLS_HEADER_45782456427634254
-#define IMAGE_TOOLS_HEADER_45782456427634254
+#ifndef IMAGE_TOOLS_H_45782456427634254
+#define IMAGE_TOOLS_H_45782456427634254
#include <numeric>
#include <wx/bitmap.h>
@@ -13,6 +13,7 @@
#include <wx/dcmemory.h>
#include <zen/basic_math.h>
+
namespace zen
{
enum class ImageStackLayout
@@ -109,8 +110,8 @@ double getAvgBrightness(const wxImage& img)
//calculate average weighted by alpha channel
double dividend = 0;
- for (auto iter = pixBegin; iter != pixEnd; ++iter)
- dividend += *iter * static_cast<double>(alphaFirst[(iter - pixBegin) / 3]);
+ for (auto it = pixBegin; it != pixEnd; ++it)
+ dividend += *it * static_cast<double>(alphaFirst[(it - pixBegin) / 3]);
const double divisor = 3.0 * std::accumulate(alphaFirst, alphaFirst + pixelCount, 0.0);
@@ -132,9 +133,9 @@ void brighten(wxImage& img, int level)
{
auto pixEnd = pixBegin + 3 * pixelCount; //RGB
if (level > 0)
- std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = std::min(255, c + level); });
+ std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = static_cast<unsigned char>(std::min(255, c + level)); });
else
- std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = std::max(0, c + level); });
+ std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = static_cast<unsigned char>(std::max(0, c + level)); });
}
}
@@ -171,8 +172,7 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs)
if (!lhs.IsOk())
return true;
- const int pixelCount = lhs.GetWidth() * lhs.GetHeight();
- if (pixelCount != rhs.GetWidth() * rhs.GetHeight())
+ if (lhs.GetSize() != rhs.GetSize())
return false;
wxImage imLhs = lhs.ConvertToImage();
@@ -181,6 +181,8 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs)
if (imLhs.HasAlpha() != imRhs.HasAlpha())
return false;
+ const int pixelCount = lhs.GetWidth() * lhs.GetHeight();
+
if (!std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData()))
return false;
@@ -254,4 +256,4 @@ wxColour hsvColor(double h, double s, double v) //h within [0, 360), s, v within
*/
}
-#endif //IMAGE_TOOLS_HEADER_45782456427634254
+#endif //IMAGE_TOOLS_H_45782456427634254
bgstack15