// exportClipFile(basepath) static void exportClipFile(LPCWSTR basepath) { // CF_UNICODETEXT HANDLE data = GetClipboardData(CF_UNICODETEXT); if (data != NULL) { LPWSTR text = (LPWSTR) GlobalLock(data); if (text != NULL) { WCHAR path[MAX_PATH]; StringCchPrintf(path, _countof(path), L"%s.txt", basepath); setClipboardOrigin(path); writeTextFile(path, text, wcslen(text)); GlobalUnlock(data); } } // CF_DIB data = GetClipboardData(CF_DIB); if (data != NULL) { LPVOID bytes = GlobalLock(data); if (bytes != NULL) { SIZE_T nbytes = GlobalSize(data); WCHAR path[MAX_PATH]; StringCchPrintf(path, _countof(path), L"%s.bmp", basepath); setClipboardOrigin(path); writeBMPFile(path, bytes, nbytes); GlobalUnlock(bytes); } } }
BOOL ffplayer::CapturePic(char *pSaveFile, int iType) { if (m_iWidth == 0 || m_iHeight == 0 || !m_picSnopshot) { return false; } unsigned char *buf = NULL; if (NULL == buf) { buf = (unsigned char*)malloc(m_iWidth*m_iHeight * 3); } AVFrame dstFrame; if (NULL != buf) { av_image_fill_arrays(dstFrame.data, dstFrame.linesize, (uint8_t*)m_picSnopshot->Data, AV_PIX_FMT_YUV420P, m_pCodecCtx->width, m_pCodecCtx->height, 1); YUV420_RGB_KP(&dstFrame, buf, m_iWidth, m_iHeight);//YUV420_RGB_KP是内部函数 } if (strstr(pSaveFile, ".jpg") || strstr(pSaveFile, ".JPG") || strstr(pSaveFile, ".jpeg")) { writeJPGFile(pSaveFile, (char*)buf, m_iWidth, m_iHeight); } else { writeBMPFile(pSaveFile, (char*)buf, m_iWidth, m_iHeight); } if (buf) { free(buf); buf = NULL; } return true; }