是否可以使用指针直接(低级)写入窗口而不使用 Bitblt?
我编写了一个浮雕滤镜,将两个图像混合成一个立体图像。这是一个快速例程,一次处理一个像素。 现在,我使用指针将每个计算出的像素输出到内存位图,然后将整个图像 Bitblt 到窗口上。
这对我来说似乎多余。我宁愿将每个像素直接复制到屏幕上,因为我的浮雕例程非常快。是否可以绕过 Bitblt 并简单地让指针直接指向 Bitblt 将其复制到的位置?
I have written an anaglyph filter that mixes two images into one stereographic image. It is a fast routine that works with one pixel at a time.
Right now I'm using pointers to output each calculated pixel to a memory bitmap, then Bitblt that whole image onto the window.
This seems redundant to me. I'd rather copy each pixel directly to the screen, since my anaglyph routine is quite fast. Is it possible to bypass Bitblt and simply have the pointer point directly to wherever Bitblt would copy it to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我确信这是可能的,但你真的真的不想这样做。一次绘制整个图案效率更高。
I'm sure it's possible, but you really really really don't want to do this. It's much more efficient to draw the entire pattern at once.
您无法从 Windows 直接绘制到屏幕,因为图形卡内存不一定以任何合理的顺序映射。
传输到屏幕的速度快得惊人。
请记住,您不会在每个像素之后进行 blt - 仅当您想要显示新结果时,即使如此,也没有必要比屏幕上的刷新速度更快 - 可能是 60hz
You can't draw directly to the screen from windows because the graphics card memory isn't necessarily mapped in any sane order.
Bltting to the screen is amazingly fast.
Remember you don't blt after each pixel - only when you want a new result to be shown, even then there's no point doing this faster than the refresh on your screen - probably 60hz
您正在 OpenGL 中寻找类似 glMapBuffer 的东西,但直接访问屏幕。
但逐像素写入 GPU 内存是您可以执行的较慢的操作。如果发送大数据流,PCI 的工作速度会更快。另外,写入和读取数据时也会出现很多问题。像素布局也很重要(请参阅有关快速纹理传输的 nvidia 文档)。 Bitblt 将以驱动程序优化的方式为您完成此操作。
You are looking for something like glMapBuffer in OpenGL, but acessing directly to the screen.
But writing to the GPU memory pixel per pixel is the slower operation you can do. PCI works faster if you send big streams of data. Also, there are many issues if you write and read data. And the pixel layout is also important (see nvidia docs about fast texture transfers). Bitblt will do it for you in a driver optimised way.