Cutting a multipoint ploygon out of Bitmap and placing it on transparency

前端 未结 1 1126
轻奢々
轻奢々 2020-12-15 14:33

I have a bitmap out of which I\'m cutting out a multipi point polygon. I\'m curious what the correct process is for taking the pixels within the arbitrary shape and copying

相关标签:
1条回答
  • 2020-12-15 14:50

    Not sure how your code works, but here's an idea on how to do it:

    1. Calculate the bounding rectangle of the selected area (find min x, min y, max x and max y from your points).
    2. Crop your image to the bounding rectangle using any of the Bitmap or Canvas-methods.
    3. Create a Path from your points, all moved into your new bitmap (x-=minX, y-=minY);
    4. Set your Paths FillType to one that is inverse (fill the outside).
    5. On your new cropped canvas, draw the Path using a paint with the Xfermode as PorterDuff.CLEAR, which removes all color.
    0 讨论(0)
提交回复
热议问题