Reputation: 856
Hey everyone, a new guy here in C#.Net.
What I need is to zoom an image drawn using gdi+ to pictureBox.
I searched but couldn't find a nice answer, all I found was for existing files. Does anyone has an idea?
Thanks for the answers.
My best Regards...
Upvotes: 0
Views: 1495
Reputation: 2434
Use Transforms and Matrix objects as described here. The example of scaling is given as
private void Scale_Click(object sender,
System.EventArgs e)
{
// Create Graphics object
Graphics g = this.CreateGraphics();
g.Clear(this.BackColor);
// Draw a filled rectangle with
// width 20 and height 30
g.FillRectangle(Brushes.Blue,
20, 20, 20, 30);
// Create Matrix object
Matrix X = new Matrix();
// Apply 3X scaling
X.Scale(3, 4, MatrixOrder.Append);
// Apply transformation on the form
g.Transform = X;
// Draw a filled rectangle with
// width 20 and height 30
g.FillRectangle(Brushes.Blue,
20, 20, 20, 30);
// Dispose of object
g.Dispose();
}
Upvotes: 1