Third-party extension libraries such as cximage are not required
Microsoft's GDI + can also be converted
-
C/C ++ code
-
Cimage mmage; hwnd =: getdomaintopwindow (); // obtain the hwnd of the screen. HDC hscreendc =: getdc (hwnd); // obtain the HDC of the screen. HDC memdc =: createcompatibledc (hscreendc); rect;: getwindowrect (hwnd, & rect); hbitmap =: createcompatiblebitmap (hscreendc, rect. right, rect. bottom); hgdiobj holdbmp =: SelectObject (memdc, hbitmap);: bitblt (memdc, 0, 0, rect. right, rect. bottom, hscreendc, rect. left, rect. top, srccopy); hbitmap = (hbitmap): SelectObject (memdc, holdbmp); mmage. attach (hbitmap); istream * pstmimage = NULL; hglobal hmembmp = globalalloc (gmem_moveable, 0); // movable buffer if (hmembmp = NULL) return 0; createstreamonhglobal (hmembmp, false, & pstmimage); // use memory Zone B as the starting stream if (pstmimage = NULL) {globalfree (hmembmp); afxmessagebox ("blank "); return 0;} mmage. save (pstmimage, gdiplus: imageformatjpeg );