2018-02-07

NSView NSImage NSData转换

Views: 200 | Add Comments
NSBitmapImageRep *bitmap =  [view bitmapImageRepForCachingDisplayInRect:[view visibleRect]];
[view cacheDisplayInRect:[view visibleRect] toBitmapImageRep:bitmap];

NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
[image addRepresentation:bitmap];

NSBitmapImageRep *bitmap = [NSBitmapImageRep imageRepWithData:data];

NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc] initWithCGImage:CGImage];

Related posts:

  1. 流式布局的原理和代码实现
  2. iOS 正确接收 HTTP chunked 数据的方法
  3. [转]一个叫做家的地方
  4. 可爱机械战警小男孩入侵底特律城
  5. Objective-C 对二进制数据 NSData 进行 URL 编码
Posted by ideawu at 2018-02-07 16:10:47

Leave a Comment