pidgin/gtkutils.c

changeset 39568
f4714f1de6d0
parent 39561
bd42e65927cf
child 39665
2172e3b8eeef
equal deleted inserted replaced
39567:34043d9fcdf9 39568:f4714f1de6d0
2690 g_free(normalized); 2690 g_free(normalized);
2691 2691
2692 return result; 2692 return result;
2693 } 2693 }
2694 2694
2695
2696 gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) {
2697 int height, rowstride, i;
2698 unsigned char *pixels;
2699 unsigned char *row;
2700
2701 if (!gdk_pixbuf_get_has_alpha(pixbuf))
2702 return TRUE;
2703
2704 height = gdk_pixbuf_get_height (pixbuf);
2705 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
2706 pixels = gdk_pixbuf_get_pixels (pixbuf);
2707
2708 row = pixels;
2709 for (i = 3; i < rowstride; i+=4) {
2710 if (row[i] < 0xfe)
2711 return FALSE;
2712 }
2713
2714 for (i = 1; i < height - 1; i++) {
2715 row = pixels + (i * rowstride);
2716 if (row[3] < 0xfe || row[rowstride - 1] < 0xfe) {
2717 return FALSE;
2718 }
2719 }
2720
2721 row = pixels + ((height - 1) * rowstride);
2722 for (i = 3; i < rowstride; i += 4) {
2723 if (row[i] < 0xfe)
2724 return FALSE;
2725 }
2726
2727 return TRUE;
2728 }
2729
2730 void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) {
2731 int width, height, rowstride;
2732 guchar *pixels;
2733 if (!gdk_pixbuf_get_has_alpha(pixbuf))
2734 return;
2735 width = gdk_pixbuf_get_width(pixbuf);
2736 height = gdk_pixbuf_get_height(pixbuf);
2737 rowstride = gdk_pixbuf_get_rowstride(pixbuf);
2738 pixels = gdk_pixbuf_get_pixels(pixbuf);
2739
2740 if (width < 6 || height < 6)
2741 return;
2742 /* Top left */
2743 pixels[3] = 0;
2744 pixels[7] = 0x80;
2745 pixels[11] = 0xC0;
2746 pixels[rowstride + 3] = 0x80;
2747 pixels[rowstride * 2 + 3] = 0xC0;
2748
2749 /* Top right */
2750 pixels[width * 4 - 1] = 0;
2751 pixels[width * 4 - 5] = 0x80;
2752 pixels[width * 4 - 9] = 0xC0;
2753 pixels[rowstride + (width * 4) - 1] = 0x80;
2754 pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0;
2755
2756 /* Bottom left */
2757 pixels[(height - 1) * rowstride + 3] = 0;
2758 pixels[(height - 1) * rowstride + 7] = 0x80;
2759 pixels[(height - 1) * rowstride + 11] = 0xC0;
2760 pixels[(height - 2) * rowstride + 3] = 0x80;
2761 pixels[(height - 3) * rowstride + 3] = 0xC0;
2762
2763 /* Bottom right */
2764 pixels[height * rowstride - 1] = 0;
2765 pixels[(height - 1) * rowstride - 1] = 0x80;
2766 pixels[(height - 2) * rowstride - 1] = 0xC0;
2767 pixels[height * rowstride - 5] = 0x80;
2768 pixels[height * rowstride - 9] = 0xC0;
2769 }
2770
2771 const char *pidgin_get_dim_grey_string(GtkWidget *widget) { 2695 const char *pidgin_get_dim_grey_string(GtkWidget *widget) {
2772 static char dim_grey_string[8] = ""; 2696 static char dim_grey_string[8] = "";
2773 GtkStyleContext *context; 2697 GtkStyleContext *context;
2774 GdkRGBA fg, bg; 2698 GdkRGBA fg, bg;
2775 2699

mercurial