implemanting freehand crop in android

后端 未结 3 493
猫巷女王i
猫巷女王i 2021-01-02 11:33

i m trying to implement freehand crop in android using canvas. i use drawPath and store it in List and draw it in canvas path drawing ok,

like this

相关标签:
3条回答
  • 2021-01-02 12:04

    Lets look at a bit more complex example:

    example

    The red point is the point you want to test. You have to find the edges that cross the y coordinate of the red point. In this example 4 edges cross the y coordinate (the blue points).

    Now test how much intersections you get on the left side and on the right side of the point you want to check. If there is an odd number of intersections on both sides the point is inside the shape.

    update: you can find a more detailed description of this algorithm here

    0 讨论(0)
  • 2021-01-02 12:19

    Hi i think below link for your exact solution, what u try?

    Android: Free Croping of Image

    Don't forget to put your vote and feedback here.

    0 讨论(0)
  • 2021-01-02 12:26

    You can use Canvas.clipPath to draw only cropped region. But be awared that this method doesn't work with hardware acceleration so you have to turn it off and use software rendering.

    0 讨论(0)
提交回复
热议问题