Capture screen with bitblt is too slow

My code used GetDC(0) to get the Desktop DC and GetDIBSection & BitBlt to get RGB pixel array.

Actually it would work well for a single screenshot , but when i need to capture the frame by frame in real-time , it seems to be going slower.

Is there other API that i could capture screenshot fast (I only want to capture the desktop screenshot instead of in a game .)
I think you want to use a combination of Windows Imaging Component(WIC) and Direct2D. You can initialize a WIC bitmap from various sources (memory buffer, HBITMAP, image file) and access its pixels with bitmap->CopyPixels(). Direct2D is a hardware-accelerated 2D rendering API and it's much MUCH better and faster than GDI.
lol thanks for reply , so ...with direct2D I can get the pixels of DC(Device Context) too?
Yes, it is made to interoperate with GDI. It is essentially the modern replacement for GDI. Just a bit more difficult to learn but there are plenty of examples and documentation on MSDN.

Actually, scratch that. I don't believe Direct2D gives access to bitmap pixel data, but WIC bitmaps do. Direct2D allows you to create D2D bitmaps from WIC bitmaps for rendering.
Last edited on
thanks again dude, I think I shall start to learn WIC and direct2D now.
Last edited on
Topic archived. No new replies allowed.