windows 使用 Win32/C++ 读取 PNG

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1391541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:05:50  来源:igfitidea点击:

Read a PNG Using Win32 / C++

windowswinapipng

提问by I. J. Kennedy

That there is no simpleway to read a PNG file into a memory bitmap in native Windows seemed impossible, but after much googling I'm beginning to believe it. The libpng/zlib combination is just too big. Any third-party libraries Win32 libraries out there for reading a PNG?

在本机 Windows 中没有简单的方法将 PNG 文件读入内存位图似乎是不可能的,但经过多次谷歌搜索后,我开始相信它。libpng/zlib 组合太大了。任何用于读取 PNG 的第三方库 Win32 库?

Edit: The boost::gil::png solution is much more complex than I'd hoped, too. Just need a single call that takes a file name and fills a memory buffer with pixels.

编辑: boost::gil::png 解决方案也比我希望的要复杂得多。只需要一次调用即可获取文件名并用像素填充内存缓冲区。

回答by ReinstateMonica Larry Osterman

Or of course you could use GDI+ - The Bitmapobject takes a string constructor and loads the specified file into memory. That way you don't need any external libraries, just that which comes with windows.

或者当然您可以使用 GDI+ - Bitmap对象采用字符串构造函数并将指定的文件加载到内存中。这样你就不需要任何外部库,只需要 Windows 自带的库。

回答by Greg Hewgill

libgdis an excellent library that can be used in Windows and has bindings for many popular languages.

libgd是一个优秀的库,可以在 Windows 中使用,并且具有许多流行语言的绑定。

回答by Anders

There is some built-in stuff you can use: IImgCtxand on later versions of windows you also have WIC

你可以使用一些内置的东西:IImgCtx和更高版本的 Windows 你也有WIC

回答by Adam Pierce

I have successfully used libpngto do this.

我已经成功地使用libpng来做到这一点。