C++ 将 ppm 转换为 png

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4012889/
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-08-28 14:17:29  来源:igfitidea点击:

Converting ppm to png

c++image

提问by Harshad Kshirsagar

In Linux I am getting .PPM files as the image format, this needs to be converted to PNG and then saved. I was looking at some API's to achieve this conversion from PPM to PNG. Can this be done using GDI+, as this would become native?

在 Linux 中,我将 .PPM 文件作为图像格式,这需要转换为 PNG 然后保存。我正在寻找一些 API 来实现从 PPM 到 PNG 的这种转换。这可以使用 GDI+ 完成吗,因为这将成为本机?

If that is not possible then I think freeimage or pnglib can accomplish that, however I would prefer to use native gdi+ if possible.

如果这是不可能的,那么我认为 freeimage 或 pnglib 可以做到这一点,但是如果可能的话,我更愿意使用本机 gdi+。

回答by joni

Quick and dirty: download Imagemagick and use it from CLI:

快速而肮脏:下载 Imagemagick 并从 CLI 使用它:

convert xx.ppm xx.png

or use Imagemagick's dll API

或使用 Imagemagick 的 dll API

回答by Mark Setchell

Whilst ImageMagickwill happily do what you need, it is actually a sledgehammer to crack a nut, and considerably more cumbersome and space and time-consuming to install than the NetPBMsuite.

虽然ImageMagick会很乐意做你需要的事情,但它实际上是一把大锤,比NetPBM套件安装起来要麻烦得多,而且安装起来更费时。

With that, you would do:

有了这个,你会这样做:

pnmtopng image.ppm > result.png

回答by B?ови?

You can use ImageMagick library :

您可以使用 ImageMagick 库:

http://www.imagemagick.org/script/index.php

http://www.imagemagick.org/script/index.php

but it does lots of other things.

但它做很多其他的事情。

回答by Goz

Well GDI+ does not natively support the PPM format. So you will need a librarywhatever you do.

GDI+ 本身并不支持 PPM 格式。所以无论你做什么,你都需要一个图书馆