2018-02-07

NSView NSImage NSData转换

Views: 22054 | 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. macOS NSView 实现 drag and drop 拖放
  2. 分布式一致性协议-Raft和Paxos
  3. 流式布局的原理和代码实现
  4. iOS 正确接收 HTTP chunked 数据的方法
  5. [转]一个叫做家的地方
Posted by ideawu at 2018-02-07 16:10:47

Leave a Comment