GdkPixbuf and alpha threshold



Hello,
I've read the API documentation for gdk_pixbuf_render_*_alpha() and want
to know what values should be supplied for alpha_threshold. This is not
documented, but I'm guessing that it could be something like
  256 -> all pixels will be transparent
  128 -> pixels with opacity < 0.5 will be transparent
    0 -> all pixels opaque
for 8 bits_per_sample pixbufs. Is that correct?

A float/double value between 0.0 and 1.0 would be more intuitive here,
since it is independent from bits_per_sample. Now I would have to do
something like

double threshold = 0.5; /* opacity threshold between 0.0 and 1.0 */
int alpha_threshold = (int)((1 << gdk_pixbuf_get_bits_per_sample(pixbuf)) *
                        threshold + 0.5);

to make sure that my code still works as expected when a future version of
GdkPixbuf should be able to support other numbers for bits_per_sample.

I'm also a bit confused about gdk_pixbuf_render_to_drawable_alpha(). On
the one hand it has a GdkPixbufAlphaMode and on the other hand it has a
alpha_threshold. The documentation for GDK_PIXBUF_ALPHA_BILEVEL says that
'Pixels below 0.5 opacity will be considered fully transparent, and all
others will be considered fully opaque'. Is that information correct or
should it be 'Pixels with opacity below a threshold will be considered
fully transparent...' ?

Regards...Peter
-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger appss de
URL:    http://www.appss.de

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]