我有代码,制作屏幕截图,并将其保存到HBITMAP
GetClientRect(hwnd, &rc);
HDC hdcScreen = GetDC(NULL);
HDC hdc = CreateCompatibleDC(hdcScreen);
int width = rc.right - rc.left;
int height = rc.bottom - rc.top;
HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen,width, height);
SelectObject(hdc, hbmp);
PrintWindow(hwnd, hdc, PW_CLIENTONLY);
然后,我想从 hbmp 对象
创建新的缓冲区(windows.storage.streams.buffer)类实例Buffer obj = new Buffer(hbmp); // HOW TO DO SOMETHING LIKE THIS ???
SoftwareBitmap^ softwareBitmap = SoftwareBitmap::CreateCopyFromBuffer(obj ,
BitmapPixelFormat::Bgra8, width, height);
主要目标 - 将窗口的屏幕截图保存到SoftwareBitmap对象