C# 开发手机地图地图移动闪屏
最近公司要求我用C#开发手机地图,现在地图出来了(地图由很多小图片拼接而成)
当我需要移动地图时就需要重新找坐标拼接地图,这样出来的效果感觉就像闪屏一样,
各位大虾能给解决方案?
这个是我拼接小图组合成地图的方法。
然后在窗体MouseMove事件中调用该方法,参数是:this.CreateGraphics();
谁能给个较好的解决方案解决这个闪动的问题,我只有这么多分了。
public void RenderNew(Graphics g) { g = _g; //Graphics g = new Graphics(); //左上角图片的最大最小经纬度 List<Image> images = new List<Image>(); colE = col; rowE = row; double pcurxMin = wxMin + ((double)col) * dx; double pcurxMax = wxMin + ((double)(col + 1)) * dx; double pcuryMin = wyMax - ((double)(row + 1)) * dy; double pcuryMax = wyMax - ((double)row) * dy; //图片左上角的框架位置 int px, py; px = 0 - (int)(((double)pw) * (xMin - pcurxMin) / (pcurxMax - pcurxMin));//列 py = 0 - (int)(((double)ph) * (pcuryMax - yMax) / (pcuryMax - pcuryMin));//行 #region #endregion for (int i = 0; i < wcount; i++) { //行 for (int j = 0; j < hcount; j++) { //列 //根据层数,行列号获取图片。 StringBuilder url = new StringBuilder("http://192.168.0.203/m_fsgisImg/L"); //StringBuilder localPath = new StringBuilder(@"\Program Files\TestOnMobile\demo\m_fsgis\data\m_fsgisImg\L"); StringBuilder localPath = new StringBuilder("\\data\\m_fsgisImg\\L"); char[] hexc =new char[100]; //第一次append PublicFun.tohex(curlevel,ref hexc, 2); localPath.Append(hexc); localPath.Append("\\R"); url.Append(hexc); url.Append("/R"); //第二次append row + i PublicFun.tohex(row + i, ref hexc, 8); localPath.Append(hexc); url.Append(hexc);//url.Append(hexc); StringBuilder fileName = localPath; fileName.Append("\\C"); url.Append("/C"); //第三次append PublicFun.tohex(col + j, ref hexc, 8); fileName.Append(hexc); fileName.Append(".png"); url.Append(hexc); url.Append(".png"); //Directory.GetCurrentDirectory(); ImageManager imgr = new ImageManager(); imgr.setUrl(url.ToString()); //imgr.setFileName(imgr.getLocalPath() + fileName); imgr.setFileName("image\\demo\\m_fsgis" + fileName); String fname = imgr.getFileName(); try { Bitmap image1 = new Bitmap(fname); images.Add(image1); //MemoryStream m = new MemoryStream(image1.GetHbitmap()); //Bitmap map = Graphics.FromImage(image1); G.DrawImage(images[images.Count-1], px + pw * j, py + ph * i); } catch (Exception ee) { ee.ToString(); } } } if (g != null) { g.Dispose(); g = null; } //return g; }