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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| #include <iostream>
#include <windows.h>
#include <atlimage.h>
#include <string>
#include <time.h>
using namespace std;
void ScreenShot(int left, int top, int sizex, int sizey, string output);
int main()
{
int t, i;
/////////////////////
clock_t startTime = clock();
clock_t testTime;
clock_t timePassed;
double secondsPassed;
/////////////////////
while (1 == 1)
{
startTime = clock();
ScreenShot(0, 0, 200, 200, "");
/////////////////////
testTime = clock();
timePassed = testTime - startTime;
secondsPassed = timePassed / (double)CLOCKS_PER_SEC;
/////////////////////
cout << secondsPassed << endl;
}
system("pause");
return 0;
}
void ScreenShot(int left, int top, int sizex, int sizey, string output)
{
HDC hScreenDC = CreateDC("DISPLAY", NULL, NULL, NULL);
HDC hMemoryDC = CreateCompatibleDC(hScreenDC);
HBITMAP hBitmap_Global = CreateCompatibleBitmap(hScreenDC, sizex, sizey);
/////////////////////////////////////////////////////
SelectObject(hMemoryDC, hBitmap_Global);
BitBlt(hMemoryDC, 0, 0, sizex, sizey, hScreenDC, left, top, SRCCOPY);
////////////////////////////////////////////
// img manipulation and saving here
////////////////////////////////////////////
///////////////////////////////////////////////
DeleteObject(hBitmap_Global);
DeleteDC(hMemoryDC);
DeleteDC(hScreenDC);
return;
} |
Partager