How do I antialias the clip boundary on Android's canvas? -


i'm using android's android.graphics.canvas class to draw ring. ondraw method clips canvas make hole inner circle, , draws full outer circle on hole:

    clip = new path();     clip.addrect(outercircle, path.direction.cw);     clip.addoval(innercircle, path.direction.ccw);      canvas.save();     canvas.clippath(clip);     canvas.drawoval(outercircle, lightgrey);     canvas.restore(); 

the result ring pretty, anti-aliased outer edge , jagged, ugly inner edge:

aliased

what can antialias inner edge?

i don't want cheat drawing grey circle in middle because dialog transparent. (this transparency isn't subtle on on other backgrounds.)

afaik, can't antialias clip regions.

i'd suggest using bitmap masking instead. render the pink, white, , light gray foreground 1 bitmap, render outer/inner circle mask (the grayscale alpha channel) bitmap, , use paint.setxfermode render foreground bitmap mask alpha channel.

an example can found in apidemos source code here:


edit: measure, here's screenshot of activity in api demos, illustrating masking:

xfermodes screenshot http://nikonizer.yfrog.com/himg46/scaled.php?tn=0&server=46&filename=xfermodes.png&xsize=640&ysize=640


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -