开发者

In Cocoa, how could you create an NSImage from a view? (Very similar to Top Sites in Safari 4.)

Actually, almost exactly the same thing. A matrix o开发者_如何学JAVAf small views that would expand out when you click on them. I don't know if it makes more sense to take a snapshot of the view as an image and work with that, or if there is a way to keep the views "live". Thoughts on either approach are welcome!


[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];


NSBitmapImageRep *bitmap = [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
[view cacheDisplayInRect:[view bounds] toBitmapImageRep:bitmap];

Then use that to draw elsewhere, perhaps by placing it into an NSImage. Or alternatively, use the PDF-based technique described by @Chuck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜