nsimage 转 png ,jpg的nsdata 类型


NSImage * image = ..........;

NSData *imageData = [image TIFFRepresentation];

NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];

[imageRep setSize:[[_imageView image] size]];

 

// png

NSData * imageData1 = [imageRep representationUsingType:NSPNGFileType properties:nil];

// jpg

NSDictionary *imageProps = nil;

NSNumber *quality = [NSNumber numberWithFloat:.85];

imageProps = [NSDictionary dictionaryWithObject:quality forKey:NSImageCompressionFactor];

NSData * imageData1 = [imageRep representationUsingType:NSJPEGFileType properties:imageProps];

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bravegogo/article/details/51537140
个人分类: OC UI image
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭