I did a simple test today, with a camera preview and a View subclass
on top of it, in a FrameLayout. The View subclass simply draws a
number of white squares in it's onDraw method (see code below).
I expected five white squares with varying transparency, but the
result is a number of squares with varying shades of grey. I recon
this is because the compositing done by the window manager uses an
xfermode of DST_IN or similar, where the destination color is
multiplied by the source alpha (Sa*Dc). For various reasons, I need
the behaviour to be something more like an overlay where the src alpha
is treated like a mask (imagine trying to make a viewfinder "peephole"
where the edges are translucent without darkening the preview pixels
underneath it).

Is this at all possible?

protected void onDraw(Canvas canvas) {

       Paint p = new Paint();
        for(int i=0; i < 5;i++) {
                p.setColor(0xffffffff);
                p.setAlpha(i*20);
                canvas.drawRect(i*40, 100, i*40+40, 140, p);
        }

             super.onDraw(canvas);
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to