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

Started by
3 comments, last by johnnyBravo 17 years, 10 months ago
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
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.
my_life:          nop          jmp my_life
[ Keep track of your TDD cycle using "The Death Star" ] [ Verge Video Editor Support Forums ] [ Principles of Verg-o-nomics ] [ "t00t-orials" ]
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
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.
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.

This topic is closed to new replies.

Advertisement