从像素缓冲块传送到设备上下文最快速的方法 [英] Fastest method for blitting from a pixel buffer into a device context

查看:249
本文介绍了从像素缓冲块传送到设备上下文最快速的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,

我在内存缓冲区几个32位图像,我希望位图传送设备上下文,快捷。速度是这里的一个问题,因为缓冲区将不断操纵,需要反复BitBlt到直流。

I have several 32-bit images in memory buffers that I wish to "blit" to a device context, quickly. Speed is an issue here because the buffer will be manipulated constantly and need to be blitted to the DC repeatedly.

缓冲器的颜色深度是32位,所以它已经在SetDIBits的DIB预期格式()。然而,由于SetDIBits的位图目标()不能被选择成之前的操作直流这是相当麻烦的。所以,我需要不断地换出DC的位图,调用SetDIBits(),交换位图回直流,然后blit的DC到窗口的DC。对我来说,这似乎只是工作量在CPU和Windows API太多分枝很多;太多以获得最佳性能。

The color depth of the buffer is 32-bits, so it is already in the DIB-expected format of SetDIBits(). However, this is rather cumbersome since the bitmap target of SetDIBits() cannot be already selected into the DC prior to the operation. So I will need to constantly swap out the DC's bitmap, call SetDIBits(), swap the bitmap back into the DC, and then blit the DC to the Window's DC. To me, that just seems like a LOT of workload on the CPU and too much branching in the Windows API; way too much for optimal performance.

我有兴趣使用DirectX如果它没有强迫我用设备上下文的2D操作,或显示他们之前上传纹理显存,因为图像的内容是不断变化的。

I would be interested in using DirectX if it didn't force me to use Device Contexts for 2D operations, or uploading textures to video memory before displaying them, because the contents of the image are constantly changing.

我的问题很简单(虽然长的书面记录)。什么是对我来说,在内存中的blit从像素缓冲器的图像在屏幕上的最快方法?到DC的像素缓冲区的直接访问将是巨大的,但我知道这是不会发生的。

My question is simple (despite the long writeup). What would be the fastest way for me to blit an image from a pixel buffer in memory onto the screen? Direct access to the pixel buffer of a DC would be great, but I know that's not going to happen.

感谢您阅读我长的书面记录。

Thanks for reading my long writeup.

推荐答案

有一个API方法的 CreateDIBSection 来创建应用程序可直接写一个DIB。这允许连续地更新所述位图(或者存储器复制或直接写入到它)。

There is an API method CreateDIBSection to create a DIB that applications can write to directly. This allows to continuously updating the bitmap (either memcopy or directly writing to it).

详情参见MSDN文章。

See MSDN article for further details.

位图的访问必须同步。通过调用函数GdiFlush做到这一点。

Access to the bitmap must be synchronized. Do this by calling the GdiFlush function.

这篇关于从像素缓冲块传送到设备上下文最快速的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆