| 2788 return result; |
2788 return result; |
| 2789 } |
2789 } |
| 2790 |
2790 |
| 2791 |
2791 |
| 2792 gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) { |
2792 gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) { |
| 2793 int width, height, rowstride, i; |
2793 int width, height, rowstride, i; |
| 2794 unsigned char *pixels; |
2794 unsigned char *pixels; |
| 2795 unsigned char *row; |
2795 unsigned char *row; |
| 2796 |
2796 |
| 2797 if (!gdk_pixbuf_get_has_alpha(pixbuf)) |
2797 if (!gdk_pixbuf_get_has_alpha(pixbuf)) |
| 2798 return TRUE; |
2798 return TRUE; |
| 2799 |
2799 |
| 2800 width = gdk_pixbuf_get_width (pixbuf); |
2800 width = gdk_pixbuf_get_width (pixbuf); |
| 2801 height = gdk_pixbuf_get_height (pixbuf); |
2801 height = gdk_pixbuf_get_height (pixbuf); |
| 2802 rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
2802 rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
| 2803 pixels = gdk_pixbuf_get_pixels (pixbuf); |
2803 pixels = gdk_pixbuf_get_pixels (pixbuf); |
| 2804 |
2804 |
| 2805 row = pixels; |
2805 row = pixels; |
| 2806 for (i = 3; i < rowstride; i+=4) { |
2806 for (i = 3; i < rowstride; i+=4) { |
| 2807 if (row[i] < 0xfe) |
2807 if (row[i] < 0xfe) |
| 2808 return FALSE; |
2808 return FALSE; |
| 2809 } |
2809 } |
| 2810 |
2810 |
| 2811 for (i = 1; i < height - 1; i++) { |
2811 for (i = 1; i < height - 1; i++) { |
| 2812 row = pixels + (i*rowstride); |
2812 row = pixels + (i * rowstride); |
| 2813 if (row[3] < 0xfe || row[rowstride-1] < 0xfe) { |
2813 if (row[3] < 0xfe || row[rowstride - 1] < 0xfe) { |
| 2814 return FALSE; |
2814 return FALSE; |
| 2815 } |
2815 } |
| 2816 } |
2816 } |
| 2817 |
2817 |
| 2818 row = pixels + ((height-1) * rowstride); |
2818 row = pixels + ((height - 1) * rowstride); |
| 2819 for (i = 3; i < rowstride; i+=4) { |
2819 for (i = 3; i < rowstride; i += 4) { |
| 2820 if (row[i] < 0xfe) |
2820 if (row[i] < 0xfe) |
| 2821 return FALSE; |
2821 return FALSE; |
| 2822 } |
2822 } |
| 2823 |
2823 |
| 2824 return TRUE; |
2824 return TRUE; |
| 2825 } |
2825 } |
| 2826 |
2826 |
| 2827 void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) { |
2827 void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) { |
| 2828 int width, height, rowstride; |
2828 int width, height, rowstride; |
| 2829 guchar *pixels; |
2829 guchar *pixels; |
| 2830 if (!gdk_pixbuf_get_has_alpha(pixbuf)) |
2830 if (!gdk_pixbuf_get_has_alpha(pixbuf)) |
| 2831 return; |
2831 return; |
| 2832 width = gdk_pixbuf_get_width(pixbuf); |
2832 width = gdk_pixbuf_get_width(pixbuf); |
| 2833 height = gdk_pixbuf_get_height(pixbuf); |
2833 height = gdk_pixbuf_get_height(pixbuf); |
| 2834 rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
2834 rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
| 2835 pixels = gdk_pixbuf_get_pixels(pixbuf); |
2835 pixels = gdk_pixbuf_get_pixels(pixbuf); |
| 2836 |
2836 |
| 2837 if (width < 6 || height < 6) |
2837 if (width < 6 || height < 6) |
| 2838 return; |
2838 return; |
| 2839 /* Top left */ |
2839 /* Top left */ |
| 2840 pixels[3] = 0; |
2840 pixels[3] = 0; |
| 2841 pixels[7] = 0x80; |
2841 pixels[7] = 0x80; |
| 2842 pixels[11] = 0xC0; |
2842 pixels[11] = 0xC0; |
| 2843 pixels[rowstride + 3] = 0x80; |
2843 pixels[rowstride + 3] = 0x80; |
| 2844 pixels[rowstride * 2 + 3] = 0xC0; |
2844 pixels[rowstride * 2 + 3] = 0xC0; |
| 2845 |
2845 |
| 2846 /* Top right */ |
2846 /* Top right */ |
| 2847 pixels[width * 4 - 1] = 0; |
2847 pixels[width * 4 - 1] = 0; |
| 2848 pixels[width * 4 - 5] = 0x80; |
2848 pixels[width * 4 - 5] = 0x80; |
| 2849 pixels[width * 4 - 9] = 0xC0; |
2849 pixels[width * 4 - 9] = 0xC0; |
| 2850 pixels[rowstride + (width * 4) - 1] = 0x80; |
2850 pixels[rowstride + (width * 4) - 1] = 0x80; |
| 2851 pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; |
2851 pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; |
| 2852 |
2852 |
| 2853 /* Bottom left */ |
2853 /* Bottom left */ |
| 2854 pixels[(height - 1) * rowstride + 3] = 0; |
2854 pixels[(height - 1) * rowstride + 3] = 0; |
| 2855 pixels[(height - 1) * rowstride + 7] = 0x80; |
2855 pixels[(height - 1) * rowstride + 7] = 0x80; |
| 2856 pixels[(height - 1) * rowstride + 11] = 0xC0; |
2856 pixels[(height - 1) * rowstride + 11] = 0xC0; |
| 2857 pixels[(height - 2) * rowstride + 3] = 0x80; |
2857 pixels[(height - 2) * rowstride + 3] = 0x80; |
| 2858 pixels[(height - 3) * rowstride + 3] = 0xC0; |
2858 pixels[(height - 3) * rowstride + 3] = 0xC0; |
| 2859 |
2859 |
| 2860 /* Bottom right */ |
2860 /* Bottom right */ |
| 2861 pixels[height * rowstride - 1] = 0; |
2861 pixels[height * rowstride - 1] = 0; |
| 2862 pixels[(height - 1) * rowstride - 1] = 0x80; |
2862 pixels[(height - 1) * rowstride - 1] = 0x80; |
| 2863 pixels[(height - 2) * rowstride - 1] = 0xC0; |
2863 pixels[(height - 2) * rowstride - 1] = 0xC0; |
| 2864 pixels[height * rowstride - 5] = 0x80; |
2864 pixels[height * rowstride - 5] = 0x80; |
| 2865 pixels[height * rowstride - 9] = 0xC0; |
2865 pixels[height * rowstride - 9] = 0xC0; |
| 2866 } |
2866 } |
| 2867 |
2867 |
| 2868 const char *pidgin_get_dim_grey_string(GtkWidget *widget) { |
2868 const char *pidgin_get_dim_grey_string(GtkWidget *widget) { |
| 2869 static char dim_grey_string[8] = ""; |
2869 static char dim_grey_string[8] = ""; |
| 2870 GtkStyle *style; |
2870 GtkStyle *style; |