如何在vc中显示jpg字节缓冲区 [英] How to show jpg byte buffer in vc

查看:75
本文介绍了如何在vc中显示jpg字节缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

接下来是我的show jpg功能:

Next is my show jpg function:

void DisplayPic(byte* imageBuffer, CDC* pDc, int nSrcWidth, int nSrcHeight, int size)
{
	IStream * pStream = NULL; 
	IPicture * pPicture = NULL; 
	HGLOBAL hMem = ::GlobalAlloc(GMEM_MOVEABLE, size); 
	LPVOID lpBuf = ::GlobalLock(hMem); 
	memcpy(lpBuf, (void*)imageBuffer, size);
	::GlobalUnlock(hMem);
	HRESULT hr = ::CreateStreamOnHGlobal(hMem, TRUE, &pStream); 
	ASSERT (SUCCEEDED(hr)); 
	hr = ::OleLoadPicture(pStream, size, FALSE, IID_IPicture, (LPVOID *)&pPicture ); 
	ASSERT(hr==S_OK); //Here failed
	pPicture->Render(pDc->m_hDC, 0, 0, nSrcWidth, nSrcHeight, 0, nSrcHeight, nSrcWidth, -nSrcHeight, NULL); 
	pPicture->Release();
	GlobalFree(hMem);
}

推荐答案

请参阅备注"部分
Please see the sector ''Remarks'' here[^] :)


这篇关于如何在vc中显示jpg字节缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆