So, I want to nab a screenshot of the desktop, as a bitmap. But, I need to store it in a container, probably a "struct" and pass it around my main application like it's a hotcake. How can I access the bitmap information now that I should have a screenshot? What should a struct have in it for holding this crap? I need the data to be fairly mobile, meaning I have the bitmap data, in a buffer I have immediate access to, any thoughts?
WIN32_LEAN_AND_MEAN#endif#include #include #include
using namespace std;
-Palette data (If 8 bit bitmap)
The GDI revolves around an object called the Device Context (DC), represented by the data type HDC (Handle to Device Context).
An HDC is basically a handle to something you can draw on; it can represent the entire screen, an entire window,
the client area of a window, a bitmap stored in memory, or a printer.
The nice part is that you don't even need to know which one it refers to, you can use it basically the same way,
which is especially handy for writing custom drawing functions which you can then use on any of these devices without changing
it for each one.
// join em up
HBITMAP old_bitmap_h = (HBITMAP)SelectObject(screen_dc, bitmap_h);
//Copy From the screen to my bitmap
BitBlt( screen_dc, 0, 0, width, height, GetDC(0), 0, 0, SRCCOPY ); // the name "screen_dc" may be misleading, but it's the bitmap
//get object info, bad name of "GetObject"
GetObject( bitmap_h, sizeof(BITMAP), &bitmap );
cout << bitmap.bmBits << endl;
cout << bitmap.bmType << endl;
cout << bitmap.bmBitsPixel << endl;
cout << bitmap.bmWidth << endl;
cout << "Last error: " << GetLastError() << endl;
//Restore bitmap to DC
SelectObject(screen_dc, old_bitmap_h );