Horje
decrease image size C# Code Example
decrease image size C#
public static void SaveJpeg (string path, Image img, int quality) 
{ 
    if (quality<0  ||  quality>100) 
        throw new ArgumentOutOfRangeException("quality must be between 0 and 100."); 

     // Encoder parameter for image quality 
     EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, quality); 
     // JPEG image codec 
     ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg"); 
     EncoderParameters encoderParams = new EncoderParameters(1); 
     encoderParams.Param[0] = qualityParam; 
     img.Save(path, jpegCodec, encoderParams); 
} 

/// <summary> 
/// Returns the image codec with the given mime type 
/// </summary> 
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; 
 } 




Csharp

Related
c# get list of all class fields Code Example c# get list of all class fields Code Example
how to disable click listener in android Code Example how to disable click listener in android Code Example
c# callback param Code Example c# callback param Code Example
stop displaying button in android Code Example stop displaying button in android Code Example
disable button in android studio Code Example disable button in android studio Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11