ps:东西太多了
缩放
- (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size {
UIImage *newImg;
UIGraphicsBeginImageContext(size);
CGRect imageRect = CGRectMake(0, 0, size.width, size.height);
[image drawInRect:imageRect];
UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImg;
}
截取
- (UIImage *)captureImage:(UIImage *)image toSize:(CGRect)rect {
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *captureImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return captureImage;
}
网友评论