NSView 转换成NSImage,并保存
来源:互联网 发布:sql server能卸载吗 编辑:程序博客网 时间:2024/06/07 09:18
[zwViewlockFocus];//zwView为继承NSView类的一个对象
NSImage *image = [[NSImagealloc] initWithData:[zwViewdataWithPDFInsideRect:[zwViewbounds]]];
[zwViewunlockFocus];
[imagelockFocus];
//先设置下面一个实例
NSBitmapImageRep *bits = [[NSBitmapImageRepalloc]initWithFocusedViewRect:[zwViewframe]];
[imageunlockFocus];
//再设置后面要用到得 props属性
NSDictionary *imageProps = [NSDictionarydictionaryWithObject:[NSNumbernumberWithBool:0]forKey:NSImageCompressionFactor];
//之后转化为NSData 以便存到文件中
NSData *imageData = [bitsrepresentationUsingType:NSPNGFileTypeproperties:imageProps];
//设定好文件路径后进行存储就ok了
[imageData writeToFile:[[[NSStringalloc] initWithFormat:@"~/Documents/test%d.jpg",1]stringByExpandingTildeInPath]atomically:YES]; //保存的文件路径一定要是绝对路径,相对路径不行
- NSView 转换成NSImage,并保存
- NSView转换为NSimage 与 UIImage转换为UIimage 总结
- 将一个NSImage实例保存成图片文件
- NSImage
- 图片数据类型转换 NSImage、CIImage、CGImageRef
- 图片数据类型转换 NSImage、CIImage、CGImageRef
- 图片数据类型转换 NSImage、CIImage、CGImageRef
- 怎么样吧DDB转换成DIB并保存?
- 将图片自己转换成BMP并缩放保存。
- Java将byte转换成图片并保存在本地
- angularjs上传图片并转换成base64保存到数据库
- java用BufferedImage转换图片大小并保存
- NSData,NSImage,NSDictionary,NSString,NSInteger,Float,NSURL 等等互相转换
- NSData,NSImage,NSDictionary,NSString,NSInteger,Float,NSURL 等等互相转换
- NSData,NSImage,NSDictionary,NSString,NSInteger,Float,NSURL 等等互相转换
- NSData,NSImage,NSDictionary,NSString,NSInteger,Float,NSURL互相转换汇总
- NSData,NSImage,NSDictionary,NSString,NSInteger,Float,NSURL 等等互相转换
- NSData,NSImage,NSDictionary,NSString,NSURL 等等互相转换
- visualstudio使用visualstudio online提供的TFS服务教程
- xcode 插件
- c++ 全局变量
- HTML随手笔记,文字效果,新手望指点
- VPB生成地形小结
- NSView 转换成NSImage,并保存
- Five Ways to Create a Scala List
- Myeclipse XSD配置XML自动提示
- SQL Server 触发器
- Guake can not init! Gconf Error. Have you installed guake.schemas properlly?
- 日期、时间拾取器(待修改)
- C++预处理器和iostream文件
- Keil5 Software Packs
- Java Web系列:Java Web基础