| 65 width = gdk_pixbuf_get_width(pixbuf); |
65 width = gdk_pixbuf_get_width(pixbuf); |
| 66 height = gdk_pixbuf_get_height(pixbuf); |
66 height = gdk_pixbuf_get_height(pixbuf); |
| 67 rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
67 rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
| 68 pixels = gdk_pixbuf_get_pixels(pixbuf); |
68 pixels = gdk_pixbuf_get_pixels(pixbuf); |
| 69 |
69 |
| 70 if (width < 6 || height < 6) |
70 if (width < 6 || height < 6) { |
| 71 return; |
71 return; |
| |
72 } |
| 72 |
73 |
| 73 /* The following code will conver the alpha of the pixel data in all |
74 /* The following code will conver the alpha of the pixel data in all |
| 74 * corners to look something like the following diagram. |
75 * corners to look something like the following diagram. |
| 75 * |
76 * |
| 76 * 00 80 c0 FF FF c0 80 00 |
77 * 00 80 c0 FF FF c0 80 00 |
| 116 pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) { |
117 pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) { |
| 117 gint height, rowstride, i; |
118 gint height, rowstride, i; |
| 118 guchar *pixels; |
119 guchar *pixels; |
| 119 guchar *row; |
120 guchar *row; |
| 120 |
121 |
| 121 if (!gdk_pixbuf_get_has_alpha(pixbuf)) |
122 if (!gdk_pixbuf_get_has_alpha(pixbuf)) { |
| 122 return TRUE; |
123 return TRUE; |
| |
124 } |
| 123 |
125 |
| 124 height = gdk_pixbuf_get_height (pixbuf); |
126 height = gdk_pixbuf_get_height (pixbuf); |
| 125 rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
127 rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
| 126 pixels = gdk_pixbuf_get_pixels (pixbuf); |
128 pixels = gdk_pixbuf_get_pixels (pixbuf); |
| 127 |
129 |
| 128 /* check the top row */ |
130 /* check the top row */ |
| 129 row = pixels; |
131 row = pixels; |
| 130 for (i = 3; i < rowstride; i+=4) { |
132 for (i = 3; i < rowstride; i+=4) { |
| 131 if (row[i] < 0xfe) |
133 if (row[i] < 0xfe) { |
| 132 return FALSE; |
134 return FALSE; |
| |
135 } |
| 133 } |
136 } |
| 134 |
137 |
| 135 /* check the left and right sides */ |
138 /* check the left and right sides */ |
| 136 for (i = 1; i < height - 1; i++) { |
139 for (i = 1; i < height - 1; i++) { |
| 137 row = pixels + (i * rowstride); |
140 row = pixels + (i * rowstride); |
| 138 if (row[3] < 0xfe || row[rowstride - 1] < 0xfe) { |
141 if (row[3] < 0xfe || row[rowstride - 1] < 0xfe) { |
| 139 return FALSE; |
142 return FALSE; |
| 140 } |
143 } |
| 141 } |
144 } |
| 142 |
145 |
| 143 /* check the bottom */ |
146 /* check the bottom */ |
| 144 row = pixels + ((height - 1) * rowstride); |
147 row = pixels + ((height - 1) * rowstride); |
| 145 for (i = 3; i < rowstride; i += 4) { |
148 for (i = 3; i < rowstride; i += 4) { |
| 146 if (row[i] < 0xfe) |
149 if (row[i] < 0xfe) { |
| 147 return FALSE; |
150 return FALSE; |
| |
151 } |
| 148 } |
152 } |
| 149 |
153 |
| 150 return TRUE; |
154 return TRUE; |
| 151 } |
155 } |
| 152 |
156 |