【求助】picturebox放大效果的实现?
我在窗体上端有一系列图片的缩略图,当鼠标放在某个缩略图片上时,这个图片从窗体上端逐渐放大并显示在窗体中央。
private void pictureEdit1_Properties_MouseWheel(object sender, MouseEventArgs e) { Rectangle oldrct; Bitmap bmp; bmp = (Bitmap)this.pictureEdit1.Image; oldrct = new Rectangle(0, 0, bmp.Width, bmp.Height); this.pictureEdit1.Image = bmp; Bitmap tmpbmp = null; int i = e.Delta; if (i > 0) { tmpbmp = new Bitmap(bmp.Width * 2, bmp.Height * 2); } else { tmpbmp = new Bitmap(bmp.Width / 2, bmp.Height / 2); } Graphics g = Graphics.FromImage(tmpbmp); Rectangle newrct = new Rectangle(0, 0, tmpbmp.Width, tmpbmp.Height); g.DrawImage(bmp, newrct, oldrct, GraphicsUnit.Pixel);//newrct是你的目标矩形位置,oldrct是你原始图片的起始矩形位置 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; //oldrct = oldrct; pictureEdit1.Image = tmpbmp; g.Dispose(); pictureEdit1.Update(); }