-
-
-
-
-
- public void ystp(string filePath, string filePath_ystp)
- {
-
- Bitmap bmp = null;
- ImageCodecInfo ici = null;
-
- Encoder ecd = null;
-
- EncoderParameter ept = null;
-
- EncoderParameters eptS = null;
- try
- {
- bmp = new Bitmap(filePath);
- ici = this.getImageCoderInfo("image/jpeg");
- ecd = Encoder.Quality;
- eptS = new EncoderParameters(1);
- ept = new EncoderParameter(ecd, 10L);
- eptS.Param[0] = ept;
- bmp.Save(filePath_ystp, ici, eptS);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- finally
- {
- bmp.Dispose();
- ept.Dispose();
- eptS.Dispose();
- }
- }
-
-
-
-
-
- private ImageCodecInfo getImageCoderInfo(string coderType)
- {
- ImageCodecInfo[] iciS = ImageCodecInfo.GetImageEncoders();
- ImageCodecInfo retIci = null;
- foreach (ImageCodecInfo ici in iciS)
- {
- if (ici.MimeType.Equals(coderType))
- retIci = ici;
- }
- return retIci;
- }
- #endregion 压缩图片
|