diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtkutil.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index c6534585f8d..59e4328a6fc 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -281,7 +281,7 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f, | |||
| 281 | 281 | ||
| 282 | #if defined USE_CAIRO && !defined HAVE_GTK3 | 282 | #if defined USE_CAIRO && !defined HAVE_GTK3 |
| 283 | static GdkPixbuf * | 283 | static GdkPixbuf * |
| 284 | xg_get_pixbuf_from_surface (struct frame *f, cairo_surface_t *surface) | 284 | xg_get_pixbuf_from_surface (cairo_surface_t *surface) |
| 285 | { | 285 | { |
| 286 | int width = cairo_image_surface_get_width (surface); | 286 | int width = cairo_image_surface_get_width (surface); |
| 287 | int height = cairo_image_surface_get_height (surface); | 287 | int height = cairo_image_surface_get_height (surface); |
| @@ -306,15 +306,20 @@ xg_get_pixbuf_from_surface (struct frame *f, cairo_surface_t *surface) | |||
| 306 | for (int x = 0; x < width; x++) | 306 | for (int x = 0; x < width; x++) |
| 307 | { | 307 | { |
| 308 | guint32 argb = ((guint32 *) pixels)[x]; | 308 | guint32 argb = ((guint32 *) pixels)[x]; |
| 309 | #ifdef WORDS_BIGENDIAN | 309 | int alpha = argb >> 24; |
| 310 | /* ARGB -> RGBA (gdk_pixbuf, big endian) */ | 310 | |
| 311 | ((guint32 *) pixels)[x] = (argb << 8) | (argb >> 24); | 311 | if (alpha == 0) |
| 312 | #else /* !WORDS_BIGENDIAN */ | 312 | ((guint32 *) pixels)[x] = 0; |
| 313 | /* ARGB -> ABGR (gdk_pixbuf, little endian) */ | 313 | else |
| 314 | ((guint32 *) pixels)[x] = (( argb & 0xff00ff00) | 314 | { |
| 315 | | ((argb << 16) & 0x00ff0000) | 315 | int red = (argb >> 16) & 0xff, green = (argb >> 8) & 0xff; |
| 316 | | ((argb >> 16) & 0x000000ff)); | 316 | int blue = argb & 0xff; |
| 317 | #endif /* !WORDS_BIGENDIAN */ | 317 | |
| 318 | pixels[x * 4 ] = red * 0xff / alpha; | ||
| 319 | pixels[x * 4 + 1] = green * 0xff / alpha; | ||
| 320 | pixels[x * 4 + 2] = blue * 0xff / alpha; | ||
| 321 | pixels[x * 4 + 3] = alpha; | ||
| 322 | } | ||
| 318 | } | 323 | } |
| 319 | pixels += rowstride; | 324 | pixels += rowstride; |
| 320 | } | 325 | } |
| @@ -399,7 +404,7 @@ xg_get_image_for_pixmap (struct frame *f, | |||
| 399 | else | 404 | else |
| 400 | gtk_image_set_from_surface (old_widget, surface); | 405 | gtk_image_set_from_surface (old_widget, surface); |
| 401 | #else /* !HAVE_GTK3 */ | 406 | #else /* !HAVE_GTK3 */ |
| 402 | GdkPixbuf *icon_buf = xg_get_pixbuf_from_surface (f, surface); | 407 | GdkPixbuf *icon_buf = xg_get_pixbuf_from_surface (surface); |
| 403 | 408 | ||
| 404 | if (icon_buf) | 409 | if (icon_buf) |
| 405 | { | 410 | { |