I tried to take a part of an UIImage
using Objective-C, but can't find anything about how to do this. I'd like help figuring out how to do this and the steps involved.
Asked
Active
Viewed 534 times
-4
-
what exactly do you want to achieve? – Femaref Jun 15 '13 at 14:24
-
Just make out of one image two separeted images. – Bastien Olivier Dijkstra Jun 15 '13 at 14:25
-
Out of curiosity, why are you a we as opposed to an I? Do you also refer to yourself as The Many? – Jun 15 '13 at 14:55
-
No, we are two people searching for an answer. – Bastien Olivier Dijkstra Jun 15 '13 at 15:00
-
In that case, it might be better to stick with "I" regardless, seeing as you probably don't want to explain that every time you use "we" and it looks weird. Shame you ignored the System Shock reference, though. – Jun 15 '13 at 15:14
1 Answers
2
Try this.. This splits the image in two parts, more speciffically in half.
UIImage *image = [UIImage imageNamed:@"theImageYouWantToSplit.png"];
CGImageRef temporaryImageReference = image.CGImage;
CGImageRef topImageReference = CGImageCreateWithImageInRect(temporaryImageReference, CGRectMake(0, 0, image.size.width, image.size.height / 2.0));
UIImage *topImage = [UIImage imageWithCGImage:topImageReference];
CGImageRelease(topImageReference);
CGImageRef bottomImageReference = CGImageCreateWithImageInRect(temporaryImageReference, CGRectMake(0, image.size.height / 2.0, image.size.width, image.size.height / 2.0));
UIImage *bottomImage = [UIImage imageWithCGImage:bottomImageReference];
CGImageRelease(bottomImageReference);

7c9d6b001a87e497d6b96fbd4c6fdf
- 1,930
- 1
- 21
- 43