gdip-pixbuf-loader r11 - in trunk: . src
- From: doml svn gnome org
- To: svn-commits-list gnome org
- Subject: gdip-pixbuf-loader r11 - in trunk: . src
- Date: Mon, 18 Feb 2008 17:27:13 +0000 (GMT)
Author: doml
Date: Mon Feb 18 17:27:13 2008
New Revision: 11
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=11&view=rev
Log:
2008-02-18 Dominic Lachowicz <domlachowicz gmail com>
* src/io-gdip.c (gdk_pixbuf__gdip_image_stop_load): Un-premultiply alpha
Modified:
trunk/ChangeLog
trunk/src/io-gdip.c
Modified: trunk/src/io-gdip.c
==============================================================================
--- trunk/src/io-gdip.c (original)
+++ trunk/src/io-gdip.c Mon Feb 18 17:27:13 2008
@@ -171,6 +171,7 @@
{
ARGB pixel;
guchar * channel;
+ guint8 alpha;
pixel = io_gdip_bitmap_get_pixel (bitmap, x, y);
channel = (guchar*) &pixel;
@@ -178,13 +179,16 @@
if (y > 0) cursor += y * x * n_channels;
else cursor += x * n_channels;
-// cursor += y * rowstride; //Something wrong here rowstride=1604
-
-
- cursor[0] = channel[1];
- cursor[1] = channel[2];
- cursor[2] = channel[3];
- cursor[3] = channel[0];
+ /* un-premultiply alpha */
+ alpha = (pixel & 0xff000000) >> 24;
+ if (alpha == 0) {
+ cursor[0] = cursor[1] = cursor[2] = cursor[3] = 0;
+ } else {
+ cursor[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
+ cursor[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
+ cursor[2] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
+ cursor[3] = alpha;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]