c# bitmap压缩
2021-03-02 12:27
标签:ali == 设置 路径 ima ++ bmp sys code 只需要传入Bitmap和路径,别的不需要修改.80L代表保存质量,还可以设置50L,25L,质量更差。 c# bitmap压缩 标签:ali == 设置 路径 ima ++ bmp sys code 原文地址:https://www.cnblogs.com/sclu/p/13049455.html 1 public static ImageCodecInfo GetEncoderInfo(String mimeType)
2
3 {
4 int j;
5 ImageCodecInfo[] encoders;
6 encoders = ImageCodecInfo.GetImageEncoders();
7 for (j = 0; j j)
8 {
9 if (encoders[j].MimeType == mimeType)
10 return encoders[j];
11 }
12 return null;
13 }
14 public static void savePath(Bitmap bmp, string str)//保存路径
15 {
16 ImageCodecInfo myImageCodecInfo;
17 System.Drawing.Imaging.Encoder myEncoder;
18 EncoderParameter myEncoderParameter;
19 EncoderParameters myEncoderParameters;
20
21 myImageCodecInfo = GetEncoderInfo("image/jpeg");
22 myEncoder = System.Drawing.Imaging.Encoder.Quality;
23 myEncoderParameters = new EncoderParameters(1);
24 myEncoderParameter = new EncoderParameter(myEncoder, 80L);
25 myEncoderParameters.Param[0] = myEncoderParameter;
26 bmp.Save(str, myImageCodecInfo, myEncoderParameters);
27 }