简体   繁体   中英

How to Zoom a Drawn Image in PictureBox

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...

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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM