c++ - 如何在 Windows 8 上使用 C++ 将 .jpg 转换为 .png?

标签 c++ windows-8 png jpeg

我一直在研究BitmapDecoderBitmapEncoder,但我不知道如何将数据从jpg解码器获取到png编码器。我发现的唯一接近的东西是 BitmapEncoder::CreateForTranscodingAsync() 但那是在两种图像格式相同的情况下。

最佳答案

使用 ImageMagick 库怎么样?

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

有一个 C++ API ... inthe documentation我在 2 分钟的搜索中找到了这个:

#include  
using namespace std; 
using namespace Magick; 
int main(int argc,char **argv) 
{ 
  InitializeMagick(*argv);

  // Read GIF file from disk 
  Image image( "giraffe.gif" );
  // Write to BLOB in JPEG format 
  Blob blob; 
  image.magick( "JPEG" ) // Set JPEG output format 
  image.write( &blob );

  [ Use BLOB data (in JPEG format) here ]

  return 0; 
}

就我个人而言,我可以推荐这个库,它与 ImageMagick 进行了相当广泛的合作(尽管使用了 C API...)

编辑:您可以将图像写入内存 blob 并将字节传递给编码器...

关于c++ - 如何在 Windows 8 上使用 C++ 将 .jpg 转换为 .png?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13739463/

相关文章:

c++ - 如何用 C++ 或 C 创建和编写索引 png 图像

c++ - Stereo Vision.exe : 0xC0000005: Access violation writing location 0x00000014 中 0x77081d76 (ntdll.dll) 的未处理异常

c++ - 排序对不起作用

c++ - 可变大小指针数组

c++ - 我可以使用 gMock 在测试代码中模拟对象创建吗?

c# - 为什么 WinRT 需要 DefaultOverloadAttribute?

.net - 如果NETFX_CORE适用于Windows 8,那么适用于Windows Phone 8?

c++ - 如何在 Visual Studio 2005 中使用 Manifest 文件以管理员权限运行应用程序?

ios - 如果文件不是图像则捕获错误

python - 使用 Ruby 或 Python 创建静态图形文件(png、gif、jpg)