0
這是用繪製一個矩形在pictureBox1代碼IM:如何使用鼠標滾輪放大繪製的矩形區域進行縮放?
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();
}
}
如何使我對以後的drawed長方形當我移動鼠標滾輪向上或向下將調整對所繪製的矩形區域在pictureBox1中的圖像? 不調整所有圖像的大小,但僅對矩形繪製區域進行放大/縮小。