void CMyVideWnd::RenderFrame(std::unique_ptr<ARGBBuffer> video_frame)
{
static int frames = 0;
frames++;
if (!video_frame)
return;
if (image_width_ != video_frame->resolution.width ||image_height_ != video_frame->resolution.height)
{
image_width_ = video_frame->resolution.width;
image_height_ = video_frame->resolution.height;
image_size_ = image_width_ * image_height_ * 4;
image_.reset(new uint8_t[image_size_]);
}
// std::copy(video_frame->buffer, video_frame->buffer + image_size_,
// image_.get());
memcpy(image_.get(), video_frame->buffer, image_size_);
//this->update();
//IStream* m_pStream;
//IPicture* m_pPictrue;
//OLE_XSIZE_HIMETRIC m_JPGWidth ;
//OLE_YSIZE_HIMETRIC m_JPGHeight;
//HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, image_size_);
//LPVOID pData = NULL;
//pData = GlobalLock(hMem);
//memcpy(pData, video_frame->buffer, image_size_);
//GlobalUnlock(hMem);
//HRESULT hrr = CreateStreamOnHGlobal(hMem, TRUE, &m_pStream);
//hrr = OleLoadPicture(m_pStream, image_size_, TRUE, IID_IPicture, (LPVOID*)&m_pPictrue);
//m_pPictrue->get_Height(&m_JPGHeight);
//m_pPictrue->get_Width(&m_JPGWidth);
//CRect lpRec;
//GetDlgItem(IDD_VIDEO_WND)->GetWindowRect(&lpRec);
//ScreenToClient(&lpRec);
//m_pPictrue->Render(GetDC()->m_hDC, lpRec.left, lpRec.top
// , (int)(m_JPGWidth / 26.45), (int)(m_JPGHeight / 26.45)
// , 0, m_JPGHeight, m_JPGWidth, -m_JPGHeight, NULL);
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, image_size_);
void * pData = GlobalLock(hGlobal);
memcpy(pData, video_frame->buffer, image_size_);
GlobalUnlock(hGlobal);
IStream * pStream = NULL;
if (CreateStreamOnHGlobal(hGlobal, TRUE, &pStream) == S_OK)
{
CImage *image = new CImage();
image->Create(image_width_, image_height_, image_size_);
// Load IStream Fail
HRESULT hResult = image->Load(pStream);
//CImage image;
////HRESULT hr = image.Load(pStream);
//if (SUCCEEDED(image.Load(TEXT("1111.png"))))
//{
// image.Draw(GetDC()->m_hDC,0,0,100,500);
//}
pStream->Release();
}
GlobalFree(hGlobal);
}
為什么我用image就是加載普通的圖片也加載失敗。用的是VS2015
uj5u.com熱心網友回復:
video_frame->buffer, 你確定這是一個影像buf嗎?你加入斷點img.load(pStream)執行完以后img的m_hbitmap是否有值呢?轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/115457.html
標籤:基礎類
上一篇:VC++2013 MFC專案中不能添加webservice
下一篇:VS2013報錯,請求大家幫忙
