我们可以在 GDI 中使用 png 代替位图进行 bitblt 吗?
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);
GetObject(g_hbmBall, sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
我发现很多游戏都使用位图来显示动画。但我们可以用 png 代替吗?
因为当我从 png 转换时,位图相当大(位图中 1kb -> 12kb)
感谢您阅读本文:)
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);
GetObject(g_hbmBall, sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
I've found that many games use bitmap for displaying animation . But can we use png instead ?
Because bitmap is quite big when i convert fron png ( 1kb -> 12kb in bitmap )
Thanks for reading this :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,您不能使用 PNG 来
BitBlt
。BitBlt
(顺便说一句,它代表“位块传输”)非常快,但它基本上只是一个简单的内存复制例程。因此,BitBlt
除未压缩位图之外的任何图像格式的唯一方法是首先将该格式转换为位图。顺便说一句,应用程序通常使用位图进行动画,因为您不希望每次都必须解压缩精灵图像来增加整体帧渲染时间。位图只是通常在内存中缓存内容以提高性能的一个示例。
No, you can't
BitBlt
with a PNG.BitBlt
(which stands for "bit block transfer", by the way) is very fast, but it is basically just a simple memory copying routine. So the only way toBitBlt
any image format other than an uncompressed bitmap is to first convert that format to a bitmap.By the way, applications typically use bitmaps for animation because you don't want to increase your overall frame rendering time by having to uncompress your sprite images each time. Bitmaps are just an example of generally caching things in memory to improve performance.
不,我不这么认为,但 GDI+ 支持 PNG 以及其他几种格式。
No, I don't think so, but GDI+ supports PNG among several other formats.