Resize Bitmap

  • Thread starter Thread starter Christian Stelte
  • Start date Start date
Create a new bitmap object of a required size. Create graphics object on it.
Then use DrawImage overload that allows to specify source and target size.

Bitmap newBitmap = new Bitmap(newSize.X, newSizeY);
Graphics g = Graphics.FromImage(newBitmap);
g.DrawImage(oldBitmap, new Rectangle(0, 0, newBitmap.Width,
newBitmap.Height), new Rectangle(0, 0, oldBitmap.Width, oldBitmap.Height),
GraphicsUnit.Pixel);
 
I couldn't use the bitmap class, not sure if this is
anything like you need but in windows generated code

'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject
("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(80, 88)
Dim bmpHigh As Integer =
PictureBox1.ClientSize.Height.ToString(30)
Dim bmpWid As Integer =
PictureBox1.ClientSize.Width.ToString(90)
Me.PictureBox1.Size = New System.Drawing.Size(bmpWid,
bmpHigh)
 
Alex Feinman said:
Create a new bitmap object of a required size. Create graphics object on it.
Then use DrawImage overload that allows to specify source and target size.

That's it!
Thank you!

Chris
 
Back
Top