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:
Diffstat (limited to 'src/libslic3r/GCode/ThumbnailData.cpp')
-rw-r--r--src/libslic3r/GCode/ThumbnailData.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libslic3r/GCode/ThumbnailData.cpp b/src/libslic3r/GCode/ThumbnailData.cpp
new file mode 100644
index 000000000..80165916b
--- /dev/null
+++ b/src/libslic3r/GCode/ThumbnailData.cpp
@@ -0,0 +1,36 @@
+#include "libslic3r/libslic3r.h"
+#include "ThumbnailData.hpp"
+
+#if ENABLE_THUMBNAIL_GENERATOR
+
+namespace Slic3r {
+
+void ThumbnailData::set(unsigned int w, unsigned int h)
+{
+ if ((w == 0) || (h == 0))
+ return;
+
+ if ((width != w) || (height != h))
+ {
+ width = w;
+ height = h;
+ // defaults to white texture
+ pixels = std::vector<unsigned char>(width * height * 4, 255);
+ }
+}
+
+void ThumbnailData::reset()
+{
+ width = 0;
+ height = 0;
+ pixels.clear();
+}
+
+bool ThumbnailData::is_valid() const
+{
+ return (width != 0) && (height != 0) && ((unsigned int)pixels.size() == 4 * width * height);
+}
+
+} // namespace Slic3r
+
+#endif // ENABLE_THUMBNAIL_GENERATOR \ No newline at end of file