|
Use GDI+ to draw a 2000-pixel-wide picture in the panel control on the form. When dragging the scroll bar, the picture is not drawn completely. It seems to be drawn slowly, and the image cannot be scrolled smoothly. Drag which direction to which direction There is a small area between the picture and the edge of the form that cannot be drawn. When the drag is fast, the area between the picture and the edge of the form will be large, and the area of the picture will be small if the picture is slow. , It seems to have something to do with the speed of dragging the scroll bar. I tried NNNN times, and after thinking of many ways, it is still the same! There is really no way! Is it the efficiency of GDI+? Shouldn't it drawing a picture will have this problem? I think there should be something wrong with my code, the code is as follows, forgot to say, my form is a subform
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MapEdit
{
public partial class newMap: Form
{
private Image im;//Image object
private Graphics g;
private Graphics g1;
private Bitmap curBitmap;
public newMap(int MapW,int MapH,int TitleW,int TitleH)
{
InitializeComponent();
}
private void newMap_Load(object sender, EventArgs e)
{
im = Image.FromFile("image.gif");
panel1.Width = im.Width;
panel1.Height = im.Height;
g = this.panel1.CreateGraphics();
g.Clear(Color.Black);
curBitmap = new Bitmap(im.Width, im.Height);
g1 = Graphics.FromImage(curBitmap);
g1.DrawImage(im, 0, 0, im.Width, im.Height);
}
private void newMap_Paint(object sender, PaintEventArgs e)
{
g.DrawImage(curBitmap, 0, 0);
}
}
} |
|