Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2020-02-03 00:22:40 +0300
committerYuSanka <yusanka@gmail.com>2020-02-03 00:22:40 +0300
commit3f7ebee39661676f70f8b58197234c307f82ed5f (patch)
tree8997fb342e4dff5788a8791a373a5091871af9ac /src/slic3r/GUI/BitmapCache.cpp
parenteb6e0c06e4217748b0a53f4ef84d575301c99dd9 (diff)
ObjectDataViewModel is extracted from wxExtentions to the separated file
+ parse_color function is moved to BitmapCache from PresetBundle
Diffstat (limited to 'src/slic3r/GUI/BitmapCache.cpp')
-rw-r--r--src/slic3r/GUI/BitmapCache.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp
index 9668278bb..8627ef4cb 100644
--- a/src/slic3r/GUI/BitmapCache.cpp
+++ b/src/slic3r/GUI/BitmapCache.cpp
@@ -2,6 +2,8 @@
#include "libslic3r/Utils.hpp"
#include "../Utils/MacDarkMode.hpp"
+#include "GUI.hpp"
+
#include <boost/filesystem.hpp>
#if ! defined(WIN32) && ! defined(__APPLE__)
@@ -349,5 +351,30 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
}
+
+static inline int hex_digit_to_int(const char c)
+{
+ return
+ (c >= '0' && c <= '9') ? int(c - '0') :
+ (c >= 'A' && c <= 'F') ? int(c - 'A') + 10 :
+ (c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1;
+}
+
+bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
+{
+ rgb_out[0] = rgb_out[1] = rgb_out[2] = 0;
+ if (scolor.size() != 7 || scolor.front() != '#')
+ return false;
+ const char* c = scolor.data() + 1;
+ for (size_t i = 0; i < 3; ++i) {
+ int digit1 = hex_digit_to_int(*c++);
+ int digit2 = hex_digit_to_int(*c++);
+ if (digit1 == -1 || digit2 == -1)
+ return false;
+ rgb_out[i] = (unsigned char)(digit1 * 16 + digit2);
+ }
+ return true;
+}
+
} // namespace GUI
} // namespace Slic3r