1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| screen::screen()
{
// Donne les dimensions de l'écran
int x1, y1, x2, y2;
x1 = GetSystemMetrics(SM_XVIRTUALSCREEN);
y1 = GetSystemMetrics(SM_YVIRTUALSCREEN);
x2 = GetSystemMetrics(SM_CXVIRTUALSCREEN);
y2 = GetSystemMetrics(SM_CYVIRTUALSCREEN);
this->w = x2 - x1;
this->h = y2 - y1;
// copie l'écran dans le bitmap
this->hScreen = GetDC(NULL);
this->hDC = CreateCompatibleDC(hScreen);
this->hBitmap = CreateCompatibleBitmap(hScreen, w, h);
HGDIOBJ old_obj = SelectObject(hDC, hBitmap);
BOOL bRet = BitBlt(hDC, 0, 0, w, h, hScreen, x1, y1, SRCCOPY);
//Charge le bitmap dans le buffer
this->scnBmp = new Gdiplus::Bitmap(hBitmap,NULL);
Gdiplus::Rect rectScnBmp(0,0, w, h);
this->scnBmpData = new Gdiplus::BitmapData;
scnBmp->LockBits(&rectScnBmp, Gdiplus::ImageLockModeRead,
PixelFormat32bppARGB, scnBmpData);
this ->scnOct = (byte*)(void*)scnBmpData->Scan0;
}
screen::~screen()
{
scnBmp->UnlockBits(scnBmpData);
DeleteDC(hDC);
ReleaseDC(NULL, hScreen);
DeleteObject(hBitmap);
delete(scnBmpData);
} |
Partager