Resize the bitmap to a certain dimension or area. This resizes the drawing area rather than any content that already exists there. If the width or height increases then new blank space will be uncovered at the right and bottom respectively. If they decrease then space at the right and bottom will be removed.
Syntax

[C#]

void Resize(int width, int height);
void Resize(Size size);

[Visual Basic]

Sub Resize(width As Integer, height As Integer)
Sub Resize(size As Size)
Params
Name Description
width The width of the bitmap in pixels, origin fixed at zero.
height The height of the bitmap in pixels, origin fixed at zero.
size The size of the bitmap in pixels, origin fixed at zero.
Notes

None.

Example

[C#]

using (Bitmap bm = new Bitmap(300, 300)) {
  Graphics graphics = Graphics.FromImage(bm);
  RectangleF rect = bm.Bounds;
  rect.Inflate(-30, -30);
  graphics.FillRectangle(Brushes.Red, rect);
  bm.Save(Server.MapPath("IG8_Bitmap_Resize1.jpg"));
  bm.Resize(bm.Width + 150, bm.Height + 300);
  bm.Save(Server.MapPath("IG8_Bitmap_Resize2.jpg"));
  bm.SetResolution(36, 36);
  bm.Save(Server.MapPath("IG8_Bitmap_Resize3.jpg"));
}


Here we show how to resize and change the resolution of an existing Bitmap. Note that the resize exposes new area on the Bitmap but that changing resolution does not affect the size.


IG8_Bitmap_Resize1.jpg


IG8_Bitmap_Resize2.jpg


IG8_Bitmap_Resize3.jpg