C# 将字节数组转换为 PNG/JPG
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8946846/
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
Converting a byte array to PNG/JPG
提问by user472875
I am currently working on an application that requires high-performance conversion of an unpadded byte array to either a PNG or JPEG. The image format doesn't matter, just as long as it's fast.
我目前正在开发一个需要将未填充字节数组高性能转换为 PNG 或 JPEG 的应用程序。图像格式无所谓,只要速度快就行。
I have tried the .NET libraries and the performance is very bad. Can anyone recommend a good freeware library for this?
我尝试过 .NET 库,但性能很差。任何人都可以为此推荐一个好的免费软件库吗?
EDIT: the byte[] is an 8bit grayscale bitmap
编辑:字节 [] 是一个 8 位灰度位图
采纳答案by Garrett Vlieger
回答by ahoffer
I like Imagemagick. http://www.imagemagick.org/script/api.php
我喜欢 Imagemagick。 http://www.imagemagick.org/script/api.php
回答by JayC
There are two problems with this question:
这个问题有两个问题:
Assuming you have a gray scale bitmap, you have two factors to consider:
假设您有一个灰度位图,您需要考虑两个因素:
- For JPGS... what loss of quality is tolerable?
- For pngs... what level of compression is tolerable? (Although for most things I've seen, you don't have that much of a choice, so this choice might be negligible.) For anybody thinking this question doesn't make sense: yes, you can change the amount of compression/number of passes attempted to compress; check out either Ifranview or some of it's plugins.
- 对于 JPGS... 质量损失是可以容忍的?
- 对于 png... 什么级别的压缩是可以容忍的?(虽然对于我见过的大多数事情,你没有那么多选择,所以这个选择可能可以忽略不计。)对于任何认为这个问题没有意义的人:是的,你可以改变压缩量/尝试压缩的传递次数;查看 Ifranview 或其中的一些插件。
Answer those questions, and then you might be able to find your original answer.
回答这些问题,然后您可能会找到原来的答案。

