Merge lp:~hzliu123/ubiquity/precise-proposed.lp1207249 into lp:~ubuntu-installer/ubiquity/precise-proposed

Proposed by Hao-Ran Liu
Status: Merged
Merged at revision: 5447
Proposed branch: lp:~hzliu123/ubiquity/precise-proposed.lp1207249
Merge into: lp:~ubuntu-installer/ubiquity/precise-proposed
Diff against target: 58 lines (+35/-3)
2 files modified
debian/changelog (+8/-0)
src/wallpaper/wallpaper.c (+27/-3)
To merge this branch: bzr merge lp:~hzliu123/ubiquity/precise-proposed.lp1207249
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Approve
Review via email: mp+178250@code.launchpad.net

Commit message

src/wallpaper/wallpaper.c: Cropping wallpaper image instead of stretching it if image's aspect ratio doesn't match monitor's aspect ratio (LP: #1207249)

Description of the change

This patch is for fixing bug 1207249 in Precise.

src/wallpaper/wallpaper.c:
Cropping wallpaper image instead of stretching it if image's aspect ratio doesn't match monitor's aspect ratio

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-05-17 14:10:57 +0000
3+++ debian/changelog 2013-08-02 10:18:28 +0000
4@@ -1,3 +1,11 @@
5+ubiquity (2.10.26) UNRELEASED; urgency=low
6+
7+ * src/wallpaper/wallpaper.c: Cropping wallpaper image instead of stretching
8+ it if image's aspect ratio doesn't match monitor's aspect ratio
9+ (LP: #1207249)
10+
11+ -- Hao-Ran Liu (Joseph Liu) <hao-ran.liu@canonical.com> Fri, 02 Aug 2013 18:07:10 +0800
12+
13 ubiquity (2.10.25) precise; urgency=low
14
15 [ Colin Watson ]
16
17=== modified file 'src/wallpaper/wallpaper.c'
18--- src/wallpaper/wallpaper.c 2011-09-22 16:55:55 +0000
19+++ src/wallpaper/wallpaper.c 2013-08-02 10:18:28 +0000
20@@ -85,11 +85,35 @@
21 c = cairo_create (surface);
22 for (monitor = 0; monitor < gdk_screen_get_n_monitors (screen); monitor++) {
23 gdk_screen_get_monitor_geometry (screen, monitor, &monitor_geometry);
24- GdkPixbuf *pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,
25- monitor_geometry.width, monitor_geometry.height,
26- GDK_INTERP_BILINEAR);
27+ int img_w = gdk_pixbuf_get_width(background_pixbuf);
28+ int img_h = gdk_pixbuf_get_height(background_pixbuf);
29+ float monitor_aspect_ratio = (float) monitor_geometry.width / monitor_geometry.height;
30+ float img_aspect_ratio = (float) img_w / img_h;
31+ GdkPixbuf *subpixbuf = NULL;
32+
33+ /* Crop image to fit the aspect ratio of monitor */
34+ if (monitor_aspect_ratio > img_aspect_ratio) {
35+ /* cut areas in upper and bottom edge */
36+ int cut_h = img_h - img_w / monitor_aspect_ratio;
37+ subpixbuf = gdk_pixbuf_new_subpixbuf (background_pixbuf, 0, cut_h/2, img_w, img_h-cut_h);
38+ } else if (monitor_aspect_ratio < img_aspect_ratio) {
39+ /* cut areas in left and right edge */
40+ int cut_w = img_w - img_h * monitor_aspect_ratio;
41+ subpixbuf = gdk_pixbuf_new_subpixbuf (background_pixbuf, cut_w/2, 0, img_w-cut_w, img_h);
42+ }
43+ GdkPixbuf *pixbuf;
44+ if (subpixbuf != NULL)
45+ pixbuf = gdk_pixbuf_scale_simple (subpixbuf,
46+ monitor_geometry.width, monitor_geometry.height,
47+ GDK_INTERP_BILINEAR);
48+ else
49+ pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,
50+ monitor_geometry.width, monitor_geometry.height,
51+ GDK_INTERP_BILINEAR);
52 gdk_cairo_set_source_pixbuf (c, pixbuf, monitor_geometry.x, monitor_geometry.y);
53 g_object_unref (pixbuf);
54+ if (subpixbuf)
55+ g_object_unref (subpixbuf);
56 cairo_paint (c);
57 }
58 cairo_destroy (c);

Subscribers

People subscribed via source and target branches