截取小图
来源:互联网 发布:mac 安装应用 编辑:程序博客网 时间:2024/05/16 08:33
- (UIImage*)getImageFromView:(UIView*)view atFrame:(CGRect)frame
{
UIGraphicsBeginImageContext(view.frame.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
// UIRectClip(frame);
[view.layerrenderInContext:ctx];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIImage * smallImage = [UIImageimageWithCGImage:CGImageCreateWithImageInRect([imageCGImage], frame)];
UIGraphicsEndImageContext();
return smallImage;
}
{
UIGraphicsBeginImageContext(view.frame.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
// UIRectClip(frame);
[view.layerrenderInContext:ctx];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIImage * smallImage = [UIImageimageWithCGImage:CGImageCreateWithImageInRect([imageCGImage], frame)];
UIGraphicsEndImageContext();
return smallImage;
}
上边代码可以实现在视图中截取指定frame的图片。
保存到相册中:UIImageWriteToSavedPhotosAlbum(smallImage,self,nil,nil);
0 0
- 截取小图
- 字符串截取小技巧
- php小技巧-截取后缀
- 中文字符串截取小案例
- ORCLE 数据库截取小方式
- 大图片中截取其中一部分小图显示 两图合成一图[转载]
- 实用小技巧之电脑如何滚动截屏/截取长图
- 如何从一幅大图里面截取一段小图 (使用background-position)
- 小技巧----java中字符串的截取
- Java 小例子:按字节截取字符串
- 如何截取大图中的小图标
- Qt 截取屏幕的小demo
- Apache Pig字符串截取实战小例子
- JAVA 正则表达式截取字符串小例子
- 关于字符串截取的一个小问题
- smarty使用小技巧——截取小技巧
- android截取屏幕图
- android截取屏幕图
- TCP协议疑难杂症全景解析
- ACTIVEPERL 5.10无法ppm安装
- [转载]小白鼠喝药水找毒药——面试题
- 小知识
- ubuntu 使用 VNC
- 截取小图
- ubuntu 13.04 sources.list 软件源
- 天天酷跑
- vim使用
- ios的设计原则
- 关于java.lang.IllegalStateException: Fragment already added的一些问题
- ListView异步加载网络信息包括图片功能
- 民政部投474亿福彩公益金支持老年福利项目
- 如何复制百度文库中的文章。。。这个必须留一份。。。