[iOS]图片压缩&保存View为内容Img
来源:互联网 发布:外汇查询软件下载 编辑:程序博客网 时间:2024/06/02 01:49
1、图片的压缩
封装类方法
+ (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize{ // Create a graphics image context UIGraphicsBeginImageContext(newSize); // Tell the old image to draw in this new context, with the desired // new size [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; // Get the new image from the context UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); // End the context UIGraphicsEndImageContext(); // Return the new image. return newImage;}
//屏幕截图并压缩 UIImage *snapshot = [UIImage imageWithCGImage:[AppDelegate screenShots].CGImage scale:1 orientation:UIImageOrientationLeft]; _updataImg =[AppDelegate imageWithImageSimple:snapshot scaledToSize:CGSizeMake(snapshot.size.width/3, snapshot.size.height/3)];
2、保存View为内容Img
-(void)savetoLocal{ _moreVC.hidden =YES; UIImage * saveimg=[self saveImage]; UIImageWriteToSavedPhotosAlbum(saveimg, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); }-(UIImage*)saveImage{ UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height - 20));//保存self.view上的内容 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return viewImage;}- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ NSString *message = @"呵呵"; if (!error) { message = @"成功保存到相册"; }else { message = [error description]; } NSLog(@"message is %@",message);}
0 0
- [iOS]图片压缩&保存View为内容Img
- 将View的内容保存为图片
- MFC如何将View(视图)内容保存为图片
- 得到将view中的内容保存为图片
- IOS 图片压缩保存
- 将ViEW保存为图片
- WebBrowser 内容保存为图片
- view窗口视图保存为BMP图片
- 将view转化为图片并保存
- iOS 中图片的压缩以及保存
- 将UIWebView内容保存为png图片
- delphi RichEdit的内容保存为图片
- UItableView 所有内容保存为图片
- delphi RichEdit的内容保存为图片
- delphi RichEdit的内容保存为图片
- convert View to Bitmap将View保存为图片
- 压缩图片,保存图片
- Android中将View的内容保存为图像的方法
- 一款已上市MMO手游地图同步方案总结
- Hibernate HelloWorld-09 多对多的映射
- Attempted to finish an input event but the ~~~异常
- ExtJS结合WCF/Jquery结合WCF 分别开发的非常优秀的网页聊天工具,持续更新
- C 语言的错误集合
- [iOS]图片压缩&保存View为内容Img
- HDU 2377 Bus Pass 最短路
- Http协议简介
- Objective-C编码规范
- QTcreator的一些设置
- 为什么在重写equals方法时都要重写equals方法呢:
- 常见的笔记本电池使用技巧
- Appium系列文章1: Appium开发环境搭建
- maven->jar包