2

我的应用程序呈现(光栅)移动地图。我需要能够显示基于任何给定角度旋转的地图。该程序目前在 VC++/MFC 中,但问题是一般性的。我有一个源位图(CBitmap 或 HBITMAP)并使用 StretchBlt 将其绘制到设备上下文(CDC)。虽然这对于角度 = 0 快速且平滑(并且用户可以用鼠标平滑地抓取地图),但如果我尝试旋转位图然后呈现它(使用 SetWorldTransform() 旋转位图),情况并非如此大约需要数百毫秒,这太慢了)。

我认为解决方案是只能与当前屏幕上的像素相关,而不是旋转原始源位图——这是关键。

如果有人有类似实现的经验,那么它可能会为我节省大量的试错工作。谢谢!艾维。

4

2 回答 2

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

请注意,如果您保证二维的功率,您可以获得显着的速度提升。

于 2009-12-04T20:55:48.830 回答
1

As follow up to my question and provided answer, let me summarize the following:

  1. I used the algorithm mentioned at http://www.codeguru.com/cpp/g-m/gdi/article.php/c3693/.

  2. It works and provide pretty good performance and smooth display.

  3. There were some bugs in it that I needed to fix as well as simplify the formulas and code in some cases.

  4. 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.

  5. 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.

于 2010-01-02T19:16:20.403 回答