Merge lp:~hzliu123/ubiquity/fix-stretched-wallpaper.lp1207249 into lp:ubiquity

Proposed by Hao-Ran Liu
Status: Rejected
Rejected by: Dimitri John Ledkov
Proposed branch: lp:~hzliu123/ubiquity/fix-stretched-wallpaper.lp1207249
Merge into: lp:ubiquity
Diff against target: 60 lines (+33/-4)
2 files modified
debian/changelog (+6/-1)
src/wallpaper/wallpaper.c (+27/-3)
To merge this branch: bzr merge lp:~hzliu123/ubiquity/fix-stretched-wallpaper.lp1207249
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+178044@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.

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) wrote :

This only needed for precise. Rejecting this branch, will accept the other one.

Unmerged revisions

5972. By Hao-Ran Liu

[ Hao-Ran Liu ]
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)

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-07-31 12:57:08 +0000
3+++ debian/changelog 2013-08-01 11:45:41 +0000
4@@ -5,7 +5,12 @@
5 * Refactor network manager code to create a separte GTK class and
6 base class for both frontends to use
7
8- -- Jonathan Riddell <jriddell@ubuntu.com> Wed, 31 Jul 2013 13:55:44 +0100
9+ [ Hao-Ran Liu ]
10+ * src/wallpaper/wallpaper.c: Cropping wallpaper image instead of stretching
11+ it if image's aspect ratio doesn't match monitor's aspect ratio
12+ (LP: #1207249)
13+
14+ -- Hao-Ran Liu (Joseph Liu) <hao-ran.liu@canonical.com> Thu, 01 Aug 2013 19:27:26 +0800
15
16 ubiquity (2.15.12) saucy; urgency=low
17
18
19=== modified file 'src/wallpaper/wallpaper.c'
20--- src/wallpaper/wallpaper.c 2012-04-23 14:13:08 +0000
21+++ src/wallpaper/wallpaper.c 2013-08-01 11:45:41 +0000
22@@ -98,11 +98,35 @@
23 c = cairo_create (surface);
24 for (monitor = 0; monitor < gdk_screen_get_n_monitors (screen); monitor++) {
25 gdk_screen_get_monitor_geometry (screen, monitor, &monitor_geometry);
26- GdkPixbuf *pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,
27- monitor_geometry.width, monitor_geometry.height,
28- GDK_INTERP_BILINEAR);
29+ int img_w = gdk_pixbuf_get_width(background_pixbuf);
30+ int img_h = gdk_pixbuf_get_height(background_pixbuf);
31+ float monitor_aspect_ratio = (float) monitor_geometry.width / monitor_geometry.height;
32+ float img_aspect_ratio = (float) img_w / img_h;
33+ GdkPixbuf *subpixbuf = NULL;
34+
35+ /* Crop image to fit the aspect ratio of monitor */
36+ if (monitor_aspect_ratio > img_aspect_ratio) {
37+ /* cut areas in upper and bottom edge */
38+ int cut_h = img_h - img_w / monitor_aspect_ratio;
39+ subpixbuf = gdk_pixbuf_new_subpixbuf (background_pixbuf, 0, cut_h/2, img_w, img_h-cut_h);
40+ } else if (monitor_aspect_ratio < img_aspect_ratio) {
41+ /* cut areas in left and right edge */
42+ int cut_w = img_w - img_h * monitor_aspect_ratio;
43+ subpixbuf = gdk_pixbuf_new_subpixbuf (background_pixbuf, cut_w/2, 0, img_w-cut_w, img_h);
44+ }
45+ GdkPixbuf *pixbuf;
46+ if (subpixbuf != NULL)
47+ pixbuf = gdk_pixbuf_scale_simple (subpixbuf,
48+ monitor_geometry.width, monitor_geometry.height,
49+ GDK_INTERP_BILINEAR);
50+ else
51+ pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,
52+ monitor_geometry.width, monitor_geometry.height,
53+ GDK_INTERP_BILINEAR);
54 gdk_cairo_set_source_pixbuf (c, pixbuf, monitor_geometry.x, monitor_geometry.y);
55 g_object_unref (pixbuf);
56+ if (subpixbuf)
57+ g_object_unref (subpixbuf);
58 cairo_paint (c);
59 }
60 cairo_destroy (c);

Subscribers

People subscribed via source and target branches

to status/vote changes: