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
=== modified file 'libunity-2d-private/src/gimageutils.cpp'
--- libunity-2d-private/src/gimageutils.cpp 2011-08-01 10:08:29 +0000
+++ libunity-2d-private/src/gimageutils.cpp 2012-04-24 15:51:19 +0000
@@ -66,16 +66,29 @@
66 return QImage();66 return QImage();
67 }67 }
6868
69 return imageForPixbuf(pixbuf.data());69 return imageForPixbuf(pixbuf.data(), name);
70}70}
7171
72QImage imageForPixbuf(const GdkPixbuf* pixbuf)72QImage imageForPixbuf(const GdkPixbuf* pixbuf, const QString &name)
73{73{
74 QImage image(gdk_pixbuf_get_pixels(pixbuf),74 QImage image;
75 if (gdk_pixbuf_get_n_channels(pixbuf) == 3 && gdk_pixbuf_get_bits_per_sample(pixbuf) == 8 && !gdk_pixbuf_get_has_alpha(pixbuf)) {
76 image = QImage(gdk_pixbuf_get_pixels(pixbuf),
77 gdk_pixbuf_get_width(pixbuf),
78 gdk_pixbuf_get_height(pixbuf),
79 gdk_pixbuf_get_rowstride(pixbuf),
80 QImage::QImage::Format_RGB888);
81 image = image.convertToFormat(QImage::Format_ARGB32);
82 } else {
83 if (gdk_pixbuf_get_n_channels(pixbuf) != 4 || gdk_pixbuf_get_bits_per_sample(pixbuf) != 8 || !gdk_pixbuf_get_has_alpha(pixbuf)) {
84 UQ_WARNING << "Pixbuf is not in the expected format. Trying to load it anyway, will most likely fail" << name;
85 }
86 image = QImage(gdk_pixbuf_get_pixels(pixbuf),
75 gdk_pixbuf_get_width(pixbuf),87 gdk_pixbuf_get_width(pixbuf),
76 gdk_pixbuf_get_height(pixbuf),88 gdk_pixbuf_get_height(pixbuf),
77 gdk_pixbuf_get_rowstride(pixbuf),89 gdk_pixbuf_get_rowstride(pixbuf),
78 QImage::Format_ARGB32);90 QImage::Format_ARGB32);
91 }
7992
80#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN93#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
81 /* ABGR → ARGB */94 /* ABGR → ARGB */
8295
=== modified file 'libunity-2d-private/src/gimageutils.h'
--- libunity-2d-private/src/gimageutils.h 2011-08-01 10:01:01 +0000
+++ libunity-2d-private/src/gimageutils.h 2012-04-24 15:51:19 +0000
@@ -39,7 +39,8 @@
3939
40QImage imageForIconString(const QString& name, int size, struct _GtkIconTheme* theme = 0);40QImage imageForIconString(const QString& name, int size, struct _GtkIconTheme* theme = 0);
4141
42QImage imageForPixbuf(const struct _GdkPixbuf* pixbuf);42/// The @param name is only used for debugging purposes
43QImage imageForPixbuf(const struct _GdkPixbuf* pixbuf, const QString& name);
4344
44} // namespace45} // namespace
4546
4647
=== modified file 'tests/manual-tests/launcher.txt'
--- tests/manual-tests/launcher.txt 2012-04-23 13:13:50 +0000
+++ tests/manual-tests/launcher.txt 2012-04-24 15:51:19 +0000
@@ -148,3 +148,7 @@
148148
149Verify that the progress bar appears and that the filler looks correctly centered inside the bar149Verify that the progress bar appears and that the filler looks correctly centered inside the bar
150----150----
151 * Launch an application whose icon uses 24 bit per pixel instead of 32 (e.g. kmag in precise)
152
153Verify that the icon shows correctly in the launcher
154----

Subscribers

People subscribed via source and target branches