转换坐标系
图像截屏
- (UIImage *)screenShotOfView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(self.imageView.frame.size, YES, 0.0);
[self.imageView drawViewHierarchyInRect:self.imageView.frame afterScreenUpdates:NO];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
水印
- (UIImage *)addlogoImage:(UIImage *)resizedImage
{
UIGraphicsBeginImageContext(resizedImage.size);
[resizedImage drawInRect:CGRectMake(0, 0, resizedImage.size.width, resizedImage.size.height)];
UIImage *maskImage = [UIImage imageNamed:@"dzh_logo.png"];
[maskImage drawInRect:CGRectMake((resizedImage.size.width - maskImage.size.width)/2,
(resizedImage.size.height - maskImage.size.height)/2,
maskImage.size.width,
maskImage.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
网友评论