Re: Fast way to grab the screen
Re: Fast way to grab the screen
- Subject: Re: Fast way to grab the screen
- From: Ken Thomases <email@hidden>
- Date: Wed, 23 Feb 2011 17:21:32 -0600
On Feb 23, 2011, at 4:40 PM, Kyle Sluder wrote:
> On Wed, Feb 23, 2011 at 2:17 PM, eveningnick eveningnick
> <email@hidden> wrote:
>> i am trying to write a video grabber, CGWindow API seems pretty convenient
>> (because it allows to select which window to "grab"), but i am worried about
>> the speed, because i need to record the grabbed frames to the video file.
>
> http://developer.apple.com/library/mac/#samplecode/OpenGLScreenCapture/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004445-Intro-DontLinkElementID_2
Actually, I don't think that's an improvement over the CGWindow API that eveningnick was already using (CGWindowListCreateImage, I assume). In general, if a high-level (more abstract) API achieves the desired result, it will be at least as efficient as the low-level API -- because, if the low-level approach is faster, the high-level API would just use it.
Snow Leopard also introduced CGDisplayCreateImage[ForRect](). It's probably of similar speed, although maybe faster because there's no attempt to examine the window list or window positions, etc.
With regard to speed, that's almost certainly more a function of the hardware (GPU, CPU, buses between the two, display resolution, etc.) than the function used. Of course, the size of the grabbed area will also be important.
My understanding is that a CGImage can wrap a texture (or whatever) in VRAM. So, creating the image itself may happen entirely within the GPU and be stunningly fast. However, if you then wish to write the image to disk or process its bits in the CPU, it will have to be copied from VRAM to RAM, which is potentially slow. But there's no way to avoid that slowness -- you need to get the image from VRAM to RAM at some point to perform those operations, and CGImage is probably as good a way as any to do that minimally and most efficiently.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden