From 89621addb4a7c87d2e3f3e7462e3c690cf71de71 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 16 Mar 2016 21:31:24 +0100 Subject: 7.6 --- wx+/image_tools.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'wx+/image_tools.h') 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 #include @@ -13,6 +13,7 @@ #include #include + 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(alphaFirst[(iter - pixBegin) / 3]); + for (auto it = pixBegin; it != pixEnd; ++it) + dividend += *it * static_cast(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(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(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 -- cgit