diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2019-10-29 09:32:15 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2019-10-29 09:32:15 +0300 |
commit | f36dd833d2fecebe86d351fe0f2933e1c920673c (patch) | |
tree | 8b306c0fa507ee24ba0b8cf5a25171e37345dccd /src | |
parent | 2896e12a4692db145dfd772d788e6b84c3a77299 (diff) |
ENABLE_THUMBNAIL_GENERATOR -> Reduce thumbnail size if exceeding 3D scene canvas size
Diffstat (limited to 'src')
-rw-r--r-- | src/slic3r/GUI/GLCanvas3D.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 703321c3c..139ee5fa4 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1658,6 +1658,16 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, static const float orange[] = { 0.99f, 0.49f, 0.26f }; static const float gray[] = { 0.64f, 0.64f, 0.64f }; + const Size& cnv_size = get_canvas_size(); + unsigned int cnv_w = (unsigned int)cnv_size.get_width(); + unsigned int cnv_h = (unsigned int)cnv_size.get_height(); + if ((w > cnv_w) || (h > cnv_h)) + { + float ratio = std::min((float)cnv_w / (float)w, (float)cnv_h / (float)h); + w = (unsigned int)(ratio * (float)w); + h = (unsigned int)(ratio * (float)h); + } + thumbnail_data.set(w, h); GLVolumePtrs visible_volumes; @@ -1720,7 +1730,6 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, #endif // restore the framebuffer size to avoid flickering on the 3D scene - const Size& cnv_size = get_canvas_size(); m_camera.apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height()); } #endif // ENABLE_THUMBNAIL_GENERATOR |