2012-06-13 32 views

回答

1

我建議你做一些更多的谷歌搜索下一次,並告訴我們你已經嘗試,但我會回答反正:

您可能需要使用NSView-(void)cacheDisplayInRect:toBitmapImageRep:到創建一個包含縮略圖的NSImage。以下是我在我的應用程序中使用的內容:

- (NSImage *)snapshotForRect:(NSRect)destinationRect { 
    NSView *view = ... // view you want thumbnail of 
    NSBitmapImageRep *imageRep = [view bitmapImageRepForCachingDisplayInRect:destinationRect]; 
    [view cacheDisplayInRect:destinationRect toBitmapImageRep:imageRep]; 
    NSImage *renderedImage = [[NSImage alloc] initWithSize:[imageRep 
                  size]]; 
    [renderedImage addRepresentation:imageRep]; 
    return [renderedImage autorelease]; 
} 

或者使用各種其他可用的方法。

How do I take a "screenshot" of an NSView?

Google

+0

非常感謝。 我試過這種方式,但是我遇到了性能問題。如果我從自定義視圖製作圖像。這種方式太慢了。 – CocoaUser

+0

您是否分析了性能備份是否在您的繪圖中或Cocoa如何打電話給您?你多久拍一次快照? – user1118321