How to speed up BitBlt screen copy?

Here's my problem. I need to copy the screen, 30 times a second, such that I can read the data of the individual pixels, in order to scale the image. I do this by first getting a handle to the screen DC:

ScreenDC = CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);

Then, I create a compatible DC using CreateCompatibleDC, create a DIB using CreateDIBSection, and select the DIB into the new DC. Now, all I have to do each frame is wait until the screen has JUST finished refreshing, and BitBlt from the screen DC to my own DC, and I will have a pointer to the bit data (I get that from using CreateDIBSection).

Most of the times, this BitBlt takes 4ms or so. But sometimes, it takes 20ms, or more. My screen refresh rate is 60hz, meaning one frame is 16.67ms. Which means, sometimes, I get part of the next frame (tailing). Which doesn't look very nice.

I've tried using GetDIBits() instead of BitBlt(), and tried using CreateCompatibleBitmap() instead of CreateDIBSection(). No difference.

Is there ANY conceivable way to get that time consistently below 16ms? Or am I just going to need to live with the tailing, or skip frames with tailing? I've looked everywhere for alternatives to BitBlt, but this seems to be as good as it gets.

At this point, I'll appreciate any ideas you have. I've tried two other forums to no avail, so I'm desperate. Thanks in advance!
I have to ask: what is this for?

BitBlting from the display seems a little backwards. Makes me wonder if you're approaching this problem in all the wrong way.
Thanks for responding,

I'm BitBlting from the display because I need to copy the screen, and then scale it using some functions I wrote in assembly. For example, if I'm watching a video, every frame (33ms), the screen is copied, and scaled at a factor of 4 to 3. If I capture a 768x600 window of the screen, the result is a 512x450 DIB, which is then sent along to another directshow filter. This all works perfectly fine; it just results in tailing when doing something like watching a video, causing that BitBlt time to go above 16ms.

Hope that clears the problem up for you, feel free to ask any other questions.
Ah okay. So this is like for a video capture thing.

There's probably a faster way to grab the display like with DirectX or something. WinGDI (BitBlt) is probably pretty slow.

But I'm afraid I can't really offer you any real help/advice as this is an area I never really got into.
Topic archived. No new replies allowed.