我想用c#中的鼠标滚轮放大或缩小图片框上的图像。我该怎么办?
This topic helps to zoom in and out picture in picturebox
add below code inside the picturebox mouse wheel event
if (e.Delta != 0) {
if (e.Delta <= 0) {
//set minimum size to zoom
if (PictureBox1.Width < 50)
return;
} else {
//set maximum size to zoom
if (PictureBox1.Width > 500)
return;
}
PictureBox1.Width += Convert.ToInt32(PictureBox1.Width * e.Delta / 1000);
PictureBox1.Height += Convert.ToInt32(PictureBox1.Height * e.Delta / 1000);
}
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.