iphone开发-图片处理-截屏
来源:互联网 发布:美国制造业数据哪里查 编辑:程序博客网 时间:2024/05/22 06:55
介绍两种图片的处理方法
1,截获当前的屏幕图
2,从大图中截图一小块图
【1】当前的窗口是一个view
CGSize mSize = self.frame.size;
//这个size定义图片的大小
UIGraphicsBeginImageContext(mSize);
//读取当前画布的内容
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *tempImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
#if 0
NSString *path = [NSHomeDirectory() stringByAppendingString:@"/tempImage.jpg"];
NSLog(@"====%@",path);
if ([UIImageJPEGRepresentation(tempImage, 1) writeToFile:path atomically:YES]) {
NSLog(@"success");
}
else {
NSLog(@"failed");
}
#endif
【2】从大图中截取一小图
//大图bigImage
//定义myImageRect,截图的区域
CGRect myImageRect = CGRectMake(10.0, 10.0, 57.0, 57.0);
UIImage* bigImage= [UIImage imageNamed:@"picture.png"];
CGImageRef imageRef = bigImage.CGImage;
CGImageRef subImageRef = CGImageCreateWithImageInRect(imageRef, myImageRect);
CGSize size;
size.width = 57.0;
size.height = 57.0;
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, myImageRect, subImageRef);
UIImage* smallImage = [UIImage imageWithCGImage:subImageRef];
UIGraphicsEndImageContext();
- iphone开发-图片处理-截屏
- iphone开发 图片处理 CIFilter
- iphone开发 图片选择 处理 上传
- iPhone :图片的灰度处理
- iphone开发 图片存相册
- iPhone开发之图片按钮
- iPhone开发指南-事件处理
- iPhone开发指南-事件处理
- iPhone开发指南-事件处理
- iPhone开发指南-事件处理
- iphone开发中对Icon等的图片的Default处理方法
- iphone开发中对Icon等的图片的Default处理方法
- iphone开发——保存图片到相册及容错处理
- iphone处理图片的两个方法
- iPhone How-to:图片的灰度处理
- iphone开发 UIImage图片的缩放、拉伸
- iphone开发——清除图片缓存
- iPhone、iPad开发之图片资源管理
- tablelayout
- 如何从一台被铅封的机器上取走数据
- 一种保护应用程序的方法 模拟Windows PE加载器,从内存资源中加载DLL
- flash 非法覆盖父类方法
- WebService大讲堂之Axis2(5):会话(Session)管理 (转载)
- iphone开发-图片处理-截屏
- JS焦点定位
- 自定义Layout xml文件转换成View对象和Activity关联的实现
- 2011.08.09
- SQL语句大全
- 项目和程序集的区别
- 国际三大评级机构
- 页面生命周期
- ASCII