summaryrefslogtreecommitdiff
path: root/wx+/image_tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'wx+/image_tools.cpp')
-rw-r--r--wx+/image_tools.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp
index 72c7dc74..04f7f7ff 100644
--- a/wx+/image_tools.cpp
+++ b/wx+/image_tools.cpp
@@ -397,7 +397,7 @@ void zen::convertToVanillaImage(wxImage& img)
const unsigned char* rgb = img.GetData();
const int pixelCount = width * height;
- for (int i = 0; i < pixelCount; ++ i)
+ for (int i = 0; i < pixelCount; ++i)
{
const unsigned char r = *rgb++;
const unsigned char g = *rgb++;
@@ -415,3 +415,46 @@ void zen::convertToVanillaImage(wxImage& img)
assert(!img.HasMask());
}
}
+
+wxImage zen::rectangleImage(wxSize size, const wxColor& col)
+{
+ assert(col.IsSolid());
+ wxImage img(size);
+
+ unsigned char* rgb = img.GetData();
+ const int pixelCount = size.GetWidth() * size.GetHeight();
+ for (int i = 0; i < pixelCount; ++i)
+ {
+ *rgb++ = col.GetRed();
+ *rgb++ = col.GetGreen();
+ *rgb++ = col.GetBlue();
+ }
+ convertToVanillaImage(img);
+ return img;
+}
+
+
+wxImage zen::rectangleImage(wxSize size, const wxColor& innerCol, const wxColor& borderCol, int borderWidth)
+{
+ assert(innerCol.IsSolid() && borderCol.IsSolid());
+ wxImage img = rectangleImage(size, borderCol);
+
+ const int heightInner = size.GetHeight() - 2 * borderWidth;
+ const int widthInner = size.GetWidth () - 2 * borderWidth;
+
+ if (widthInner > 0 && heightInner > 0 && innerCol != borderCol)
+ //copyImageLayover(rectangleImage({widthInner, heightInner}, innerCol), img, {borderWidth, borderWidth}); => inline:
+ for (int y = 0; y < heightInner; ++y)
+ {
+ unsigned char* rgb = img.GetData () + 3 * (borderWidth + (borderWidth + y) * size.GetWidth());
+
+ for (int x = 0; x < widthInner; ++x)
+ {
+ *rgb++ = innerCol.GetRed();
+ *rgb++ = innerCol.GetGreen();
+ *rgb++ = innerCol.GetBlue();
+ }
+ }
+
+ return img;
+}
bgstack15