Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HDC hScreen = GetDC(NULL);
- HDC hDC = CreateCompatibleDC(hScreen);
- HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, 1920, 1080);
- HGDIOBJ old_obj = SelectObject(hDC, hBitmap);
- BOOL bRet = BitBlt(hDC, 0, 0, 1920, 1080, hScreen, 0, 0, SRCCOPY);
- constexpr size_t buffer_size = 1920 * 1080 * 4;
- std::vector<char> buffer(buffer_size);
- GetBitmapBits(hBitmap, buffer_size, buffer.data());
- CImg img(buffer.data(), 1920, 1080);
- CImgDisplay display(img);
- while (!display.is_closed())
- {
- display.wait(1000 / 60);
- }
- // clean up
- SelectObject(hDC, old_obj);
- DeleteDC(hDC);
- ReleaseDC(NULL, hScreen);
- DeleteObject(hBitmap);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement