Save images by specified quality

Source: Internet
Author: User

Jpgimages are directly produced in the program. The quality is inferior to that of the source Image because of Microsoft Image. the Save method is saved to the image compression quality of 75, so the quality of the saved image is low, to improve the quality of the generated image, you must set the quality parameters of the EncoderParameters class and the image storage format of the ImageCodecInfo class.

 

System. drawing. imaging. the Encoder class is used to specify the mode and parameters to be presented, such as slice quality parameters, scan method parameters, color table parameters, compression parameters, and color depth. at this point, you should understand the steps and methods for modifying the image quality. mainly for System. drawing. imaging. encoder settings, and then use System. drawing. imaging. encoder constructs the EncoderParameter class and passes the EncoderParameter to the EncoderParameters array to get an image that fits your needs! The code is actually very simple:

 

First introduce: using System. Drawing. Imaging;

 

SaveImageForSpecifiedQuality (System. drawing. image sourceImage, savePath, EncoderParameters encoderParameters =] === (I =; I <ImageCodecInfoArray. length; I ++ (ImageCodecInfoArray [I]. formatDescription. equals (= View Code

Call method:

System. Drawing. Image image = System. Drawing. Image. FromFile (, ImageFormat. Jpeg );
Image. Dispose ();

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.