Mercurial > pidgin.yaz
comparison pidgin/gtkblist.c @ 18212:77b9ceb83426
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 20 Jun 2007 21:00:34 +0000 |
parents | 84b577372b90 |
children | 16bf31872b7a |
comparison
equal
deleted
inserted
replaced
18211:84b577372b90 | 18212:77b9ceb83426 |
---|---|
2092 } | 2092 } |
2093 } | 2093 } |
2094 } | 2094 } |
2095 } | 2095 } |
2096 | 2096 |
2097 static void | |
2098 roundify(GdkPixbuf *pixbuf) { | |
2099 int width, height, rowstride; | |
2100 guchar *pixels; | |
2101 | |
2102 if (!gdk_pixbuf_get_has_alpha(pixbuf)) | |
2103 return; | |
2104 | |
2105 width = gdk_pixbuf_get_width(pixbuf); | |
2106 height = gdk_pixbuf_get_height(pixbuf); | |
2107 rowstride = gdk_pixbuf_get_rowstride(pixbuf); | |
2108 pixels = gdk_pixbuf_get_pixels(pixbuf); | |
2109 | |
2110 if (width < 6 || height < 6) | |
2111 return; | |
2112 | |
2113 /* Top left */ | |
2114 pixels[3] = 0; | |
2115 pixels[7] = 0x80; | |
2116 pixels[11] = 0xC0; | |
2117 pixels[rowstride + 3] = 0x80; | |
2118 pixels[rowstride * 2 + 3] = 0xC0; | |
2119 | |
2120 /* Top right */ | |
2121 pixels[width * 4 - 1] = 0; | |
2122 pixels[width * 4 - 5] = 0x80; | |
2123 pixels[width * 4 - 9] = 0xC0; | |
2124 pixels[rowstride + (width * 4) - 1] = 0x80; | |
2125 pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; | |
2126 | |
2127 /* Bottom left */ | |
2128 pixels[(height - 1) * rowstride + 3] = 0; | |
2129 pixels[(height - 1) * rowstride + 7] = 0x80; | |
2130 pixels[(height - 1) * rowstride + 11] = 0xC0; | |
2131 pixels[(height - 2) * rowstride + 3] = 0x80; | |
2132 pixels[(height - 3) * rowstride + 3] = 0xC0; | |
2133 | |
2134 /* Bottom right */ | |
2135 pixels[height * rowstride - 1] = 0; | |
2136 pixels[(height - 1) * rowstride - 1] = 0x80; | |
2137 pixels[(height - 2) * rowstride - 1] = 0xC0; | |
2138 pixels[height * rowstride - 5] = 0x80; | |
2139 pixels[height * rowstride - 9] = 0xC0; | |
2140 } | |
2141 | |
2142 /* Altered from do_colorshift in gnome-panel */ | 2097 /* Altered from do_colorshift in gnome-panel */ |
2143 static void | 2098 static void |
2144 do_alphashift (GdkPixbuf *dest, GdkPixbuf *src, int shift) | 2099 do_alphashift (GdkPixbuf *dest, GdkPixbuf *src, int shift) |
2145 { | 2100 { |
2146 gint i, j; | 2101 gint i, j; |
2273 | 2228 |
2274 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 32, 32); | 2229 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 32, 32); |
2275 gdk_pixbuf_fill(ret, 0x00000000); | 2230 gdk_pixbuf_fill(ret, 0x00000000); |
2276 gdk_pixbuf_scale(buf, ret, (32-scale_width)/2, (32-scale_height)/2, scale_width, scale_height, (32-scale_width)/2, (32-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); | 2231 gdk_pixbuf_scale(buf, ret, (32-scale_width)/2, (32-scale_height)/2, scale_width, scale_height, (32-scale_width)/2, (32-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); |
2277 if (pidgin_gdk_pixbuf_is_opaque(ret)) | 2232 if (pidgin_gdk_pixbuf_is_opaque(ret)) |
2278 roundify(ret); | 2233 pidgin_gdk_pixbuf_make_round(ret); |
2279 } else { | 2234 } else { |
2280 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); | 2235 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); |
2281 } | 2236 } |
2282 g_object_unref(G_OBJECT(buf)); | 2237 g_object_unref(G_OBJECT(buf)); |
2283 } | 2238 } |