如何在不丢失颜色键信息的情况下缩放精灵图像?
我目前正在开发一个简单的应用程序,用于显示地图并在其上绘制一些标记。我正在为 Windows Mobile 进行开发,因此我决定使用 DirectDraw 和 Imaging 接口来使应用程序快速且美观。当用户在触摸屏上移动手指时,地图就会移动,因此整个地图移动/滚动动画必须很快,但事实并非如此。
每次地图更新时,我都必须绘制地图的一部分、控制按钮和标记 - 按钮和标记作为 mipmap 预加载到 DirectDraw 表面上。因此,我唯一要做的就是从 mipmap 到后台缓冲区,以及从后台缓冲区到主表面的 BitBlit(由于我的应用程序的窗口模式,我无法使用页面翻转)。
以前,我使用具有 32 位 ARGB 像素格式的预乘 alpha 曲面来生成图像 mipmap,一切看起来都不错,但绘制整个“场景”速度非常慢 - 我可能会忘记平滑的地图滚动。现在,我使用具有本机 (RGB565) 像素格式和紫红色 (0xFF00FF) 颜色键的 mipmap。画画就好多了。
我的 mipmap 表面是在程序加载时生成的 - 图像从文件加载、缩放(通过过滤)并在 mipmap 上绘制。问题是,图像缩放过程混合了像素颜色,并且位于精灵区域边界上的那些像素与周围的紫红色像素混合,产生不被视为颜色键的半紫红色。当我使用颜色键选项进行位块传输时,精灵有紫红色的小边框,看起来非常糟糕。
如何解决这个问题呢?我可以使用 alpha blitting,但它太慢了 - 即使是 ARGB 1555 格式。
I'm currently developing a simple application that displays map and draws some markers on it. I'm developing for Windows Mobile, so I decided to use DirectDraw and Imaging interfaces to make the application fast and pretty. The map moves when user moves finger on the touchscreen, so the whole map moving/scrolling animation has to be fast, but it is not.
On every map update I have to draw portion of the map, control buttons, and markers - buttons and markers are preloaded on DirectDraw surface as a mipmap. So the only thing I do is BitBlit from the mipmap to a back buffer, and from the back buffer to a primary surface (I can't use page flipping due to the windowed mode of my application).
Previously I used premultiplied-alpha surface with 32 bit ARGB pixel format for images mipmap, everything was looking good, but drawing entire "scene" was horribly slow - i could forget about smooth map scrolling. Now I'm using mipmap with native (RGB565) pixel format and fuchsia (0xFF00FF) color key. Drawing is much better.
My mipmap surface is generated on program loading - images are loaded from files, scaled (with filtering) and drawn on mipmap. The problem is, that image scaling process blends pixel colors, and those pixels which are on the border of a sprite region are blended with surrounding fuchsia pixels resulting semi-fuchsia color that is not treated as color key. When I do blitting with color key option, sprites have small fuchsia-like borders, and it looks really bad.
How to solve this problem? I can use alpha blitting, but it is too slow - even in ARGB 1555 format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论