System.Drawing.Bitmap.SetResolution C# (CSharp) Method

SetResolution() public method

public SetResolution ( float xDpi, float yDpi ) : void
xDpi float
yDpi float
return void
        public void SetResolution(float xDpi, float yDpi)
        {
            throw new NotImplementedException ();
        }

Usage Example

Example #1
14
 // This is to resize an image file biased to the width of the image
 public void ResizeImageProportionate_XInclination(Stream File_Stream, int Target_Width, string Save_Path)
 {
     try
     {
         // This to extract the image from the file stream without uploading
         System.Drawing.Image _image = System.Drawing.Image.FromStream(File_Stream);
         int Image_Width = _image.Width;
         int Image_Height = _image.Height;
         int target_width = Target_Width;
         int target_height = (Target_Width * Image_Height) / Image_Width;
         // This is to create a new image from the file stream to a specified height and width
         Bitmap _bitmap = new Bitmap(target_width, target_height, _image.PixelFormat);
         _bitmap.SetResolution(72, 72);
         // This is to resize the image to the target height and target width
         Graphics _graphics = Graphics.FromImage(_bitmap);
         _graphics.DrawImage(_image, new Rectangle(0, 0, target_width, target_height),
            new Rectangle(0, 0, Image_Width, Image_Height), GraphicsUnit.Pixel);
         // This is to save the image file into the save path
         _bitmap.Save(Save_Path, _image.RawFormat);
         _image.Dispose();
         _graphics.Dispose();
         _bitmap.Dispose();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
All Usage Examples Of System.Drawing.Bitmap::SetResolution