Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resize Bitmap

0 views
Skip to first unread message

Christian Stelte

unread,
Nov 24, 2003, 9:31:18 AM11/24/03
to
Hi!

Any idea how I resize a Bitmap in the Bitmap-Class at runtime?

Chris


Alex Feinman [MVP]

unread,
Nov 24, 2003, 11:31:51 AM11/24/03
to
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);

"Christian Stelte" <cstelte(at)sytec-net.de> wrote in message
news:ertlQeps...@TK2MSFTNGP09.phx.gbl...

marcmc

unread,
Nov 24, 2003, 11:39:43 AM11/24/03
to
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)

Christian Stelte

unread,
Nov 25, 2003, 5:55:29 AM11/25/03
to

"Alex Feinman [MVP]" <publi...@alexfeinman.com> schrieb

> 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


0 new messages