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)
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.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.