// Write a program in the work,
// Note that the program uses the CPU time, and it is only simple to operate with a pixel.
// You can also change the value of the pixel to a special effect as needed.
// This program is passed under Win2000, you can get 256 colors of one resolution screen.
// Custom RGB Pixel StructucturePedef struct tagrbbrequired {byte rgbblue; Byte rgbgreen; Byte rgbred, * prgrequired;
int APIENTRY WinMain (HINSTANCE hInstance, HINSTance hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {HDC hdcScr; int cx, cy; BITMAPFILEHEADER BFH; BITMAPINFOHEADER BIH; WORD wType; LONG lSize; LONG lPixNum; BYTE byte;
PRGBREQUIRED PPIXEL = NULL; FSTREAM * OUT;
CX = getSystemMetrics (SM_CXSCREEN); cy = getSystemMetrics;
Lsize = sizeof (rgbrequired) * cy * cx; lpixnum = cy * cx;
BYTE = 'm'; wtype = (byte << 8); byte = 'b'; wtype = wtype byte;
// Fill in the bitmap information head BIH.bisize = sizeof (bih.biheight = cy; bih.biwidth = cx; bih.bih.bih.bih.biclrused = 0; bih.biMPRESION = Bi_RGB; bih.Biplated = 1; bih.bisizeImage = lsize 44; bih.bixpelspermeter = 3780; bih.biypelspermeter = 3780; bih.biBitcount = 24;
// Fill in the header file
Bfh.BFTYPE = WTYPE; BFH.BFSIZE = Lsize; bfh.bfoffbits = sizeof (bfh) sizeof (bf "; bfh.bfreserved1 = 0; bfh.bfreserved2 = 0;
HDCSCR = getdc (null); if (! hdcscr) {MessageBox (Null, "Can't get the screen handle", "error", MB_OK; Return 0;}
Ppixel = new rgbrequired [lpixnum];
IF (! ppixel)
{
MessageBox (Null, "Can't Alloc Memory", "Error", MB_OK;
Return 0;
} Memset (void *) ppixel, 0, lsize); prgrequired ptemp = ppixel; RGBRequired TMPPIX; DWORD ColorRef; INT I, J; For (i = cy-1; i> = 0; I -) for (J = 0; j
//save document
Out = new fstream ("screen.bmp", iOS :: out | os :: binary, filebuf :: sh_none); if (! out) {
Delete ppixel;
Ppixel = null;
PTEMP = NULL; MessageBox (Null, "Can't Open File", "Error", MB_OK); RETURN 0;}
OUT-> Write ((char *) & bfh, sizeof (bitmapfileHead); // Write the bitmap file head out-> write ((char *) & bih, sizeof (bitmapinfoheader)); // Write a bitmap information header OUT-> Write ((char *) & ppixel, lsize);
OUT-> Close ();
Delete ppixel; ppixel = null; ptemp = NULL;
MessageBox (Null, "Copy Screen SuccessFully!", "CONGRATULATIONS", MB_OK; RETURN 0;}