CreateCompatibleBitmap Fails with Err code 8

AI人工智能代理工作流 AI Agent WorkFlow:在股票市场预测中的应用 AI人工智能代理工作流 AI Agent WorkFlow:在股票市场预测中的应用 作者:禅与计算机程序设计艺术 / Zen and the Art of Computer Programming 关键词: AI Agent, W 阅读详情

CreateCompatibleBitmap Fails with Err code 8
http://www.keyongtech.com/2538297-createcompatiblebitmap-fails-with-err-code

Mahesh Bhirangi
 
hi,
i am using the follwing calls:

screenDC = GetDC(NULL);

compDC = CreateCompatibleDC(screenDC);

hbmp = CreateCompatibleBitmap(screenDC);


Now if my machine's, display setting if they are at 16, 24 bits per pixel
everything works fine irrespective of resolution setting.
But when i change the bits per pixel setting to 32 and reolution to more
than 1200 * 960. the CreateCompatibleBitmap() starts failing
with error code 8. I have enough virtual memory so that is not the problem.

All suggestions are welcome.

regards
Mahesh

 

 #2    01-21-04, 02:28 PM 
Serge Castelier
 
Did you try

hbmp = CreateCompatibleBitmap(screenDC,GetDeviceCaps(scre enDC, HORZRES),
GetDeviceCaps(screenDC, VERTRES));

Serge

 #3    01-21-04, 03:00 PM 
Mahesh Bhirangi
 
yes i m giving the bitmap height and width as arguments.


"Serge Castelier"
<[sdshsh.gs<g<gtzdwhdshdshdsdfhsgqsgqgqgqg[345@]hsdsfdsfhdshsdh[@]qg.qgs][@f
d.com][tyyty.gkjgj[serge.castelier][toot.aar[> wrote
in message
news:ik11
[..]

 #4    01-21-04, 06:11 PM 
vipin
 
you say 24 bpp works fine and when you cahnge to 32 bpp it fails

for 1200 * 800 the increase in kernel memory is 96KB or 0.1 MB, but you do an

allocation of
0.4 MB. I am not sure whether it should be failing, might be FENG has some

experiences in it

But you could use CreateDibsection to allocate bitmap memory as DIB in user

memory and I am pretty sure i
will work to a bigger scale

thank yo
vipin

 #5    01-21-04, 06:12 PM 
Feng Yuan [MSFT]
 
CreateCompatibleBitmap creates DDB, which are normally stored in kernel mode
paged pool. There is a low limit on the kernel mode paged pool, which is
around 48 MB.

Avoid creating lots of DDBs, use DIB section or DIB instead.

 #6    01-23-04, 01:06 PM 
Marc
 
I have the same problem like Mahesh

My limitation is around 100MB. All DDBs which are larger than 100MB fail. E.g.

4100x6000 (32Bit)
I will try to use a DIB instead of a DDB.

 #7    01-23-04, 05:31 PM 
vipin
 
I think windows NT4 has a bigger range in the kernel memory for DDBs but on

windows 2k and above its just less

 #8    01-24-04, 02:59 PM 
John Hornick [MSFT]
 
Hi,

DDBs are generally allocated out of paged pool. This is usually no larger
than 192MB, but can be smaller on systems with less memory, and can be
substantially smaller in Terminal Server environments. If you're
allocating that much at once, you really should be using DIBSections or
DIBs.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit
http://www.microsoft.com/security for current information on security.

 

 

> I have the same problem like Mahesh.

My limitation is around 100MB. All DDBs which are larger than 100MB fail.
E.g. 4100x6000 (32Bit).
I will try to use a DIB instead of a DDB.

 #9    01-26-04, 07:51 AM 
Marc
 
Ok, now I understand what the problem is
But I have 2 more questions regarding this subject

1. How does Windows create a bitmap for a printer DC? If I get a printer DC

from Windows (e.g. in the OnPrint handler) the bitmap in the DC must be very

large if I have e.g. a plotter paper with DinA1? This must be a large bitmap
2. Do I have the same size limitaion under Windows 95/98/ME (16 MB) if I use a

DIB instead of a DDB
Is it the best way to follow the description in the documentation to create a

DIB with CreateCompatibleBitmap
"If a DIB section, which is a bitmap created by the CreateDIBSection function,

is selected into the device context identified by the hdc parameter,

CreateCompatibleBitmap creates a DIB section.
Maybe someone has some simple example code for this.

 #10    01-27-04, 10:31 PM 
John Hornick [MSFT]
 
Hi,

The actual device DC doesn't have a bitmap in it. It's backed by
the device, and doesn't need a memory bitmap.

Win9x is generally more restrictive than NT OSs.

Just use CreateDIBSection() to create the DIBSection.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit
http://www.microsoft.com/security for current information on security.

 

 

> Ok, now I understand what the problem is.
But I have 2 more questions regarding this subject:

1. How does Windows create a bitmap for a printer DC? If I get a printer DC
from Windows (e.g. in the OnPrint handler) the bitmap in the DC must be
very large if I have e.g. a plotter paper with DinA1? This must be a large
bitmap.
2. Do I have the same size limitaion under Windows 95/98/ME (16 MB) if I
use a DIB instead of a DDB?
Is it the best way to follow the description in the documentation to create
a DIB with CreateCompatibleBitmap?
"If a DIB section, which is a bitmap created by the CreateDIBSection
function, is selected into the device context identified by the hdc
parameter, CreateCompatibleBitmap creates a DIB section."
Maybe someone has some simple example code for this.

 #11    01-28-04, 10:51 AM 
Marc
 
Thank you for your answer.

Win9x is generally more restrictive than NT OSs.

Just use CreateDIBSection() to create the DIBSection.

I have done this and it works fine under NT/2000/XP but that seems not to solve

my problem under ME.
So if ME is so strict (max. 16MB) I will have to find an other solution. Maybe

I have to split my source bitmap into multiple parts and then copy the bands to

my target DC using StretchDIBits.
Is there a "build in" solution in MFC to do this?

 #12    01-31-04, 12:31 AM 
John Hornick [MSFT]
 
Hi,

I don't think MFC has anything special to offer here.

I thought I recalled that you could create larger DIBSections on Win9x.
Have you tried it?

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit
http://www.microsoft.com/security for current information on security.

 

 

 

> Thank you for your answer.

Win9x is generally more restrictive than NT OSs.

Just use CreateDIBSection() to create the DIBSection.

I have done this and it works fine under NT/2000/XP but that seems not to
solve my problem under ME.
So if ME is so strict (max. 16MB) I will have to find an other solution.
Maybe I have to split my source bitmap into multiple parts and then copy
the bands to my target DC using StretchDIBits.
Is there a "build in" solution in MFC to do this?

 #13    01-31-04, 12:56 AM 
Severian
 
On Wed, 28 Jan 2004 03:51:07 -0800, "Marc"
<anonymous> wrote:

>Thank you for your answer.
>
> Win9x is generally more restrictive than NT OSs.
>
> Just use CreateDIBSection() to create the DIBSection.
>
>I have done this and it works fine under NT/2000/XP but that seems not to

solve my problem under ME.
>So if ME is so strict (max. 16MB) I will have to find an other solution. Maybe

I have to split my source bitmap into multiple parts and then copy the bands to

my target DC using StretchDIBits.
>Is there a "build in" solution in MFC to do this?

I'm sure there's no 16Mb limit to DIB sections on ME. I know my
applications creates much larger ones, and it runs fine on ME.

Limits to DDB size may be imposed by the display driver in addition to
the O/S, but (AFAIK) the driver is not involved in DIB sections.

- Sev

 #14    02-02-04, 11:26 AM 
Marc
 
Thank you for your help
I have written a small test application which can create DIBs using

CreateCompatibleBitmap (with a DIB already selected into the DC) or

CreateDIBSection and made some tests under Windows ME with a 256 MB PC
If I use CreateDIBSection it seems that I can create very large bitmaps. But

CreateCompatibleBitmap with DIBs seems to be a little bit more restrictiv

But I know I have decided that I use some sort of bitmap banding to do the job.

I devide my large bitmap into smaller bands (chunks) with a size of approx. 8

MB. After I have created each band I use StretchDIBits to copy the band to the

printer DC to its correct position on the output DC. So my memory usage should

be very small
Unfortunately my drawing functions which can create the large bitmap can only

paint the whole bitmap into a DC. So I have to paint the whole bitmap if I want

to paint a band. I use SetViewportOrg to force the drawing function to paint

the part of the bitmap which is my current band.
That leads me to another question: Does GDI paint the whole bitmap if I only

pass a smaller bitmap (= my band) as output to my drawing function? E.g. my

source bitmap is 6000x6000 but I give only a 100x100 bitmap in my output DC in

which the large bitmap is drawn

 #15    02-02-04, 02:06 PM 
Marc
 
Thank you for your help.
I have written a small test application which can create DIBs using

CreateCompatibleBitmap (with a DIB already selected into the DC) or

CreateDIBSection and made some tests under Windows ME with a 256 MB PC.
If I use CreateDIBSection it seems that I can create very large bitmaps. But

CreateCompatibleBitmap with DIBs seems to be a little bit more restrictiv.

But I know I have decided that I use some sort of bitmap banding to do the job.

I devide my large bitmap into smaller bands (chunks) with a size of approx. 8

MB. After I have created each band I use StretchDIBits to copy the band to the

printer DC to its correct position on the output DC. So my memory usage should

be very small.
Unfortunately my drawing functions which can create the large bitmap can only

paint the whole bitmap into a DC. So I have to paint the whole bitmap if I want

to paint a band. I use SetViewportOrg to force the drawing function to paint

the part of the bitmap which is my current band.
That leads me to another question: Does GDI paint the whole bitmap if I only

pass a smaller bitmap (= my band) as output to my drawing function? E.g. my

source bitmap is 6000x6000 but I give only a 100x100 bitmap in my output DC in

which the large bitmap is drawn?

基于若依的ruoyi-nbcio-plus支持VForm3表单字段数据保存到数据库的一种方法——全网首创(三) 阅读详情

相关推荐

​​瑞芯微RK系列 vs 全志系列芯片:终极选型指南(2025版)​

​。

jinxi996611的博客 1万+

CBitmap、CreateCompatibleBitmap、CreateBitmap

第二个区别意味着:非兼容位图拷贝到显示界面上往往需要进行颜色转换,因为它要符合显示驱动的颜色格式才能正常地显示出来,常用的位图格式是24位RGB888,而显示驱动常用的格式是16位RGB565、32位ARGB8888,自然免不了转换,这部分工作都是在显示驱动中进行的,如果仅有一两次转换或少量像素的转换可能不会有什么,但如果是大量的绘图操作,意味着每次拷贝都会进行转换,这将把宝贵的系统资源消耗在位图的转换上。二、兼容位图CreateCompatibleBitmap和非兼容位图CreateBitmap的区别。

zxf347085420的博客 1047

Virbox Protector:全方位守护 Android 应用安全

在数字化浪潮中,Android 应用面临着诸多安全挑战,如破解、篡改、盗版、数据窃取和钓鱼欺诈等。为了应对这些复杂的安全问题,Virbox Protector 应运而生,为 Android 应用提供高强度的专业化安全保护,支持对 APK 和 AAB 文件的加固保护,并兼容 Google Play,助力应用顺利出海。

VBP_2025的博客 998

GDI编程小结

图形设备接口(GDI)是一个可执行程序,它接受Windows应用程序的绘图请求(表现为GDI函数调用),并将它们传给相应的设备驱动程序,完成特定于硬件的输出,象打印机输出和屏幕输出。GDI负责Windows的所有图形输出,包括屏幕上输出像素、在打印机上输出硬拷贝以及绘制Windows用户界面。也就是Windows的图形编程。 一、GDI体系结构 1、  GDI32.DLL导出的函数 GDI提

锄禾日当午 2227

HarmonyOS逆向降级实战:从鸿蒙2.0回退至EMUI 10.1的完整路径解析

本文详细解析了从HarmonyOS 2.0逆向降级至EMUI 10.1的完整操作流程,涵盖必备工具准备、数据备份策略及阶梯式降级步骤。针对华为手机用户遇到的兼容性问题,提供HiSuite和HiSuite Proxy工具的具体使用方法,并分享降级失败应急处理与系统优化技巧,帮助用户安全高效完成系统回退。

weixin_27741699的博客 1997

TSmaster CANFD配置避坑指南:为什么你的PCAN盒不支持最新版本?

本文针对TSmaster配置PCAN硬件进行CANFD通信时的常见问题,提供了详细的避坑指南。重点解析了CANFD配置中TSEG1等关键参数的理解误区,并深入探讨了TSmaster新版本与PCAN硬件驱动之间的兼容性变化,帮助工程师快速定位并解决连接失败或无法发送CANFD报文等问题。

alpha的博客 554

关于CreateCompatibleBitmap创建位图失败的解决方法

在做CDC双缓冲时CreateCompatibleBitmap 创建位图, 但是发现当位图特别大时, 就返回0 创建失败, 查询错误码是8 内存不足 虽然位图比较大, 但还没有到内存不足的地步啊!!! 查询得到:  CreateCompatibleBitmap 创建位图使用的的是系统内核的分页内存,这是稀有资源。 替代方法是: CreateDIBSection  它使用虚拟内存创建位图

cay22的专栏 5467

YOLOv8 TensorRT C++部署实战详解:从XMake构建到推理流水线

本项目实现了一个基于YOLOv8和TensorRT的高性能火灾烟雾检测系统,具有以下核心特点: 技术架构:采用TensorRT 8.6+进行GPU加速推理,结合CUDA 12.1和OpenCV 4.8+,实现高效计算机视觉处理。系统使用XMake替代CMake构建,配置更简洁高效。

hscing的博客 1075

CE6下兼容和非兼容位图的深入分析

兼容位图即DDB,由CreateCompatibleBitmap创建;非兼容位图即DIB,是由LoadImage、SHLoadBitmap、CreateDIBSection、CreateBitmap创建。 非兼容位图和兼容位图有两个本质差别 第一个区别是兼容位图的存放空间通常由GWES或显示驱动分配,处于驱动层之中,可以获取到存放数据的物理地址,而非兼容位图的存放空间通常由应用程序分配,处于应

alien75的专栏 1516

DLPFC.h5ad格式数据简便获取方式+STAGATE论文复现问题

简便获取DLPFC.h5ad格式的数据方式

apple_74057836的博客 2264

《双剑合璧:双 IMU 驱动的高精度 AHRS 实战宝典(基于 ROS2)》

本文系统阐述了基于双IMU的高精度姿态与航向参考系统(AHRS)设计与实现方法。文章首先分析了传统单IMU系统的局限性,提出通过双IMU冗余配置实现性能互补的方案。从硬件设计要点(包括IMU选型策略、电路降噪方法、PCB布局规范),到算法实现方案(互补滤波、卡尔曼滤波等融合算法),再到ROS2软件架构与调优策略,全方位展示了双IMU系统的技术实现路径。特别强调快速性与高精度平衡的方法,包括动态参数调整、双IMU权重优化等核心技巧。最后总结了硬件降噪、算法调优等实用心法。

bother3000的博客 2031

CreateCompatibleBitmap返回错误码8的原因及解决方案

转自:http://hi.baidu.com/li_kun_peng/item/785d84f5ec21014c932af2b2 最近测试程序,发现一个图片显示程序在一台512M内存的机器上同时打开5个以后,就无法显示图片了。在网上查了一下,CSDN有袁峰回答了一个类似问题。根据袁峰的提示,我找了他的书《Windows图形编程》(英文名:Windows Graphics Programm

1445

DataCastle-租金预测

ID:编号;时间:房屋信息采集的时间;小区名:房屋所在小区,已脱敏处理;小区房屋出租数量:小区出租房屋数量,已脱敏处理;楼层:0、1、2分别表示楼层低,中,高;总层数:房屋所在建筑的总楼层数,已脱敏处理;房屋面积:房屋面积数值,已脱敏处理;房屋朝向:房屋的朝向;居住状态:房屋的居住状态,表示是否已出租或居住中,已脱敏处理;卧室数量:户型信息,数字表示卧室的个数;卫的数量:户型信息,数字表示卫生间的个数;厅的数量:户型信息,数字表示厅的个数;

CSDN 精品推荐 3470

CBitmap和HBITMAP的区别及相互转换方法

hbitmap是bitmap的指针,msdn中:Handle to a bitmap.typedef HANDLE HBITMAP;cbitmap是mfc中封装bitmap的类;msdn中: Encapsulates(囊括) a Windows graphics device interface (GDI) bitmap and provides member func

newstarao的专栏 1万+

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

HICON与HBITMAP相互转换

将BMP转换成ICON图标 方法一、 HICON HICONFromCBitmap( CBitmap& bitmap) {   BITMAP bmp;   bitmap.GetBitmap(&bmp);     HBITMAP hbmMask = ::CreateCompatibleBitmap(::GetDC(NULL),     bmp.bmWidth, bmp.bmHei

程序人生的专栏 1万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

CBitmap 与 HBITMAP

CBitmap   bmp;     bmp.LoadBitmap(IDB_BITMAP1);     HBITMAP   hbm   =   (HBITMAP)bmp;     CBitmap   bmp1;     bmp1.Attach(hbm);HBITMAP   =   CBitmap.m_hObject     CBitmap*   =   CBitmap.FromHandle(H

渴了喝水 695

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Windows API GDI(2) CreateCompatibleDC、CreateCompatibleBitmap、SelectObject和BitBlt函数

CreateCompatibleDC 说明: The CreateCompatibleDC function creates a memory device context(DC) compatible with thespecified device. “设备上下文”、“设备环境”是The Device Context的翻译。 设备上下文是一种包含有关某个设备(如显示器或打印机)的绘制属性信息的 Windows 数据结构。所有绘制调用都通过设备上下文对象进行,这些对象封装了用于绘制线条、形状和文本的 W

Z_Paper的博客 2060

CreateComatibleBitmap使用不当,在DC上画出来的图一片黑

下面这些代码你能看出什么问题吗? HDC hdc=GetDC(NULL); HDC mem_dc = CreateCompatibleDC(NULL); m_hBmp = CreateCompatibleBitmap( mem_dc, width, height ); HBITMAP oldBitmap = (HBITMAP)SelectObject(mem_dc, m_hBmp

吴遥的专栏 1539

CreateCompatibleBitmap返回NULL,GetLastError却返回0

memBM = CreateCompatibleBitmap(m_baseDC, bmp->width, bmp->height); if ( memBM == NULL ) { XExit(XEXIT_CODE_GDI, "CreateCompatibleBitmap(0x%x, %d, %d) fail: %d\n", m_baseDC, bmp->wi

chenyujing1234的专栏 2996

CreateDIBSection

  理解分辨率我们常说的屏幕分辨率为640×480,刷新频率为70Hz,意思是说每行要扫描640个象素,一共有480行,每秒重复扫描屏幕70次。 理解调色板有一个长宽各为200个象素,颜色数为16色的彩色图,每一个象素都用R、G、B三个分量表示。因为每个分量有256个级别,要用8位(bit),即一个字节(byte)来表示,所以每个象素需要用3个字节。整个图象要用200×200×

105694832的专栏 7194
上一篇: User.GetDC Method
下一篇: CreateCompatibleBitmap failing
akinoo
博客等级 码龄17年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值