1

I want to crop image when user create a particular shape by touching the screen.

For example in the image below when the user touchs and draw a shape (green color here), then the image inside of the shape will be cut out and shown as a new UIImage :

enter image description here

I know how to mask an image and also know how to cut an image in rectangle shape but no idea about this.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ranjeet Sajwan
  • 1,925
  • 2
  • 28
  • 60
  • @Almo I have tried nothing, Because I have no idea how to do it.... – Ranjeet Sajwan Jul 13 '12 at 08:09
  • Then StackOverflow is the wrong place to ask. What you need is a tutorial site, not a Q+A site. StackOverflow is for specific questions about programming problems, not general methodologies. – Almo Jul 13 '12 at 12:01
  • @Almo - I am asking for a programming solution of this. Just don't know how to do this.:( – Ranjeet Sajwan Nov 08 '12 at 04:57
  • And I'm saying that StackOverflow is not where you ask about things you know nothing about. It's for asking things you've devled into, and gotten stuck on. You show us what you've tried, and we help by showing where you've gone wrong. http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – Almo Nov 08 '12 at 14:27
  • This question can be closed as too broad. – halfer Aug 31 '18 at 13:50

1 Answers1

0

Try something like this, it is not EXACTLY the same questions, but a slight change to this algorithm should work for you!!!

Draw border just inside non-transparent portion of image

It does not give exact code for any platform, but gives the mathematical geometry and generic looping algorithm for how to accomplish such a task.

Within iOS you will need to perform the new image creation (and indeed pixel copy over) using CoreGraphics.

Things you will HAVE to look out for. The screen resolution to actual image resolution. If the image resolution is different, then when you perform you math to calculate the crop zone, that crop zone may grow or shrink when translating from the screen to the actual backing image being displayed.

Community
  • 1
  • 1
trumpetlicks
  • 7,033
  • 2
  • 19
  • 33