How fast? I would like to make a program that can capture “screen movies” (like SnapzPro – the reviews on that page are not really accurate) at 10 fps or better…but I can’t find a way to take frames that fast. I didn’t have to add the Carbon framework to my target, but you may need to if you get compilation errors. However, because it’s QuickDraw, the point of origin (0,0) is at the top left of the screen instead of the bottom left. This basically does the same thing as the above code, but it uses QuickDraw functions to capture the screen which are much faster. Create an image with the representation We can release the PicHandle now that we’re done with it Length:GetHandleSize((Handle)picHandle)]] ImageRep = [NSPICTImageRep imageRepWithData:[NSData dataWithBytes:(*picHandle) First lock the PicHandle so it doesn’t move in memory while we copy Capture the screen into the PicHandle.ĬopyBits((BitMap )( mainDevice).gdPMap, (BitMap )(mainDevice).gdPMap, I may want to add support for multiple screens later SetRect(&rect, NSMinX(cocoaRect), NSMinY(cocoaRect), NSMaxX(cocoaRect), NSMaxY(cocoaRect)) (NSImage *)imageWithScreenShotInRect:(NSRect)cocoaRect I’ve been fiddling with various carbon screen shot examples trying to find an alternative to the method posted above. There’s also the Snapshot ( ) and Super Snapshot ( ) archived examples.ĭoes anybody have a saved copy of the GLGrab example? With a bit of hacking around I’ve managed to take a 1024*768 screendump and map it onto a gl quad in 0.11 seconds (with the addition of Apple’s GL extensions ofcourse). GlGrab is by far the fastest grabbing routine I’ve come across. “This sample shows how to use OpenGL to grab the contents of the screen via a DMA transfer Exactly why it was deprecated is unclear, but it’s now in their archive section at. Less than a second for the entire screen!! -ZacĪpple’s sample code has been deprecated. I haven’t put it into my program yet, but I will later. It is lightning fast for the entire screen. Man, the code in the above link in the original post is great. So, it would be most appropriate to ask him for permission to post it on. Thanks! -ZacĬredit for the code given above goes to Ben Haller from Stick Software. I am at school on a PeeCee so I can’t try it, but I will try it when I get home. Hm, I just noticed that link you (or someone else) gave me. As soon as I post it for download I will post a link in here or something. I wanted to basically freeze the screen by displaying a screenshot of the computer right before the screensaver activated but I kept getting part of the fade in the screenshot. ![]() I made sure that the task was finished before proceeding with my screensaver. I ended up just using NSTask and screencapture. With your permission I would like to post it to. I tried your code and it is very cool but a little too slow for my needs (the whole screen). I believe Apple had some sample code on how to do this, but I can’t find it at the moment. You might need to use some Carbon if you want to get the best results. ![]() Rep = initWithFocusedViewRect:window contentView] bounds Window = initWithContentRect:rect styleMask:NSBorderlessWindowMaskīacking:NSBackingStoreNonretained defer:NO] (NSImage *)captureImageForRect:(NSRect)rect The downside is that it’s slow if you are trying to capture the entire screen. This works fairly well for me and takes a surprisingly little amount of code - and best of all, it’s 100% Cocoa. Is there another way because this way sucks. Right now I am using NSTask and the “screencapture” command line utility. I need to take a picture of the screen and load it into an NSImage or some derivation of that.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |