I am trying to use CGImageCreateWithImageInRect to get a sub-image from an image but it's not working properly. It returns the image from a random place in the image, rather than the one I specify. Please take a look at the following image;
My code is:
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(524, 1331, 600, 600));
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
But that doesn't work. What am I doing wrong?
Thanks!