视频祯,显示问题
锻刀 2016-11-25 01:16:48 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