GDI 哪个更快?或者libpng?

发布于 2024-09-13 05:35:34 字数 170 浏览 1 评论 0原文

我有一个 HBITMAP ,我想尽快将其转换为 png 格式(在内存中我有 malloc),所以我的问题是我应该使用 GDI+ 吗> 或libpng

我尝试过使用 GDI+,但它似乎没有我希望的那么快。 我也尝试过 FreeImage,但速度太慢了。

I have an HBITMAP and I would like to convert it to png format(in memory I have malloc'd)as fast as possible, so my question is should I go with GDI+ or libpng?

I've tried using GDI+, but it doesn't seem as fast as I would like it to be.
I've also tried FreeImage and it was way too slow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烂人 2024-09-20 05:35:34

在我的测试中,使用默认设置运行 libpng 大约比 GDI+ 慢 2 到 3 倍,但往往会生成压缩程度更高的 png 文件。

根据输入位图的不同,结果会有很大差异。在一个极端情况下,我有一个 1680x1050 位图,libpng 花了大约 1.23 秒将其编码为 1531k png; GDI+ 只花了 0.35 秒来处理该位图,但它的 png 大小却高达 2391k。但对于另一个相同大小的位图(实际上是该堆栈溢出页面的屏幕截图),libpng 在 0.305 秒内生成了 294k png,而 GDI+ 在 0.097 秒内生成了 318k png。

根据 pngcheck,GDI+ 生成的 png 不进行任何行级预测过滤,并且还使用 zlib 压缩的快速版本。 Libpng 使用“默认 zlib 压缩”,并且似乎还根据行及其邻居的内容使用不同的预测过滤器。想必您可以使用 png_set_compression_level() 来让 libpng 产生类似于 GDI+ 所提供的大小/速度权衡。

最后一点——我在 png 测试中使用了 PNG_INTERLACE_NONE 。 PNG_INTERLACE_ADAM7 似乎确实损害了 png 压缩比,所以我会避免它,除非你真的想要渐进式渲染图像。

In my tests, running libpng with its default settings is roughly 2 to 3 times slower than GDI+, but tends to produce more highly compressed png files.

The results vary considerably depending on the input bitmap. On one extreme, I had a 1680x1050 bitmap which libpng took about 1.23 seconds to encode as a 1531k png; GDI+ took only 0.35 secs to process that bitmap, but its png was a whopping 2391k. But for another bitmap of the same size (actually a screen grab of this stack overflow page) libpng generated 294k png in 0.305 seconds while GDI+ generated a 318k png in 0.097 seconds.

According to pngcheck, the GDI+ generated pngs don't do any row-level predictive filtering and also use a fast version of zlib compression. Libpng uses "default zlib compression" and also appears to use different predictive filters depending on the contents of a row and its neighbours. Presumably you could use png_set_compression_level() to get libpng to produce a size/speed trade-off similar to what GDI+ gives you.

One final point -- I used PNG_INTERLACE_NONE in my png tests. PNG_INTERLACE_ADAM7 seemed to really hurt png compression ratios, so I'd avoid it unless you really want progressive rendering of your images.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文