原先使用cximage库,load一个bmp文件,然后得到一个HBITMAP(m_bitmap ).以下是原来的代码。
CxImage image(strFilePath, CXIMAGE_FORMAT_BMP);
if(image.IsValid())
{
if(m_bitmap)
{
DeleteObject(m_bitmap);
m_bitmap = NULL;
} m_bitmap = image.MakeBitmap();
}
现在的要求是,直接得到一块bits的数据,知道长,宽,24位的数据,如何从这块数据转换成HBITMAP(m_bitmap )?试验好久了,m_bitmap有值,但是图像不显示(图像显示沿用以前的,怀疑自己的转换有问题),请教大家该怎么实现?能给出具体的代码吗?谢谢大家!
CxImage image(strFilePath, CXIMAGE_FORMAT_BMP);
if(image.IsValid())
{
if(m_bitmap)
{
DeleteObject(m_bitmap);
m_bitmap = NULL;
} m_bitmap = image.MakeBitmap();
}
现在的要求是,直接得到一块bits的数据,知道长,宽,24位的数据,如何从这块数据转换成HBITMAP(m_bitmap )?试验好久了,m_bitmap有值,但是图像不显示(图像显示沿用以前的,怀疑自己的转换有问题),请教大家该怎么实现?能给出具体的代码吗?谢谢大家!
int nWidth, // bitmap width, in pixels
int nHeight, // bitmap height, in pixels
UINT cPlanes, // number of color planes
UINT cBitsPerPel, // number of bits to identify color
CONST VOID *lpvBits // color data array
);
[in] Pointer to an array of color data used to set the colors in a rectangle of pixels. Each scan line in the rectangle must be word aligned (scan lines that are not word aligned must be padded with zeros). If this parameter is NULL, the contents of the new bitmap is undefined.
http://support.microsoft.com/kb/81498