2
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!

1

2 Answers 2

0

There simply isn't enough memory to complete your command. You can't "fix" it as is, except to try and break some memory boundary.

Rather, you need to split whatever image your working on into manageable sizes, so they can be swapped in and out.

-1

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

Also, since your dimensions are now half the dimensions of the bitmap in your earlier question, I'm guessing you're trying to break the destination up into quadrants, but now you don't have enough resources to even create the destination bitmap. This may mean that you're also not releasing the bitmap memory from your previous attempts. You may want to reboot and try all this again with much smaller destination images.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.