Re: Problem displaying image with alpha channel in a transparent window



Le mercredi 23 juillet 2008 à 08:52 -0400, zentara a écrit :
> On Wed, 23 Jul 2008 10:38:51 +0200
> Yann Droneaud <ydroneaud mandriva com> wrote:
> 
> 
> >  At first, it seems to work, but in fact, as soon as you move the 
> >  picture using CTRL+Button 1, you will realize the problem: the 
> >  window's background is a snapshot of the root window (see post from 
> >  Matt Hoosier [2]), and is fixed for the window's lifetime.
> 
> 
> I don't know if this will help you. I do Perl, and managed to do this
> transparent window with image, maybe you can convert it to c?
> 
> I did notice the artifact problem when loading images that did not
> have a pure black fill, but my example( created with Gimp) looks
> clean.
> 
> I'm no expert, just hacked and got lucky, so don't ask too many
> questions of me. :-)
> 

:)

Your program works fine because you don't use too Composite extension,
32bits colormap and such.

Plus, you explicitly initialize the content of the pixmap with a solid
black value (fully opaque), before drawing the content of the pixbuf on
it.
After you use the content of the pixmap to recreate a new pixbuf on
which you add an alpha channel, used later to create the mask you
supplied to shape_combine_mask() to enable XShape on the window.

XShape is an old, quite deprecated way to create transparent window: it
apply a binary mask, so for image with subtle transparency, such a
shadows, the result is quite ugly and using XShape makes window
redrawing soooooo slow.

On my own pictures with shadows, your program render them incorrectly.

So i've simplified a bit your program to only do useful things to get
the results attended with pictures with alpha values (such as my
sample.png). 

Try to change the alpha cutoff value (currently set to 127) to see the
result, depending on the image changing the alpha cutoff value could
give things awful (for example shadows, if not totally cut off are quite
awful rendered with XShape binary mask).

See attached:
- z-simple: a simplified version of your program, to work with pictures
with alpha value
- sample.png: my test pictures
- simple.png: sample.png draw with z-simple (using XShape).
- xrender.png: sample.png draw with a composite aware program

Regards.

-- 
Yann Droneaud <ydroneaud mandriva com>
Mandriva

Attachment: sample.png
Description: PNG image

Attachment: simple.png
Description: PNG image

Attachment: xrender.png
Description: PNG image

Attachment: z-simple
Description: Perl program



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