summaryrefslogtreecommitdiff
path: root/wx+/image_tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'wx+/image_tools.h')
-rw-r--r--[-rwxr-xr-x]wx+/image_tools.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/wx+/image_tools.h b/wx+/image_tools.h
index bef4cb67..e1a6953c 100755..100644
--- a/wx+/image_tools.h
+++ b/wx+/image_tools.h
@@ -52,6 +52,8 @@ void convertToVanillaImage(wxImage& img); //add alpha channel if missing + remov
//wxColor hsvColor(double h, double s, double v); //h within [0, 360), s, v within [0, 1]
+wxImage shrinkImage(const wxImage& img, int requestedSize);
+
inline
wxImage getTransparentPixel()
@@ -179,6 +181,17 @@ bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs)
return true;
}
+
+inline
+wxImage shrinkImage(const wxImage& img, int requestedSize)
+{
+ const int maxExtent = std::max(img.GetWidth(), img.GetHeight());
+ assert(requestedSize <= maxExtent);
+ return img.Scale(img.GetWidth () * requestedSize / maxExtent,
+ img.GetHeight() * requestedSize / maxExtent, wxIMAGE_QUALITY_BILINEAR); //looks sharper than wxIMAGE_QUALITY_HIGH!
+}
+
+
/*
inline
wxColor gradient(const wxColor& from, const wxColor& to, double fraction)
bgstack15