BITMAPINFO bmi;
memset(&bmi,0,sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth =m_pImg->GetWidth();
bmi.bmiHeader.biHeight =m_pImg->GetHeight();
bmi.bmiHeader.biPlanes = 1;
//if( m_pImg->GetInfo()->biBitCount!=16)
//{
// bmi.bmiHeader.biBitCount = m_pImg->GetInfo()->biBitCount;
//}
//else
//{
//ASSERT((m_pImg->GetInfo())->bmiHeader->biBitCount == 24);
bmi.bmiHeader.biBitCount=24;
bmi.bmiHeader.biCompression = BI_RGB;
if (bmi.bmiHeader.biSizeImage == 0)
bmi.bmiHeader.biSizeImage =
WidthBytes(bmi.bmiHeader.biWidth,bmi.bmiHeader.biBitCount) * bmi.bmiHeader.biHeight;
if(bmi.bmiHeader.biClrUsed == 0 && bmi.bmiHeader.biBitCount <16)
bmi.bmiHeader.biClrUsed=DWORD(1 <<bmi.bmiHeader.biBitCount);
m_nNewSize=bmi.bmiHeader.biSizeImage;
if(m_hbmCanvasBitmap!=NULL)
{
DeleteObject(m_hbmCanvasBitmap);
m_hbmCanvasBitmap=NULL;
m_pCanvasBits=NULL;
}
// 创建直接与DC相关联的位图
m_hbmCanvasBitmap=CreateDIBSection(m_hDC, &bmi, DIB_RGB_COLORS,(void**)&m_pCanvasBits, NULL, NULL);
// 在 CreateDIBSection 之后我发现错误代码是 8,没有足够的资源。
我怎样才能避免这个错误?我通过宽度:3500 高度 2500 非常感谢!