diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-09-06 09:55:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-09-06 10:03:45 +0300 |
commit | b4c9f88cbede8bc27d4d869232fd4a8f59e39f40 (patch) | |
tree | 4ce9fd23f35e3035900d2eddfebc80faf6958259 /source/blender/windowmanager | |
parent | 3e44592cb9f93b0f5b443c03c7d9103f28dba1a0 (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.c | 24 |
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 */ |