I only understand your question partially, if you are looking to crop an UIImage, check out the below code:
//Pass the UIImage object and the varying rectangle you "outputrect"
- (UIImage *)cropImage:(UIImage *)image outPutRect:(CGRect) outputRect
{
CGImageRef takenCGImage = image.CGImage;
size_t width = CGImageGetWidth(takenCGImage);
size_t height = CGImageGetHeight(takenCGImage);
CGRect cropRect = CGRectMake(outputRect.origin.x * width, outputRect.origin.y * height,
outputRect.size.width * width, outputRect.size.height * height);
CGImageRef cropCGImage = CGImageCreateWithImageInRect(takenCGImage, cropRect);
image = [UIImage imageWithCGImage:cropCGImage scale:1 orientation:image.imageOrientation];
CGImageRelease(cropCGImage);
return image;
}