2018-02-07

NSView NSImage NSData转换

Views: 20250 | 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. 流式布局的原理和代码实现
  3. iOS 正确接收 HTTP chunked 数据的方法
  4. [转]一个叫做家的地方
  5. 苹果Cocoa框架中关于NSView和NSViewController的关系
Posted by ideawu at 2018-02-07 16:10:47

Leave a Comment