private void tttttt(object oo) { try { threadobj tobj = (threadobj)oo; System.Drawing.Image img = new System.Drawing.Bitmap((tobj.MaxC - tobj.MinC + 1) * ElectronTransferModel.Config.MapConfig.Instance.PicWidth, (tobj.MaxR - tobj.MinR + 1) * ElectronTransferModel.Config.MapConfig.Instance.PicHeight); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img); g.Clear(System.Drawing.Color.White); System.Drawing.Image imgtemp; foreach (CYZTile ct in tobj.mTiles_back) { if (File.Exists(ct._ImageHLHUrl)) { imgtemp = System.Drawing.Image.FromFile(ct._ImageHLHUrl); g.DrawImage(imgtemp, (ct.TileCol - tobj.MinC) * ((int)ct.TileWidth), (ct.TileRow - tobj.MinR) * ((int)ct.TileHeight), (int)ct.TileWidth, (int)ct.TileHeight); imgtemp.Dispose(); } } //int txmin = (int)((ElectronTransferModel.Config.MapConfig.Instance.ProjectionMinX - tileMinX) / TileLevel.xResolution); //int txmax = (int)((ElectronTransferModel.Config.MapConfig.Instance.ProjectionMaxX - tileMinX) / TileLevel.xResolution); //int tymin = (int)(( tileMaxY- ElectronTransferModel.Config.MapConfig.Instance.ProjectionMinY ) / TileLevel.xResolution); //int tymax = (int)(( tileMaxY- ElectronTransferModel.Config.MapConfig.Instance.ProjectionMaxY ) / TileLevel.xResolution); //g.DrawPolygon(new System.Drawing.Pen(System.Drawing.Color.Red, 1.0f), // new System.Drawing.Point[] { // new System.Drawing.Point(txmin,tymin), // new System.Drawing.Point(txmax,tymin), // new System.Drawing.Point(txmax,tymax), // new System.Drawing.Point(txmin,tymax), // new System.Drawing.Point(txmin,tymin) // } // ); imgName = System.AppDomain.CurrentDomain.BaseDirectory + (imgIndex++).ToString() + "f**k.png"; img.Save(imgName, ImageFormat.Png); g.Dispose(); img.Dispose(); } catch (Exception ex) { } }
/** * @制作瓦片 */ private void create() { //左上角 double dx = SceenMapMinX - __cMapConfPtr.MapMinX; MinC = (int)Math.Floor(dx / (TileLevel.xResolution * TileLevel.PicWidth)); tileMinX = MinC * (TileLevel.xResolution * TileLevel.PicWidth) + __cMapConfPtr.MapMinX; double dy = __cMapConfPtr.MapMaxY - SceenMapMaxY; MinR = (int)Math.Floor(dy / (TileLevel.yResolution * TileLevel.PicHeight)); tileMaxY = __cMapConfPtr.MapMaxY - MinR * (TileLevel.yResolution * TileLevel.PicHeight); //右下角 dx = SceenMapMaxX - __cMapConfPtr.MapMinX; MaxC = (int)Math.Floor(dx / (TileLevel.xResolution * TileLevel.PicWidth)); tileMaxX = (MaxC + 1) * (TileLevel.xResolution * TileLevel.PicWidth) + __cMapConfPtr.MapMinX; dy = __cMapConfPtr.MapMaxY - SceenMapMinY; MaxR = (int)Math.Floor(dy / (TileLevel.yResolution * TileLevel.PicHeight)); tileMinY = __cMapConfPtr.MapMaxY - (MaxR + 1) * (TileLevel.yResolution * TileLevel.PicHeight); tilesWidth = (MaxC - MinC + 1) * TileLevel.PicWidth; tilesHeight = (MaxR - MinR + 1) * TileLevel.PicHeight; List <int> rows = new List <int>(); int rrmin = (MaxR + MinR) / 2; int rrmax = (MaxR + MinR) / 2 + 1; while (rrmin >= MinR || rrmax <= MaxR) { if (rrmin >= MinR) { rows.Add(rrmin); } rrmin--; if (rrmax <= MaxR) { rows.Add(rrmax); } rrmax++; } List <int> cols = new List <int>(); int ccmin = (MaxC + MinC) / 2; int ccmax = (MaxC + MinC) / 2 + 1; while (ccmin >= MinC || ccmax <= MaxC) { if (ccmin >= MinC) { cols.Add(ccmin); } ccmin--; if (ccmax <= MaxC) { cols.Add(ccmax); } ccmax++; } //foreach (CYZTile ct in mTiles_back) //{ // ct._RemoveTileFunc(); //} mTiles_back.Clear(); /* if(mTiles!=NULL) * { * iter=mTiles->begin(); * while(iter!=mTiles->end()) * { * if(iter->HideTileFunc!=NULL){ * iter->HideTileFunc(&(*iter)); * } * iter->_HideTileFunc(); * * iter++; * } * }*/ string str; for (int i = 0; i < rows.Count; i++) { for (int j = 0; j < cols.Count; j++) { CYZTile ctile = new CYZTile(); ctile.TileHeight = TileLevel.PicHeight; ctile.TileWidth = TileLevel.PicWidth; ctile.TileMinX = __cMapConfPtr.MapMinX + cols[j] * (TileLevel.xResolution * TileLevel.PicWidth); ctile.TileMaxX = __cMapConfPtr.MapMinX + (cols[j] + 1) * (TileLevel.xResolution * TileLevel.PicWidth); ctile.TileMaxY = __cMapConfPtr.MapMaxY - rows[i] * (TileLevel.yResolution * TileLevel.PicHeight); ctile.TileMinY = __cMapConfPtr.MapMaxY - (rows[i] + 1) * (TileLevel.yResolution * TileLevel.PicHeight); ctile.TileCol = cols[j]; ctile.TileRow = rows[i]; ctile.TileLevel = TileLevel.LevelID; ctile.xResolution = TileLevel.xResolution; ctile.yResolution = TileLevel.yResolution; ctile.basedir = __cMapConfPtr.BaseDir; ctile.getImageHLHUrl(); ctile.getImageName(); ctile.getImageWMSUrl(); if (File.Exists(ctile.getImageHLHUrl())) { mTiles_back.Add(ctile); } } } threadobj tobj = new threadobj(); tobj.MinC = MinC; tobj.MaxC = MaxC; tobj.MinR = MinR; tobj.MaxR = MaxR; tobj.mTiles_back = mTiles_back; tttttt(tobj); }