[Bf-blender-cvs] [b4c9f88cbed] master: Fix thumbnail screenshot error in 58632a7f3c0f1be6cc860c7cad9c41ba43e6454f

Campbell Barton noreply at git.blender.org
Mon Sep 6 09:04:02 CEST 2021


Commit: b4c9f88cbede8bc27d4d869232fd4a8f59e39f40
Author: Campbell Barton
Date:   Mon Sep 6 16:55:46 2021 +1000
Branches: master
https://developer.blender.org/rBb4c9f88cbede8bc27d4d869232fd4a8f59e39f40

Fix thumbnail screenshot error in 58632a7f3c0f1be6cc860c7cad9c41ba43e6454f

Scaling didn't clamp above zero, see T89868.

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

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 */



More information about the Bf-blender-cvs mailing list