如何使用鼠标滚轮在绘制的矩形区域上放大缩小?(How do i make zoom in zoom out with the mouse wheel over a drawn rectangle area? [closed])
这个代码我用来在pictureBox1上绘制一个矩形:
private void DrawRectangle(Graphics e) { using (Pen pen = new Pen(Color.Red, 2)) { e.DrawRectangle(pen, mRect); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mRect = new Rectangle(e.X, e.Y, 0, 0); pictureBox1.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mRect = new Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top); pictureBox1.Invalidate(); } }当我向上或向下移动鼠标滚轮时,我如何绘制矩形后,它将调整pictureBox1中iamge上绘制的矩形区域的大小? 不调整所有图像的大小,但仅对矩形绘制区域进行放大/缩小。
This the code im using to draw a rectangle over a pictureBox1:
private void DrawRectangle(Graphics e) { using (Pen pen = new Pen(Color.Red, 2)) { e.DrawRectangle(pen, mRect); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mRect = new Rectangle(e.X, e.Y, 0, 0); pictureBox1.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mRect = new Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top); pictureBox1.Invalidate(); } }How do i make that after i drawed a rectangle when i move the mouse wheel up or down it will resize the drawn rectangle area on the iamge in the pictureBox1 ? Not resize all the image but make zoom in/out only for the rectangle drawn area.
最满意答案
熟悉MouseWheel事件。
Get familiar with the MouseWheel event.
更多推荐
发布评论