mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-10 02:59:09 +08:00
ENABLE_THUMBNAIL_GENERATOR -> Reduce thumbnail size if exceeding 3D scene canvas size
This commit is contained in:
parent
2896e12a46
commit
f36dd833d2
@ -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 orange[] = { 0.99f, 0.49f, 0.26f };
|
||||||
static const float gray[] = { 0.64f, 0.64f, 0.64f };
|
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);
|
thumbnail_data.set(w, h);
|
||||||
|
|
||||||
GLVolumePtrs visible_volumes;
|
GLVolumePtrs visible_volumes;
|
||||||
@ -1720,7 +1730,6 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// restore the framebuffer size to avoid flickering on the 3D scene
|
// 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());
|
m_camera.apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height());
|
||||||
}
|
}
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user