【发布时间】:2015-12-13 03:58:13
【问题描述】:
我目前遇到CGImageRef 的问题。
每当我创建一个 CGImageRef 并在调试器视图中查看它时,在 Xcode 中,它是 nil。
代码如下:
-(void)mouseMoved:(NSEvent *)theEvent{
if (self.shoulddrag) {
NSPoint event_location = [theEvent locationInWindow];//direct from the docs
NSPoint local_point = [self convertPoint:event_location fromView:nil];//direct from the docs
CGImageRef theImage = (__bridge CGImageRef)(self.image);
CGImageRef theClippedImage = CGImageCreateWithImageInRect(theImage, CGRectMake(local_point.x,local_point.y,1,1));
NSImage * image = [[NSImage alloc] initWithCGImage:theClippedImage size:NSZeroSize];
self.pixleView.image = image;
CGImageRelease(theClippedImage);
}
}
其他一切似乎都在工作。我无法理解。任何帮助将不胜感激。
注意:self.pixelView 是一个 NSImageView 实例,未被以任何方式覆盖。
【问题讨论】:
标签: objective-c nsimage cgimageref