CreateDIBSection error

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 error code 8, not enough resources.

How can I avoid this error? Aisle width: 3500 height 2500 thanks a lot!

+2


source to share


2 answers


I think the answer to this question is the same as the answer to your previous question: your bitmaps are too big.



Also, since your dimensions are now half the size of the bitmap in your previous question, I am assuming that you are trying to quadrant the destination, but now you don't have enough resources to even create the target bitmap. This may mean that you are also not freeing bitmap memory from your previous attempts. You might want to restart your computer and try it all again with much smaller destination images.

-1


source


There just isn't enough memory to run your command. You cannot "fix" it as it is, except to try and break some memory boundary.



Rather, you need to split whatever image you are working in into manageable dimensions so that they can be swapped.

0


source







All Articles