C#实现类似淘宝图片局部放大功能源码
pb_dqtp原图
pictureBox1局部放大的图片
public System.Drawing.Point movepoint = new System.Drawing.Point();
public bool ismove = false;
Pen pen = new Pen(Color.FromArgb(91, 98, 114));
HatchBrush brush = new HatchBrush(HatchStyle.Cross, Color.FromArgb(91, 98, 114),
Color.Empty);
//选?取¨?区?域®¨°的Ì?大䨮小?
const int rect_W = 80;
const int rect_H = 60;
//网ª?格?边À?长¡è:êo5px 一°?格?
const int gridSize = 2;
//网ª?格?的Ì?行D、¡é列¢D数ºy
int rowGridCount = rect_H / gridSize;
int columnGridCount = rect_W / gridSize;
private void pb_dqtp_MouseMove(object sender, MouseEventArgs e)
{
GC.Collect();
movepoint.X = e.X;
movepoint.Y = e.Y;
}
private void pb_dqtp_MouseLeave(object sender, EventArgs e)
{
GC.Collect();
pictureBox1.Visible = false;
pb_dqtp.Refresh();
pictureBox1.Width = 200;
pictureBox1.Height = 150;
}
private void pb_dqtp_Click(object sender, EventArgs e)
{
GC.Collect();
pb_dqtp.Focus();
ismove = true;
pb_dqtp.Refresh();
}
private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
{
GC.Collect();
double scale = 1;
if (pictureBox1.Height > 0)
{
scale = (double)pictureBox1.Width / (double)pictureBox1.Height;
}
pictureBox1.Width += (int)(e.Delta * scale);
pictureBox1.Height += e.Delta;
评论0