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
=== modified file 'debian/changelog'
--- debian/changelog 2013-05-17 14:10:57 +0000
+++ debian/changelog 2013-08-02 10:18:28 +0000
@@ -1,3 +1,11 @@
1ubiquity (2.10.26) UNRELEASED; urgency=low
2
3 * src/wallpaper/wallpaper.c: Cropping wallpaper image instead of stretching
4 it if image's aspect ratio doesn't match monitor's aspect ratio
5 (LP: #1207249)
6
7 -- Hao-Ran Liu (Joseph Liu) <hao-ran.liu@canonical.com> Fri, 02 Aug 2013 18:07:10 +0800
8
1ubiquity (2.10.25) precise; urgency=low9ubiquity (2.10.25) precise; urgency=low
210
3 [ Colin Watson ]11 [ Colin Watson ]
412
=== modified file 'src/wallpaper/wallpaper.c'
--- src/wallpaper/wallpaper.c 2011-09-22 16:55:55 +0000
+++ src/wallpaper/wallpaper.c 2013-08-02 10:18:28 +0000
@@ -85,11 +85,35 @@
85 c = cairo_create (surface);85 c = cairo_create (surface);
86 for (monitor = 0; monitor < gdk_screen_get_n_monitors (screen); monitor++) {86 for (monitor = 0; monitor < gdk_screen_get_n_monitors (screen); monitor++) {
87 gdk_screen_get_monitor_geometry (screen, monitor, &monitor_geometry);87 gdk_screen_get_monitor_geometry (screen, monitor, &monitor_geometry);
88 GdkPixbuf *pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,88 int img_w = gdk_pixbuf_get_width(background_pixbuf);
89 monitor_geometry.width, monitor_geometry.height,89 int img_h = gdk_pixbuf_get_height(background_pixbuf);
90 GDK_INTERP_BILINEAR);90 float monitor_aspect_ratio = (float) monitor_geometry.width / monitor_geometry.height;
91 float img_aspect_ratio = (float) img_w / img_h;
92 GdkPixbuf *subpixbuf = NULL;
93
94 /* Crop image to fit the aspect ratio of monitor */
95 if (monitor_aspect_ratio > img_aspect_ratio) {
96 /* cut areas in upper and bottom edge */
97 int cut_h = img_h - img_w / monitor_aspect_ratio;
98 subpixbuf = gdk_pixbuf_new_subpixbuf (background_pixbuf, 0, cut_h/2, img_w, img_h-cut_h);
99 } else if (monitor_aspect_ratio < img_aspect_ratio) {
100 /* cut areas in left and right edge */
101 int cut_w = img_w - img_h * monitor_aspect_ratio;
102 subpixbuf = gdk_pixbuf_new_subpixbuf (background_pixbuf, cut_w/2, 0, img_w-cut_w, img_h);
103 }
104 GdkPixbuf *pixbuf;
105 if (subpixbuf != NULL)
106 pixbuf = gdk_pixbuf_scale_simple (subpixbuf,
107 monitor_geometry.width, monitor_geometry.height,
108 GDK_INTERP_BILINEAR);
109 else
110 pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,
111 monitor_geometry.width, monitor_geometry.height,
112 GDK_INTERP_BILINEAR);
91 gdk_cairo_set_source_pixbuf (c, pixbuf, monitor_geometry.x, monitor_geometry.y);113 gdk_cairo_set_source_pixbuf (c, pixbuf, monitor_geometry.x, monitor_geometry.y);
92 g_object_unref (pixbuf);114 g_object_unref (pixbuf);
115 if (subpixbuf)
116 g_object_unref (subpixbuf);
93 cairo_paint (c);117 cairo_paint (c);
94 }118 }
95 cairo_destroy (c);119 cairo_destroy (c);

Subscribers

People subscribed via source and target branches