Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

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

This topic is 4413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!