Here's my problem. I need to copy and scale the screen, ~30 times a second (live screen drawing).
I do this by first getting a handle to the screen DC:
GetDC(NULL)
Then, I create a compatible DC using CreateCompatibleDC, create a DIB using CreateDIBSection, and select the DIB into the new DC. Now I StretchBlt from the screen DC to my own DC (blit and scale the image) .
So we have
while(1)
{
StretchBlt ... (get the screen and resize from 1440*900 to 1200*700)
}
As you probable know the scaling takes most of the CPU and time.
If i do only
while(1){bitblt()} i get ~400 fps - i.e 400 call of bitblt per second.
if i use the while(1){StretchBlt} i get only ~25 fps - i.e 25 call of StretchBlt per second.
(I need 30). also since i am doing other things as well, CPU will not be idle so this code need to be ran at least at 34 FPS.
As said, the bottleneck is not the Blitting from the screen. the bottleneck is the scaling (i use SetStretchBltMode(hCompatible, HALFTONE)).
with COLORONCOLOR i get 60FPS but quality is not good (if there only something in the middle of HALFTONE to COLORONCOLOR ...).
For now i do not want to use directx or open GL.
Any idea how to make it faster (i only need ~10 more FPS :))
I have an idea how to make it faster but i do know how to do that and if it is possible.
Idea is to:
Bitblt to get the screen into buffer A.
StretchBlt to scale the image into buffer B.
Now on the next bitblt's to use SRCINVERT (XOR) to blt only the differences between the new capture and the old and to use the differences to update the scaled buffer B so no need to do more scaling.
Again just an idea but i do not think it is possible.
I would love to hear your suggestions.
I tries to use bitblt with some custom scaling functions (instead of StretchBlt) i found on the Internet or with image libs like FreeImage but results were dramatically worst than StretchBlt (even using BOX filtering)
Again, i know that using DirectX/opengl may be faster but currently i do not have the time to learn that or deal with that - so currently i would like to use GDI/GDI+ only.
Thanks!