问题描述
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非常感谢!
我认为答案与您先前的问题相同:您的位图太大了. >
此外,由于您的尺寸现在是前面问题中位图尺寸的一半,因此我猜您正在尝试将目标划分为多个象限,但现在您没有足够的资源甚至无法创建目标位图.这可能意味着您也没有释放先前尝试的位图内存.您可能需要重新启动,然后使用很多较小的目标映像再次尝试所有这些操作.
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 CreateDIBSectionI found the error code is 8, no enough resource.
How can I avoid this error?I pass width: 3500 height 2500many thanks!
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.
这篇关于CreateDIBSection失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!