简体   繁体   English

在.Net中生成高压缩率图像

[英]Generate high compression ratio image in .Net

Here is my code: 这是我的代码:

using (Graphics graph = Graphics.FromImage(destImg))
{
     graph.InterpolationMode = InterpolationMode.HighQualityBicubic;
     graph.SmoothingMode = SmoothingMode.HighQuality;

     Rectangle srcRect = new Rectangle(0, 0, srcWidth, srcHeight);
     Rectangle destRect = new Rectangle(0, 0, destWidth, destHeight);

     graph.DrawImage(srcImg, destRect, srcRect, GraphicsUnit.Pixel);

     srcImg.Dispose();
}

It can generate a 210k image(360*270 pixel) from a 550k image(1024*768 pixel). 它可以从550k图像(1024 * 768像素)生成210k图像(360 * 270像素)。

However ,I can generate a 20k image in photoshop. 但是,我可以在photoshop中生成20k图像。 Certainly, it seen some sort of blurring. 当然,它看起来有些模糊。 But you know that I'm living in China, many of my customers are being tormented with 0.5M bandwidth now. 但是您知道我住在中国,现在我的许多客户都受到50万带宽的折磨。 They will not like a 210k image, it's too huge! 他们不会喜欢210k的图像,它太大了!

So, how can I do to generate high compression ratio image in .Net? 那么,如何在.Net中生成高压缩率图像?

I think I would switch to JPEG and lessen the quality. 我想我会改用JPEG并降低画质。 That generates pretty small filesizes. 生成的文件大小很小。

Here is an example of how to do that in C# 这是如何在C#中执行此操作的示例

http://www.geekpedia.com/tutorial232_Reducing-JPEG-Picture-Quality-using-Csharp.html http://www.geekpedia.com/tutorial232_Reducing-JPEG-Picture-Quality-using-Csharp.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM