加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

iOS开发 图片镜像处理

(2017-06-26 10:10:56)
标签:

it

ios开发

图片镜像

镜像处理

image翻转

分类: iOS开发
iOS开发——图片镜像处理,获取一张图片的镜像,需要修改图片源数据,重绘图片。方法如下:

- (UIImage *)mirrorImageWith:(UIImage *)img{

    CGRect rect =  CGRectMake(0, 0, img.size.width , img.size.height);

    UIGraphicsBeginImageContextWithOptions(rect.size, false, 2);

    CGContextRef currentContext =  UIGraphicsGetCurrentContext();

    CGContextClipToRect(currentContext, rect);

    CGContextRotateCTM(currentContext, M_PI);

    CGContextTranslateCTM(currentContext, -rect.size.width, -rect.size.height);

    CGContextDrawImage(currentContext, rect, img.CGImage);

    UIImage* drawImage =  UIGraphicsGetImageFromCurrentImageContext();

    return [UIImage imageWithCGImage:drawImage.CGImage scale:img.scale orientation:img.imageOrientation];

}


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有