管理旋转移动栅格地图
我的应用程序呈现一个(光栅)移动地图。 我需要能够显示基于任何给定角度旋转的地图。 该程序当前使用 VC++/MFC,但问题是通用的。 我有一个源位图(CBitmap 或 HBITMAP),并使用 StretchBlt 将其绘制到设备上下文 (CDC)。 虽然对于angle=0(并且用户可以用鼠标平滑地抓取地图),这可以快速且平滑地工作,但如果我尝试旋转位图然后呈现它(使用 SetWorldTransform() 旋转位图),则情况并非如此大约需要数百毫秒,这太慢了)。
我认为解决方案是能够仅与当前屏幕上的像素相关,而不是旋转原始源位图 - 这是关键。
如果有人有类似实施的经验,那么它可能会节省我大量的试错工作。 谢谢! 阿维。
My application present a (raster) moving map.
I need to be able to show the map rotated base on any given angle.
The program is currently in VC++/MFC but the problem is generic.
I have a source bitmap (CBitmap or HBITMAP) and draw it to the device context (CDC) using StretchBlt.
While this works fast and smooth for angle=0 (and the user can grab the map smoothly with the mouse), this is not the case if I try to rotate the bitmap and then present it (the rotation of the bitmap using SetWorldTransform() or so takes hundreds of miliseconds and this is too slow).
I think that the solution is to be able to relate only to the pixels that currently on the screen and not rotating the original source bitmap - and this is the key.
If someone has experience with similar implementation then it might save me lots of trial and error efforts.
Thanks!
Avi.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来 SetWorldTransform 非常慢:
http://www.codeguru.com/Cpp/GM/ bitmap/specialeffects/article.php/c1743
虽然该文章中提供的其他选项速度更快,但当然还有其他更好的解决方案,如下所示:
http://www.codeguru.com/cpp/gm/gdi /article.php/c3693/ (也请检查评论中的修复和改进)
此外,这里还有一些非 Windows 中心的快速旋转算法:
http://www.ddj.com/windows/184416337?pgno=11
请注意,如果您保证 2 维的能力,您可以获得显着的速度提升。
It looks like SetWorldTransform is extremely slow:
http://www.codeguru.com/Cpp/G-M/bitmap/specialeffects/article.php/c1743
And while the other options presented in that article are faster, there are of course other better solutions like this:
http://www.codeguru.com/cpp/g-m/gdi/article.php/c3693/ (check the comments for fixes and improvements as well)
Also here are some non-Windows centric fast rotation algorithms:
http://www.ddj.com/windows/184416337?pgno=11
Note that if you guarantee power of 2 dimensions you can get significant speed improvements.
作为我的问题和提供的答案的后续,让我总结以下内容:
我使用了 http://www.codeguru.com/cpp/gm/gdi/article.php/c3693/。
它可以工作,并提供非常好的性能和流畅的显示。
其中存在一些错误,我需要修复并简化公式和
在某些情况下代码。
我将检查 http://www.ddj.com/ 中提到的算法windows/184416337?pgno=11 看看它是否提供了一些值得调整的突破性性能。
我的实现需要使用大型源位图,因此我需要修改代码,这样我就不会每次都旋转整个位图,而只会旋转将在屏幕上显示的相关部分(否则性能将无法接受)。< /p>
阿维。
As follow up to my question and provided answer, let me summarize the following:
I used the algorithm mentioned at http://www.codeguru.com/cpp/g-m/gdi/article.php/c3693/.
It works and provide pretty good performance and smooth display.
There were some bugs in it that I needed to fix as well as simplify the formulas and
code in some cases.
I will examine the algorithm mentioned at http://www.ddj.com/windows/184416337?pgno=11 to see if it provides some break through performance that worth adapting it.
My implementation required using a large source bitmap, so I needed to modify the code so I will not rotate the whole bitmap each time but only the relevant portion that will be displayed at the screen (otherwise performance would be unacceptable).
Avi.