创建DIBection失败
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);
// 创建DIBSection之后 我发现错误代码是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 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根本没有足够的内存来完成您的命令。除了尝试打破某些内存边界之外,您无法按原样“修复”它。
相反,您需要将您正在处理的任何图像分割成可管理的大小,以便它们可以换入和换出。
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.
我认为这个问题的答案与您之前问题的答案相同:您的位图太大了。
另外,由于您的尺寸现在是之前问题中位图尺寸的一半,我猜测您正在尝试将目标分成象限,但现在您没有足够的资源来创建目标位图。这可能意味着您也没有释放之前尝试中的位图内存。您可能需要重新启动并使用较小的目标映像再次尝试所有这些操作。
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.