diff options
author | B. Stack <bgstack15@gmail.com> | 2023-05-19 09:24:58 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-05-19 09:24:58 -0400 |
commit | 90bc692185a27f18acb6b029dfaf038e555ef8ff (patch) | |
tree | fdb56193bab28d36a4c6723bf847f3aa2ce36a9b /wx+/image_tools.cpp | |
parent | add upstream 12.2 (diff) | |
download | FreeFileSync-90bc692185a27f18acb6b029dfaf038e555ef8ff.tar.gz FreeFileSync-90bc692185a27f18acb6b029dfaf038e555ef8ff.tar.bz2 FreeFileSync-90bc692185a27f18acb6b029dfaf038e555ef8ff.zip |
add upstream 12.312.3
Diffstat (limited to 'wx+/image_tools.cpp')
-rw-r--r-- | wx+/image_tools.cpp | 45 |
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; +} |