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.
精彩评论