How to zoom an image in&out in C#?

前端 未结 2 1471
悲&欢浪女
悲&欢浪女 2020-12-03 03:12

I want to implement zoom for an image. I don\'t want to resize the PictureBox, but the image itself.

How do I do this?

2条回答
  •  失恋的感觉
    2020-12-03 04:11

    I used a web browser to achieve this.

    //loads the image
    myWebBrowser.Navigate(@"C:\myimage.png");
    

    From there I used SendKeys to zoom in and out

    myWebBrowser.Select(); //Selects browser.
    SendKeys.Send("^{+}"); //Sends the control + key combo, causing the browser to zoom in. Replace the "+" with a "-" to zoom out.
    

    It's a bit of a weird method, but it worked really well for me. I hope you find this helpful!

提交回复
热议问题