如何创建每像素 24 位的内存 DC?
我需要它使用 GDI 函数(特别是 StretchBlt() ,速度相当快)处理 RGB24 数据,并且我不能使用 CreateCompatibleDC(),因为它只能创建具有其他 DC 颜色深度的内存 DC。通常它与屏幕 DC 一起使用(通过向函数传输 NULL 指针),并且通常屏幕的颜色深度值为 32。此外,我不能依赖它,因为如果屏幕设置发生更改,我的应用程序可能无法工作。
所以我需要某种方法来创建具有特定颜色深度的内存 DC。到目前为止,我只找到了一种使用 CreateDC() 函数的方法,但它需要许多设备特定的参数,并且对我来说似乎有些不可靠。此外,有太多字段需要填充适当的值来调用 CreateDC()。
是否有一些更简单的方法来创建特定的内存 DC 并且不依赖某些设备?或者即使创建 24 bpp 的内存 DC?
PS我需要它来一些快速的图形。我尝试过手动向位图添加 alpha 通道,以便将其与兼容屏幕 32bpp 内存 DC 一起使用,并且成功了,但速度太慢。正如我上面所说,我不能依赖可以更改的屏幕设置。
I need it to work with RGB24 data using GDI functions (specifically StretchBlt() which is pretty fast) and I can't use CreateCompatibleDC() since it can create memory DC only with color depth of other DC. Usually it's used with screen DC (by transmitting NULL pointer to function) and usually screen has color depth of value 32. In addition I can't rely on it, 'coz if screen settings are changed my application probably won't work.
So I need some way to create memory DC with specific certain color depth. So far I've found only one way with using CreateDC() function but it requires many device specific parameters and seems somewhat unreliable for me. Moreover there are too many fields to be filled with appropriate values to call CreateDC().
Is there some easier way to create specific memory DC and not rely on some devices? Or even if to create memory DC with 24 bpp?
P.S. I need it for some fast graphics. I've tried manual adding alpha channel to bitmap for using it with compatible to screen 32bpp memory DC and it worked out, but was too slow. And as I said above, I can't rely on screen settings which can be changed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每像素位数并不真正取决于 DC,而是取决于选择到其中的位图。使用 CreateDIBSection 创建 24bpp 位图,然后将其选择到内存 DC 中。
Bits-per-pixel does not really depend on a DC, but on the bitmap selected into it. Create a 24bpp bitmap with
CreateDIBSection
then select it into a memory DC.