graphics - drawing part of a bitmap on an Android canvas -


how can blit non-rectangular (e.g. oval) part of bitmap canvas on android?

consider how you'd blit rectangular part of bitmap: canvas.drawbitmap(src,src_rect,dest_rect,paint). sadly there no corresponding methods non-rectangular regions.

four approaches present (maybe know fifth?):

  1. copy rectangular bounds want blit intermediate bitmap, , go setting pixels don't want blit transparent, draw bitmap

  2. make mask bitmap - there ways blit separate mask?

  3. use bitmapshader drawarc()/drawcircle(); however, can't work out how matrix aligned; how initialize matrix operation?

  4. use very complicated clipping region

of these, option 3 1 work; however, cannot work out how so; can you?

you can use option number #3, it's easiest. way draw shape want clip in intermediate bitmap (argb8888), draw original bitmap using dstin or dstout xfermode.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -