本文介绍了如何解压缩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中的图像?
发布评论