-1

Pls. suggest how to set an image's width & Height Property while saving Images

Jackson Pope
  • 14,225
  • 6
  • 53
  • 80
user633558
  • 15
  • 2
  • 3

1 Answers1

4

If you want to save bitmap with some specific width and height (which differ from the Width and Height properties of the bitmap), you need to create a new Bitmap of corresponding size and draw the initial bitmap in needed size on it.

Like this:

using (Bitmap bmpToSave = new Bitmap(1000, 500)) {
    using (Graphics g = Graphics.FromImage(bmpToSave)) {
        g.DrawImage(bmp, 0, 0, 1000, 500);
    }
    bmpToSave.Save(@"bitmap.bmp");
}

Where bmp is your original bitmap. Also, read up on some options that affect the quality of resampling if you need the high quality result.

Hans Passant
  • 897,808
  • 140
  • 1,634
  • 2,455
Dyppl
  • 11,795
  • 9
  • 45
  • 67