Sign in to follow this  
johnnyBravo

(c++ win32) Taking screenshot/reading all pixels onscreen?

Recommended Posts

Hi, I want to read all the pixels on screen (a screenshot), eg if I'm playing a movie it will capture the pixels, instead of showing black and capture whatever else apps I have onscreen. So how would I go about it? thx

Share this post


Link to post
Share on other sites
To capture the screen (Win32) use CreateDC("DISPLAY",0,0,0) (and DeleteDC() when done)... and then either GetPixel() or GetDIBits().

You'll have to create memory DCs and Compatible Bitmaps if you go the GetDIBits() route.

Share this post


Link to post
Share on other sites
The movie I am playing comes up as black, are there any solutions?

heres a screenshot that i took using that code:




heres the source:

HDC screen = CreateDC("DISPLAY", 0,0,0);
HDC dest = CreateCompatibleDC(screen);

RECT rect;
GetWindowRect(GetDesktopWindow(), &rect);

HBITMAP bmp = CreateCompatibleBitmap(screen, rect.right, rect.bottom);
SelectObject(dest, bmp);
BitBlt(dest, 0, 0, rect.right, rect.bottom, screen, 0, 0, SRCCOPY);

CreateBMPFile(0, "pszFile.bmp", CreateBitmapInfoStruct(0, bmp), bmp, dest);

DeleteDC(screen);








thx

Share this post


Link to post
Share on other sites
you have to open two media player windows. First one grabs the hardware overlay (the black color you see).
The second one can't use the overlay, and so you can screenshot the image.

There might also be an option in your version of media player that allows you to disable harware acceleration/hw overlay.

Share this post


Link to post
Share on other sites
I want my program to be able to capture everything on screen though, while googling I've picked up that 'professional' screen capture apps can do it, so I'm guessing it can't be too hard to do it myself.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this