Beispiel #1
0
 /// <summary>
 /// 打开切片文件并保存切片
 /// </summary>
 /// <param name="bm"></param>
 private void ToImg(BundleModel bm)
 {
     byte[] BundlxData = null;
     byte[] BundleData = null;
     using (FileStream file = new FileStream(bm.BundlxDire, FileMode.Open))
     {
         byte[] bufferfile = new byte[file.Length];
         file.Read(bufferfile, 0, (int)file.Length);
         //写入数据
         BundlxData = bufferfile;
     }
     using (FileStream file = new FileStream(bm.BundleDire, FileMode.Open))
     {
         byte[] bufferfile = new byte[file.Length];
         file.Read(bufferfile, 0, (int)file.Length);
         //写入数据
         BundleData = bufferfile;
     }
     for (int x = 0; x < 128; x++)
     {
         for (int y = 0; y < 128; y++)
         {
             int index = 128 * x + y;
             GetTile(bm.StartX + x, bm.StartY + y, bm.Level, index, BundlxData, BundleData);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 获取某一切片等级下的文件对象
        /// </summary>
        /// <param name="level"></param>
        /// <param name="xy">【x1,y1,x2,y2】</param>
        /// <returns></returns>
        private List <BundleModel> GetLevelBundle(int level, int[] xy)
        {
            List <BundleModel> bundleModelList = new List <BundleModel>();
            int minx   = ((xy[0] + 1) / 128) * 128;
            int maxx   = ((xy[1] + 1) / 128) * 128;
            int miny   = ((xy[2] + 1) / 128) * 128;
            int maxy   = ((xy[3] + 1) / 128) * 128;
            int xcount = (maxx - minx) / 128 + 1;
            int ycount = (maxy - miny) / 128 + 1;

            for (int x = 0; x < xcount; x++)
            {
                for (int y = 0; y < ycount; y++)
                {
                    BundleModel bm = new BundleModel();
                    bm.StartX = minx + (x) * 128;
                    bm.StartY = miny + (y) * 128;
                    var rGroup     = Convert.ToInt32(128 * Convert.ToInt32(bm.StartX / 128));
                    var cGroup     = Convert.ToInt32(128 * Convert.ToInt32(bm.StartY / 128));
                    var bundleBase = getBundlePath(textBox1.Text, level, rGroup, cGroup);
                    bm.Level      = level;
                    bm.BundlxDire = bundleBase + ".bundlx";
                    bm.BundleDire = bundleBase + ".bundle";
                    bm.BundleName = Path.GetFileNameWithoutExtension(bm.BundleDire);
                    bundleModelList.Add(bm);
                }
            }
            return(bundleModelList);
        }