Re: [GnomeMeeting-devel-list] [PATCH] vfakeio modification
- From: PUYDT Julien <julien puydt laposte net>
- To: GnomeMeeting Devel Liste <gnomemeeting-devel-list gnome org>
- Subject: Re: [GnomeMeeting-devel-list] [PATCH] vfakeio modification
- Date: Mon, 09 Feb 2004 18:11:47 +0100
On lun, 2004-02-09 at 10:50, Damien Sandras wrote:
> Notice that if you select a image bigger than the video size, you only
> have black. Was it your intended behavior? The old behavior in 0.98.5
> was resizing the image.
The following patch changes that behaviour:
* if the image fits in the preview, it is centered;
* if it doesn't, it is first scaled (1:1 to keep the best result), then
centered.
Rants:
* the gdk-pixbuf doc is unclear;
* gdk-pixbuf stores image size in (int) instead of the saner (unsigned);
* the C language's implicit conversions sucks.
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 18:01:15.000000000 +0100
@@ -222,10 +222,35 @@
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;
+
+ if (width < (unsigned)orig_width)
+ scale_w = (double)width / orig_width;
+ else
+ scale_w = 1;
+
+ if (height < (unsigned)orig_height)
+ scale_h = (double)height / orig_height;
+ else
+ scale_h = 1;
+
+ if (scale_w < scale_h)
+ 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]