创建DIBection失败

发布于 2024-08-05 12:59:29 字数 1252 浏览 7 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浪漫之都 2024-08-12 12:59:29

根本没有足够的内存来完成您的命令。除了尝试打破某些内存边界之外,您无法按原样“修复”它。

相反,您需要将您正在处理的任何图像分割成可管理的大小,以便它们可以换入和换出。

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.

你与清晨阳光 2024-08-12 12:59:29

我认为这个问题的答案与您之前问题的答案相同:您的位图太大了。

另外,由于您的尺寸现在是之前问题中位图尺寸的一半,我猜测您正在尝试将目标分成象限,但现在您没有足够的资源来创建目标位图。这可能意味着您也没有释放之前尝试中的位图内存。您可能需要重新启动并使用较小的目标映像再次尝试所有这些操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文