Why is the program that I have written in the area-catching program is compilated, and the result is empty after running? ? Than

zhaozj2021-02-16  64

The following is the source program ~~~

HDC HSCRDC, HMEMDC; / / Screen and Memory Device Description Table HBitmap Hbitmap, Holdbitmap; // Bit 图 INT NX, NY, NX2, NY2; // Selection Area Coordinate INT NWIDTH, NHEIGHT; // Bitmap Width and Height INT XSCRN, YSCRN; // Screen resolution

/ / Make sure the selected area is not empty rectangle // (ISRECTEMPTY (LPRECT)) // Return Null; / / Create a device description table hscrdc = createdc ("Display", NULL, NULL, NULL); // is the screen Device Description Table Create a compatible memory device description table hmemdc = creteCompatibleDC (HSCRDC); // Get selected area coordinate Nx = 900; NY = 375; Nx2 = 930; NY2 = 390; // Get screen resolution xscrn = getDevicecaps HSCRDC, Horzres); YSCRN = getDeviceCaps (HSCRDC, Vertres); // Make sure the selected area is visible if (NX <0) nx = 0; if (NY <0) NY = 0; if (nx2> xscrn) NX2 = xscrn; if (NY2> YSCRN) NY2 = YSCRN; NWIDTH = NX2-NX; NHEIGHT = NY2-NY; // Create a bitmap Hbitmap (HSCRDC, NWIDTH, NHEIGHT), which is compatible with screen device description table. / Put the new bitmap in the memory device descriptor table HoldbitMap = (hbitmap) SelectObject (HMEMDC, HBitmap); / / copy the screen device description table to the memory device description table Bitblt (hmemdc, 0, 0, nwidth, nHEight, HSCRDC, NX, NY, SRCCOPY; // Get the handle of the screen bitmap HbitMap = (Hbitmap) SelectObject (HMEMDC, Holdbitmap); // Clear deletedc (HSCRDC); deletedc (HMEMDC);

HDC hDC; WORD wBitCount; int iBits; DWORD dwPaletteSize = 0, dwBmBitsSize, dwDIBSize, dwWritten; BITMAP Bitmap; BITMAPFILEHEADER bmfHdr; BITMAPINFOHEADER bi; LPBITMAPINFOHEADER lpbi; HANDLE fh, hDib, hPal = NULL, hOldPal = NULL; hDC = CreateDC ( " Display ", NULL, NULL, NULL); IBITS = GetDeviceCaps (HDC, Bitspixel) * getDeviceCaps (HDC, Planes); deletedc (HDC); if (iBITS <= 1) wbitcount = 1; Else IF (ibits <= 4) Wbitcount = 4; else if (ibits <= 8) wbitcount = 8; Else IF (ibits <= 24) wbitcount = 24; // Calculate Tune Size IF (WbitCount <= 8) dwpalettesize = (1 << wbitcount) * sizeof (RGBQUAD); GetObject (hBitmap, sizeof (BITMAP), (LPSTR) & Bitmap); bi.biSize = sizeof (BITMAPINFOHEADER); bi.biWidth = Bitmap.bmWidth; bi.biHeight = Bitmap.bmHeight; bi.biPlanes = 1; bi.biBitCount = wBitCount; bi.biCompression = BI_RGB; bi.biSizeImage = 0; bi.biXPelsPerMeter = 0; bi.biYPelsPerMeter = 0; bi.biClrUsed = 0; bi.biClrImportant = 0; dwBmBitsSize = ((Bitmap. BMWIDTH * WBITCOUNT 31) / 32) * 4 * Bitmap.bmheight; hdib = GlobalAlloc (GHND, DWBMBITSSI DWPALETES ize sizeof (BITMAPINFOHEADER)); lpbi = (LPBITMAPINFOHEADER) GlobalLock (hDib); * lpbi = bi; hPal = GetStockObject (DEFAULT_PALETTE); if (hPal) {hDC = (HDC) GetDC (); hOldPal = SelectPalette (hDC, (HPALETTE) HPAL, FALSE); REALIZEPALETTE (HDC);} // Get new pixel value getDibits (HDC, Hbitmap, 0, (UINT) Bitmap.BmHeight, (LPSTR) LPBI SIZEOF (BitmapInfoHeader) DWPALETTESIZE, (BitMapInfo *) lpbi, dib_rgb_colors; // Restore Palette IF (Holdpal) {SelectPalette (HDC, (HPALETTE) HOLDPAL, TRUE); RelasePalette (HDC); ReleaseDC (NULL);} // Create a bit Graph file

转载请注明原文地址:https://www.9cbs.com/read-16477.html

New Post(0)