I want to use the Windows clipboard image data in OpenCV without using a temporary file.
Can I use imdecode for this?
I tried this but Mat was empty:
if(!IsClipboardFormatAvailable(CF_DIB)) return;
OpenClipboard(NULL);
HGLOBAL clipboard = GetClipboardData(CF_DIB);
if(clipboard){
char* data = (char*)GlobalLock(clipboard);
Mat buf = Mat(1, GlobalSize(clipboard), CV_8UC1, data, Mat::AUTO_STEP);
Mat mat = imdecode(buf, IMREAD_UNCHANGED);
GlobalUnlock(clipboard);
}
CloseClipboard();