多谢楼上的仁兄。 我自己找到的解决的方法。 下面二个个资源很了我很大的帮助。 http://stackoverflow.com/questions/3514275/load-image-from-memory-buffer-using-atl-cimage You could do it with the CImage::Load(IStream*) function. You can get the IStream from CreateStreamOnHGlobal() or create your own.Beware that using the file is actually the superior solution. CImage creates a memory-mapped file to demand-load the pixels from the image. When you load from memory you need double the memory and you'll put pressure on the paging file. And you'll run into trouble if the image is large.http://www.4ucode.com/Study/Topic/1170367 // load resource into mem ory DWORD len = SizeofResource(hInst, hRsrc); BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc); if (!lpRsrc) return FALSE; // Allocate global memory on which to create stream HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len); BYTE* pmem = (BYTE*)GlobalLock(m_hMem); memcpy(pmem,lpRsrc,len); IStream* pstm; CreateStreamOnHGlobal(m_hMem,FALSE,&pstm); // load from stream m_Image.Load(pstm);
HRESULT Load(
LPCTSTR pszFileName
) throw( );还可以实现另存等很多功能,详见http://msdn.microsoft.com/zh-cn/library/5eb252d0.aspx
没有我想要的。
0, // xDest
0, // yDest
m_nWidth,
m_nHeight,
0, // xSrc
0, // ySrc
0, // uStartScan 开始复制的扫描线和要复制的扫描线数
m_nHeight, // cScanLines
pBits, // lpvBits 指向DIB中的象素数据部分
pInfoHeader, // lpbmi 指向BITMAPINFO结构
DIB_RGB_COLORS); // fuColorUse 指定了DIB中数据的类型
参数说的很详细了吧,第一个参数就是你屏幕DC如果你想使用双缓冲,那么m_hMemDC可以是与显示器兼容的内存DC再用bibit,把内存DC copy到屏幕DC上.
我自己找到的解决的方法。
下面二个个资源很了我很大的帮助。 http://stackoverflow.com/questions/3514275/load-image-from-memory-buffer-using-atl-cimage
You could do it with the CImage::Load(IStream*) function. You can get the IStream from CreateStreamOnHGlobal() or create your own.Beware that using the file is actually the superior solution. CImage creates a memory-mapped file to demand-load the pixels from the image. When you load from memory you need double the memory and you'll put pressure on the paging file. And you'll run into trouble if the image is large.http://www.4ucode.com/Study/Topic/1170367
// load resource into mem
ory
DWORD len = SizeofResource(hInst, hRsrc);
BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);
if (!lpRsrc)
return FALSE;
// Allocate global memory on which to create stream
HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len);
BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
memcpy(pmem,lpRsrc,len);
IStream* pstm;
CreateStreamOnHGlobal(m_hMem,FALSE,&pstm); // load from stream
m_Image.Load(pstm);