I have 2 images, one on top of the other. I paint a circle in the 
front-image with xfermode to let the image bellow show through.

I realized this with 2 views in a RelativeLayout. The front-view acts as 
"mask" and is a custom view. 

The problem: Works well in 4.x, but on 2.x the circle is black, instead of 
transparent.


The code:


@Override
public void onDraw(Canvas canvas){
super.onDraw(canvas);

c2.drawCircle(X, Y, 50, pTouch);
Paint new_paint = new Paint();
new_paint.setXfermode(new PorterDuffXfermode(Mode.SRC_ATOP));
rect.set (0, 0, getWidth(), getHeight());
canvas.drawBitmap(overlay, null, rect, new_paint);

}

And c2 was initialized to a canvas with bitmap "overlay", like this:

Bitmap overlay;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false;
overlay = BitmapFactory.decodeResource(getResources(), R.drawable.overlay, 
options);
//...
overlay = Bitmap.createScaledBitmap(overlay, newWidth, newHeight, false);

c2 = new Canvas(overlay);
c2.drawBitmap(overlay, null, rect, filterPaint);


Thanks!

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to