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);
// after CreateDIBSection I found the error code is 8, no enough resource.
How can I avoid this error? I pass width: 3500 height 2500 many thanks!