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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-09-06 09:55:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-09-06 10:03:45 +0300
commitb4c9f88cbede8bc27d4d869232fd4a8f59e39f40 (patch)
tree4ce9fd23f35e3035900d2eddfebc80faf6958259 /source/blender/windowmanager
parent3e44592cb9f93b0f5b443c03c7d9103f28dba1a0 (diff)
Fix thumbnail screenshot error in 58632a7f3c0f1be6cc860c7cad9c41ba43e6454f
Scaling didn't clamp above zero, see T89868.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index dbc5a801cac..30b76fd110b 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1515,7 +1515,9 @@ static void wm_history_file_update(void)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Save Main Blend-File (internal) by capturing main window.
+/** \name Save Main Blend-File (internal) Screen-Shot
+ *
+ * Screen-shot the active window.
* \{ */
static ImBuf *blend_file_thumb_from_screenshot(bContext *C, BlendThumbnail **thumb_pt)
@@ -1540,11 +1542,17 @@ static ImBuf *blend_file_thumb_from_screenshot(bContext *C, BlendThumbnail **thu
ImBuf *ibuf = IMB_allocFromBuffer(buffer, NULL, win_size[0], win_size[1], 24);
if (ibuf) {
- int ex = (ibuf->x > ibuf->y) ? BLEN_THUMB_SIZE :
- (int)((ibuf->x / (float)ibuf->y) * BLEN_THUMB_SIZE);
- int ey = (ibuf->x > ibuf->y) ? (int)((ibuf->y / (float)ibuf->x) * BLEN_THUMB_SIZE) :
- BLEN_THUMB_SIZE;
- /* Filesystem thumbnail image can be 256x256. */
+ int ex, ey;
+ if (ibuf->x > ibuf->y) {
+ ex = BLEN_THUMB_SIZE;
+ ey = max_ii(1, (int)(((float)ibuf->y / (float)ibuf->x) * BLEN_THUMB_SIZE));
+ }
+ else {
+ ex = max_ii(1, (int)(((float)ibuf->x / (float)ibuf->y) * BLEN_THUMB_SIZE));
+ ey = BLEN_THUMB_SIZE;
+ }
+
+ /* File-system thumbnail image can be 256x256. */
IMB_scaleImBuf(ibuf, ex * 2, ey * 2);
/* Thumbnail inside blend should be 128x128. */
@@ -1565,7 +1573,9 @@ static ImBuf *blend_file_thumb_from_screenshot(bContext *C, BlendThumbnail **thu
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Save Main Blend-File (internal) by rendering scene
+/** \name Save Main Blend-File (internal) Camera View
+ *
+ * Render the current scene with the active camera.
* \{ */
/* screen can be NULL */