暂未加载到内存中处理,猜测不是这个原因,已开双缓冲DoubleBuffered = true;panel是自定义的usercontrol;测试1000*1000范围内,浏览拖动图像无卡顿,千位像素级别以上越大卡顿越明显,原因大致清楚:每次移动时都是针对该图片偏移量移动,所以图片越大移动越困难,想保持图片不动,移动图片时相对移动panel相对图片的坐标来浏览图像,只是猜测,求指点,小弟新人一个,第一次发帖,如有不对请指出!
附代码:- public Pic_Position_Move()
- {
- InitializeComponent();
- }
- Point offset = new Point(0, 0);
- Point p;
- Bitmap fileBitmap;
- private void btnLoad_Click(object sender, EventArgs e)
- {
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- fileBitmap = new Bitmap(openFileDialog1.FileName);
- offset = new Point(0, 0);
- panShow.Invalidate();
- }
- }
-
- private void panShow_Paint(object sender, PaintEventArgs e)
- {
- if (fileBitmap != null)
- e.Graphics.DrawImage(fileBitmap, offset);
- }
-
- private void panShow_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left && fileBitmap != null)
- {
- offset.Offset(e.X - p.X, e.Y - p.Y);
- p = e.Location;
- panShow.Invalidate();
- }
- }
- private void panShow_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left && fileBitmap != null)
- {
- panShow.Cursor = Cursors.Hand;
- p = e.Location;
- panShow.Invalidate();
- }
- }
-
- private void panShow_MouseUp(object sender, MouseEventArgs e)
- {
- panShow.Cursor = Cursors.Default;
- panShow.Invalidate();
- }
复制代码 |