fix alpha multiplication routine to perhaps work correctly, reported by
2002-04-09 Havoc Pennington <hp@pobox.com> * src/theme.c (multiply_alpha): fix alpha multiplication routine to perhaps work correctly, reported by tigert. Also, be sure we always copy the image if necessary before modifying the alpha channel.
This commit is contained in:
parent
fa0592ebc7
commit
38ff6a49c4
@ -1,3 +1,10 @@
|
|||||||
|
2002-04-09 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
|
* src/theme.c (multiply_alpha): fix alpha multiplication routine
|
||||||
|
to perhaps work correctly, reported by tigert. Also, be sure
|
||||||
|
we always copy the image if necessary before modifying the
|
||||||
|
alpha channel.
|
||||||
|
|
||||||
2002-04-05 Havoc Pennington <hp@pobox.com>
|
2002-04-05 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
* src/stack.c: remove the unused tab stuff
|
* src/stack.c: remove the unused tab stuff
|
||||||
|
20
src/theme.c
20
src/theme.c
@ -2460,7 +2460,8 @@ get_gc_for_primitive (GtkWidget *widget,
|
|||||||
|
|
||||||
static GdkPixbuf*
|
static GdkPixbuf*
|
||||||
multiply_alpha (GdkPixbuf *pixbuf,
|
multiply_alpha (GdkPixbuf *pixbuf,
|
||||||
guchar alpha)
|
guchar alpha,
|
||||||
|
gboolean force_copy)
|
||||||
{
|
{
|
||||||
GdkPixbuf *new_pixbuf;
|
GdkPixbuf *new_pixbuf;
|
||||||
guchar *pixels;
|
guchar *pixels;
|
||||||
@ -2479,6 +2480,14 @@ multiply_alpha (GdkPixbuf *pixbuf,
|
|||||||
g_object_unref (G_OBJECT (pixbuf));
|
g_object_unref (G_OBJECT (pixbuf));
|
||||||
pixbuf = new_pixbuf;
|
pixbuf = new_pixbuf;
|
||||||
}
|
}
|
||||||
|
else if (force_copy)
|
||||||
|
{
|
||||||
|
new_pixbuf = gdk_pixbuf_copy (pixbuf);
|
||||||
|
g_object_unref (G_OBJECT (pixbuf));
|
||||||
|
pixbuf = new_pixbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
|
||||||
|
|
||||||
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||||
@ -2502,7 +2511,8 @@ multiply_alpha (GdkPixbuf *pixbuf,
|
|||||||
* then it should be modified to contain "alpha"; if the
|
* then it should be modified to contain "alpha"; if the
|
||||||
* pixbuf contains 0, it should remain 0.
|
* pixbuf contains 0, it should remain 0.
|
||||||
*/
|
*/
|
||||||
*p = (*p * alpha) / 65025; /* (*p / 255) * (alpha / 255); */
|
/* ((*p / 255.0) * (alpha / 255.0)) * 255; */
|
||||||
|
*p = (guchar) (((int) *p * (int) alpha) / (int) 255);
|
||||||
|
|
||||||
++p; /* skip A */
|
++p; /* skip A */
|
||||||
}
|
}
|
||||||
@ -2597,7 +2607,8 @@ scale_and_alpha_pixbuf (GdkPixbuf *src,
|
|||||||
|
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
pixbuf = multiply_alpha (pixbuf,
|
pixbuf = multiply_alpha (pixbuf,
|
||||||
ALPHA_TO_UCHAR (alpha));
|
ALPHA_TO_UCHAR (alpha),
|
||||||
|
pixbuf == src);
|
||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
@ -2672,7 +2683,8 @@ draw_op_as_pixbuf (const MetaDrawOp *op,
|
|||||||
widget, width, height);
|
widget, width, height);
|
||||||
|
|
||||||
pixbuf = multiply_alpha (pixbuf,
|
pixbuf = multiply_alpha (pixbuf,
|
||||||
ALPHA_TO_UCHAR (op->data.gradient.alpha));
|
ALPHA_TO_UCHAR (op->data.gradient.alpha),
|
||||||
|
FALSE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user