/**
* 截取部分图像
*
* @param rect 裁剪的区域
* @param image 要裁剪的image
* return 根据rect裁剪完的image
*
*/
- (UIImage *)captureWithRect:(CGRect)rect Image:(UIImage *)image {
CGImageRef subImageRef = CGImageCreateWithImageInRect(image.CGImage,
CGRectMake(rect.origin.x,
rect.origin.y,
rect.size.width * image.scale,
rect.size.height * image.scale));
CGRect smallBounds = CGRectMake(0, 0, CGImageGetWidth(subImageRef), CGImageGetHeight(subImageRef));
//UIGraphicsBeginImageContext(smallBounds.size);
UIGraphicsBeginImageContextWithOptions(smallBounds.size, NO, [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, smallBounds, subImageRef);
UIImage* smallImage = [UIImage imageWithCGImage:subImageRef];
UIGraphicsEndImageContext();
return smallImage;
}