Is there a way to crop images in a non-rectangular shape on iOS? What I need is for a person to be able to draw a circle (or what ever closing shape) with their finger inside an image and select "Crop". This will make the content inside the shape stay, and the outside be "removed". Not black, but a transparent save. If I then have two UIImageView's ontop of eachother in one view, and place the customly cropped image on the top, I need the image in back to be visible outside the shape.
Asked
Active
Viewed 1,460 times
5
-
I also need to do to something like this.Please tell me how did you achieve this.Please help me and post your answer. – Gypsa Nov 07 '12 at 10:25
1 Answers
4
Yes, you would use a CGImageMask
.

Bhargav Rao
- 50,140
- 28
- 121
- 140

justin
- 104,054
- 14
- 179
- 226
-
in the second link they have used a ready made image as a mask image, can you please tell how to create a mask image from finger drawing.Please help me. – Gypsa Nov 07 '12 at 10:41
-
@Gypsa well, it's not so simple if your input is a finger drawing outline. first, you would need to draw into a grayscale CGBitmapContext (which had a component layout compatible with a mask). then if you had only the outline, you would manually fill in the pixels inside the user's outline (just evaluate the bitmap's values). then take that bitmap and create a mask from it. you could also draw an image into that context, if that is your input. – justin Nov 07 '12 at 18:16
-
-
sorry - i've explained the process and technologies you would use, but the coding part takes a bit of time. – justin Nov 07 '12 at 18:23