diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:17:51 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:17:51 +0200 |
commit | 237aedc590b58c0e69d7dfcac92b5f767b7c004a (patch) | |
tree | 83f361a82ba483f2daf83b677e8685cd953812d9 /wx+/image_tools.h | |
parent | 4.5 (diff) | |
download | FreeFileSync-237aedc590b58c0e69d7dfcac92b5f767b7c004a.tar.gz FreeFileSync-237aedc590b58c0e69d7dfcac92b5f767b7c004a.tar.bz2 FreeFileSync-237aedc590b58c0e69d7dfcac92b5f767b7c004a.zip |
4.6
Diffstat (limited to 'wx+/image_tools.h')
-rw-r--r-- | wx+/image_tools.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/wx+/image_tools.h b/wx+/image_tools.h index 23a363df..687025d0 100644 --- a/wx+/image_tools.h +++ b/wx+/image_tools.h @@ -9,6 +9,7 @@ #include <numeric> #include <wx/bitmap.h> +#include <wx/image.h> #include <wx/dcmemory.h> #include <zen/basic_math.h> @@ -24,7 +25,7 @@ void brighten(wxImage& img, int level); //level: delta per channel in points bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs); //pixel-wise equality (respecting alpha channel) - +wxColor gradient(const wxColor& from, const wxColor& to, double fraction); //maps fraction within [0, 1] to an intermediate color @@ -152,6 +153,17 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs) return std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData()); } + +inline +wxColor gradient(const wxColor& from, const wxColor& to, double fraction) +{ + fraction = std::max(0.0, fraction); + fraction = std::min(1.0, fraction); + return wxColor(from.Red () + (to.Red () - from.Red ()) * fraction, + from.Green() + (to.Green() - from.Green()) * fraction, + from.Blue () + (to.Blue () - from.Blue ()) * fraction, + from.Alpha() + (to.Alpha() - from.Alpha()) * fraction); +} } |