Rectangle, to capture the image of a selected screen area, using the mouse.Foreground window, to capture the image of the window with which the user is currently working.Screen, to capture the entire screen image of the first monitor.The demo application is a simple SDI application which uses CScreenImage class to capture images from the screen and display them in a view.įrom the Capture menu you can choose the following items: The other methods implementation can be found in attached source code and demo application. restore the memory DC and perform cleanup note: CAPTUREBLT flag is required to capture layered windowsīOOL bRet = ::BitBlt(hDCMem, 0, 0, rect.Width(), rect.Height(), bit-blit from screen to memory device context HBITMAP hBmpOld = (HBITMAP)::SelectObject(hDCMem, hBitmap) ::CreateCompatibleBitmap(hDCScreen, rect.Width(), rect.Height()) create a compatible bitmap and select it in the memory DC HDC hDCMem = ::CreateCompatibleDC(hDCScreen) HDC hDCScreen = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL) create a screen and a memory device context detach and destroy the old bitmap if any attached Parameters: rect: screen rectangle to be captured This allows dealing with layered windows images. To be noticed the CAPTUREBLT flag used in BitBlt function call. It uses the classic way of bit-blitting from the screen device context to a compatible memory device context.įinally it attaches the bitmap handle to this object. CScreenImage::CaptureWindow – captures the image of a given window.ĬScreenImage::CaptureRect function implementation is shown below.CScreenImage::CaptureScreen – captures the entire screen image of the first monitor.CScreenImage::CaptureRect – captures an image from a given screen area.class CScreenImage : public CImageīOOL CaptureRect(const CRect& rect) throw() This article presents an extension class having methods for screen images capture.ĬScreenImage is derived from CImage, uses shared MFC/ATL classes and plain Windows API, so can be inserted in any MFC or ATL-based application. It provides support for easy manipulation of bitmaps and different graphic file formats (BMP, JPEG, GIF, and PNG).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |