如何解压缩WPF中的图像?

编程入门 行业动态 更新时间:2024-10-27 21:23:56
本文介绍了如何解压缩WPF中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用以下代码压缩了图像.现在我不知道如何解压缩它.请帮助.

i have an compressed image using the below code. now i dont know how to decompress it.pls help..

void compress(Image img,string path){ EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60); ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg"); EncoderParameters encoderParams = new EncoderParameters(1); encoderParams.Param[0] = qualityParam; img.Save("check1.jpg", jpegCodec, encoderParams); } private static ImageCodecInfo GetEncoderInfo(string mimeType) { // Get image codecs for all image formats ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); // Find the correct image codec for (int i = 0; i < codecs.Length; i++) if (codecs[i].MimeType == mimeType) return codecs[i]; return null; }

推荐答案

您不能这样做.特别是对于JEPG,要减小其尺寸,要做的就是从图像中删除尽可能多的不可见信息(减少颜色渐变,像素等的数量). 可以将它想象成允许冰块融化以减小其尺寸,因为就象图像一样,该冰块也不能像原来那样被重构. 因此,您可以调整所需大小,并添加任意数量的颜色,但不能神奇地重新创建原始文件. 图片压缩和音频压缩与用于暂时减小某些文件大小的文件压缩不同,就像使用Zip文件一样. -frank you can''t do that. especially with JEPGs as what they do to reduce their size is to remove as much invisible information from the image as possible, (reduce the amount of color gradients, pixels, and the like). Think of it as allowing an ice-cube to melt to reduce it in size, for as with the image the ice-cube can''t be reconstituted into as it was. So you can re-size all you want, and add number of colors as much as you like, but you can''t magically re-create the original file. Picture compression and audio compression isn''t the same as file-compression used to reduce the size temporarily of something, like one does with Zip-files. -frank

更多推荐

如何解压缩WPF中的图像?

本文发布于:2023-10-30 01:17:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解压缩   图像   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!