Search results for 'Resizing Image'. 1 post(s) found.

  1. 2009/09/03 How to resize and save PNG or Jpeg Image file ?
2009/09/03 09:51

How to resize and save PNG or Jpeg Image file ?


I tried to change image file with PictureBox control. Following is the example to convert image size.

private void copy_to_resized_png(string tar, string src, int w, int h)
{
  Image imgInput = Image.FromFile(src);
  Bitmap bitmapResized = new Bitmap( imgInput, w, h);

  // in case that you need to save as jpeg format
  // just change
  // ImageFormat.Png to ImageFormat.Jpeg
  bitmapResized.Save(tar, ImageFormat.Bmp);

  imgInput.Dispose();
  bitmapResized.Dispose();
}

You can call above function as following:
copy_to_resized_png( "c:\\tmp2_mask1.png", "c:\\widget_104_mask2_v2.png", w, h);


Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.