Merge lp:~aacid/unity-2d/load_24bit_pixbuf_icons_2 into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 1080
Merged at revision: 1080
Proposed branch: lp:~aacid/unity-2d/load_24bit_pixbuf_icons_2
Merge into: lp:unity-2d
Diff against target: 62 lines (+22/-4)
3 files modified
libunity-2d-private/src/gimageutils.cpp (+16/-3)
libunity-2d-private/src/gimageutils.h (+2/-1)
tests/manual-tests/launcher.txt (+4/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/load_24bit_pixbuf_icons_2
Reviewer Review Type Date Requested Status
Gerry Boland Pending
Review via email: mp+103311@code.launchpad.net

Commit message

[lib] Support 24 bit pixbuf to QImage conversion (e.g. for kmag icon in Launcher)

Description of the change

Support 24 bit pixbuf to QImage conversion (e.g. for kmag icon)
UNBLOCK

To post a comment you must log in.
1079. By Albert Astals Cid

Merge lp:unity-2d

1080. By Albert Astals Cid

fix whitespace

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/gimageutils.cpp'
2--- libunity-2d-private/src/gimageutils.cpp 2011-08-01 10:08:29 +0000
3+++ libunity-2d-private/src/gimageutils.cpp 2012-04-24 15:51:19 +0000
4@@ -66,16 +66,29 @@
5 return QImage();
6 }
7
8- return imageForPixbuf(pixbuf.data());
9+ return imageForPixbuf(pixbuf.data(), name);
10 }
11
12-QImage imageForPixbuf(const GdkPixbuf* pixbuf)
13+QImage imageForPixbuf(const GdkPixbuf* pixbuf, const QString &name)
14 {
15- QImage image(gdk_pixbuf_get_pixels(pixbuf),
16+ QImage image;
17+ if (gdk_pixbuf_get_n_channels(pixbuf) == 3 && gdk_pixbuf_get_bits_per_sample(pixbuf) == 8 && !gdk_pixbuf_get_has_alpha(pixbuf)) {
18+ image = QImage(gdk_pixbuf_get_pixels(pixbuf),
19+ gdk_pixbuf_get_width(pixbuf),
20+ gdk_pixbuf_get_height(pixbuf),
21+ gdk_pixbuf_get_rowstride(pixbuf),
22+ QImage::QImage::Format_RGB888);
23+ image = image.convertToFormat(QImage::Format_ARGB32);
24+ } else {
25+ if (gdk_pixbuf_get_n_channels(pixbuf) != 4 || gdk_pixbuf_get_bits_per_sample(pixbuf) != 8 || !gdk_pixbuf_get_has_alpha(pixbuf)) {
26+ UQ_WARNING << "Pixbuf is not in the expected format. Trying to load it anyway, will most likely fail" << name;
27+ }
28+ image = QImage(gdk_pixbuf_get_pixels(pixbuf),
29 gdk_pixbuf_get_width(pixbuf),
30 gdk_pixbuf_get_height(pixbuf),
31 gdk_pixbuf_get_rowstride(pixbuf),
32 QImage::Format_ARGB32);
33+ }
34
35 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
36 /* ABGR → ARGB */
37
38=== modified file 'libunity-2d-private/src/gimageutils.h'
39--- libunity-2d-private/src/gimageutils.h 2011-08-01 10:01:01 +0000
40+++ libunity-2d-private/src/gimageutils.h 2012-04-24 15:51:19 +0000
41@@ -39,7 +39,8 @@
42
43 QImage imageForIconString(const QString& name, int size, struct _GtkIconTheme* theme = 0);
44
45-QImage imageForPixbuf(const struct _GdkPixbuf* pixbuf);
46+/// The @param name is only used for debugging purposes
47+QImage imageForPixbuf(const struct _GdkPixbuf* pixbuf, const QString& name);
48
49 } // namespace
50
51
52=== modified file 'tests/manual-tests/launcher.txt'
53--- tests/manual-tests/launcher.txt 2012-04-23 13:13:50 +0000
54+++ tests/manual-tests/launcher.txt 2012-04-24 15:51:19 +0000
55@@ -148,3 +148,7 @@
56
57 Verify that the progress bar appears and that the filler looks correctly centered inside the bar
58 ----
59+ * Launch an application whose icon uses 24 bit per pixel instead of 32 (e.g. kmag in precise)
60+
61+Verify that the icon shows correctly in the launcher
62+----

Subscribers

People subscribed via source and target branches