How can you split the non-rectangular (e.g. oval) portion of a bitmap on an Android canvas?
Think about how you might break a rectangular part of a raster image:
canvas.DrawBitmap(src,src_rect,dest_rect,paint). Unfortunately, there are no suitable methods for non-rectangular areas.
Four approaches are present (perhaps you know the fifth?):
copy the rectangular borders that you want to split into an intermediate bitmap and go to adjust the pixels that you do not want them to be transparent, then draw this bitmap
make a bitmap image of a mask - are there ways to shine with a separate mask?
use BitmapShaderwith drawArc()/drawCircle(); however, I cannot figure out how to get the correct aligned matrix; how would you initialize the matrix for this operation?
Use a very complex clipping area.
Of these, option 3 is the one I would most like to work on; however, I cannot figure out how to do this; You can?
source
share