C#:寻求PNG的COM pression算法/库算法、PNG、COM、pression

由网友(凉城以北是无尾声的海。)分享简介:我要COM preSS或至少下降了一些用户上传到我的网站的PNG图像的质量。我已经调整,但不会对图像的大小做太多。求一个PNG /图像融为一体pression或质量损失算法或库.NET 4.0或以下。这就是我目前保存/转换我的图片:图片mainImg = ImageHelper.ResizeImage(BMP,600,...

我要COM preSS或至少下降了一些用户上传到我的网站的PNG图像的质量。我已经调整,但不会对图像的大小做太多。

求一个PNG /图像融为一体pression或质量损失算法或库.NET 4.0或以下。

这就是我目前保存/转换我的图片:

 图片mainImg = ImageHelper.ResizeImage(BMP,600,500,FALSE);
mainImg.Save(文件路径,System.Drawing.Imaging.ImageFormat.Png);
 

解决方案

不幸的是,.NET(和GDI +,它在.NET图形库的构建上)不支持任何编码参数PNG。事实上,如果你调用GetEn coderParameterList上的PNG图像连接codeR CLSID,位于你会得到一个未实现的异常。

更不幸的是,这两个和的imageformat图像codecInfo密封类,你不能只是增加新的codeCS什么.NET能够本地访问。微软放弃了球就这一个。

零基础如何自学C

这意味着你的替代品,按递减顺序受虐狂: 1)实现一个你自己保存功能在.NET中实现了RFC 2083, 2)实现基于关到.NET移植的libpng保存功能, 3)调用非托管code,它是直接了libpng建

的libpng有很大的文档,自由,无论是在可用性和许可纵容。

I need to compress or at least drop the quality of some png images that users are uploading to my site. I already resized it but that doesn't do much for the image size.

Seeking a png/image compression or quality loss algorithm or library for .net 4.0 or under.

This is how I currently save/convert my images:

Image mainImg = ImageHelper.ResizeImage(bmp, 600, 500, false);
mainImg.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);

解决方案

Unfortunately, .NET (and GDI+, which the .NET graphics libraries are built on) does not support any encoding parameters for PNG. In fact, if you call GetEncoderParameterList on your image with the PNG encoder Clsid, you'll get a "Not implemented" exception.

Even more unfortunate is that both ImageFormat and ImageCodecInfo are sealed classes and you can't just add new codecs to what .NET can natively access. Microsoft dropped the ball on this one.

This means your alternatives are, in decreasing order of masochism: 1) Implement a save function on your own in .NET that implements RFC 2083, 2) Implement a save function based off porting libpng to .NET, 3) Call unmanaged code that was built from libpng directly

libpng has great documentation and is free, both in availability and license permissiveness.

阅读全文

相关推荐

最新文章