Re: [GnomeMeeting-devel-list] [PATCH] vfakeio modification



On lun, 2004-02-09 at 20:53, PUYDT Julien wrote:
Here it comes, and again:
> Thanks lurchi for pointing this out!

Snark
diff -ur gnomemeeting-cvs-20040209.CVS/src/vfakeio.cpp gnomemeeting-cvs-20040209.CVS.patched/src/vfakeio.cpp
--- gnomemeeting-cvs-20040209.CVS/src/vfakeio.cpp	2004-02-09 02:02:48.000000000 +0100
+++ gnomemeeting-cvs-20040209.CVS.patched/src/vfakeio.cpp	2004-02-09 20:48:24.000000000 +0100
@@ -222,10 +222,28 @@
       orig_width = gdk_pixbuf_get_width (orig_pix);
       orig_height = gdk_pixbuf_get_height (orig_pix);
       
-      gdk_pixbuf_copy_area (orig_pix, 0, 0, orig_width, orig_height,
-			    cached_pix, 
-                            (width - orig_width) / 2, 
-                            (height - orig_height) / 2);
+      if ((unsigned)orig_width <= width && (unsigned)orig_height <= height)
+	/* the picture fits in the  target space: center it */
+        gdk_pixbuf_copy_area (orig_pix, 0, 0, orig_width, orig_height,
+			      cached_pix, 
+                              (width - orig_width) / 2, 
+                              (height - orig_height) / 2);
+      else { /* the picture doesn't fit: scale 1:1, and center */
+	double scale_w, scale_h, scale;
+	
+	scale_w = (double)width / orig_width;
+	scale_h = (double)height / orig_height;
+	
+	if (scale_w < scale_h) // one of them is known to be < 1
+	  scale = scale_w;
+	else
+	  scale = scale_h;
+	
+	GdkPixbuf *scaled_pix = gdk_pixbuf_scale_simple (orig_pix, (int)(scale*orig_width),(int)(scale*orig_height), GDK_INTERP_BILINEAR);
+	gdk_pixbuf_copy_area (scaled_pix, 0, 0, (int)(scale*orig_width), (int)(scale*orig_height), cached_pix,
+			      (width - (int)(scale*orig_width)) / 2, (height - (int)(scale*orig_height)) / 2);
+	g_object_unref (G_OBJECT (scaled_pix));
+      }
     }
   }
    


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