[gegl] bin: deal with infinitie bounding boxes in scale to fit by assuing a 1024x1024 buffer



commit ebc942026cc7355fe496eb8fedb46dab1df3759f
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jan 30 02:41:36 2019 +0100

    bin: deal with infinitie bounding boxes in scale to fit by assuing a 1024x1024 buffer

 bin/ui.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/bin/ui.c b/bin/ui.c
index 2ea6a9f82..7883aa0f3 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -839,6 +839,15 @@ cmd_thumb (COMMAND_ARGS)
     float scale, scale2;
     float width = 256, height = 256;
 
+    if (rect.width > 1000000 ||
+        rect.height > 1000000)
+    {
+       rect.x=0;
+       rect.y=0;
+       rect.width=1024;
+       rect.height=1024;
+    }
+
     scale = 1.0 * width / rect.width;
     scale2 = 1.0 * height / rect.height;
 
@@ -5836,6 +5845,15 @@ static void zoom_to_fit (State *o)
     return;
   }
 
+  if (rect.width >  1000000 ||
+      rect.height > 1000000)
+  {
+     rect.x=0;
+     rect.y=0;
+     rect.width=1024;
+     rect.height=1024;
+  }
+
   if (mrg)
   {
     width = mrg_width (mrg);
@@ -5854,10 +5872,10 @@ static void zoom_to_fit (State *o)
   o->u += rect.x * o->scale;
   o->v += rect.y * o->scale;
 
-
   o->is_fit = 1;
 
-  mrg_queue_draw (mrg, NULL);
+  if (mrg)
+    mrg_queue_draw (mrg, NULL);
 }
 static void center (State *o)
 {
@@ -5865,6 +5883,7 @@ static void center (State *o)
   GeglRectangle rect = gegl_node_get_bounding_box (o->sink);
   o->scale = 1.0;
 
+
   o->u = -(mrg_width (mrg) - rect.width * o->scale) / 2;
   o->v = -(mrg_height (mrg) - rect.height * o->scale) / 2;
   o->u += rect.x * o->scale;
@@ -7190,7 +7209,6 @@ cmd_node_add (COMMAND_ARGS)
   return 0;
 }
 
-int cmd_todo (COMMAND_ARGS);/* "todo", -1, "", ""*/
 int cmd_about (COMMAND_ARGS);/* "about", -1, "", ""*/
 int
 cmd_about (COMMAND_ARGS)
@@ -7222,6 +7240,7 @@ cmd_about (COMMAND_ARGS)
   return 0;
 }
 
+int cmd_todo (COMMAND_ARGS);/* "todo", -1, "", ""*/
 int
 cmd_todo (COMMAND_ARGS)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]