示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InitializeGlobal();
            Size size = JsonMapper.ToObject <Size>(File.ReadAllText(@"images\typeIcon.json"));

            treeView1.ImageList           = new ImageList();
            treeView1.ImageList.ImageSize = new Size(18, 25);
            Image[] images = MyGraphics.SplitImage(Image.FromFile(@"images\typeIcon.bmp"), size);
            foreach (Image img in images)
            {
                treeView1.ImageList.Images.Add(img);
            }
        }
示例#2
0
        private void button15_Click(object sender, EventArgs e)
        {
            int minX = 0, minZ = 0, maxX = 0, maxZ = 0;

            foreach (RegionFile eachRegionFile in region)
            {
                minX = eachRegionFile.regionX < minX ? eachRegionFile.regionX : minX;
                minZ = eachRegionFile.regionZ < minZ ? eachRegionFile.regionZ : minZ;
                maxX = eachRegionFile.regionX > maxX ? eachRegionFile.regionX : maxX;
                maxZ = eachRegionFile.regionZ > maxZ ? eachRegionFile.regionZ : maxZ;
            }
            chunkpic = new Bitmap((maxX - minX + 1) * 512, (maxZ - minZ + 1) * 512);
            foreach (RegionFile eachRegionFile in region)
            {
                chunkpic = (Bitmap)MyGraphics.CombineBitmap(eachRegionFile.GetBiomeImage(), chunkpic, (eachRegionFile.regionX - minX) * 512, (eachRegionFile.regionZ - minZ) * 512);
            }
            pictureBox1.BackgroundImage = chunkpic;
        }
示例#3
0
        public Image GetMap(int y)
        {
            Image respic = new Bitmap(16 * 32, 16 * 32);
            Image pic    = new Bitmap(16, 16);

            for (int x = 0; x < 32; x++)
            {
                for (int z = 0; z < 32; z++)
                {
                    if (chunks[x, z] != null)
                    {
                        pic    = chunks[x, z].GetMap(y);
                        respic = MyGraphics.CombineBitmap(pic, respic, x * 16, z * 16);
                    }
                }
            }
            return(respic);
        }
示例#4
0
        public Image GetBiomeImage()
        {
            object regionBiomes;
            Bitmap pic = new Bitmap(16 * 32, 16 * 32);
            int    i = 0;
            int    currentBiome = -1;
            int    chunkX = 0, chunkZ = 0;

            int[]  regionBiomesValueInt  = { };
            byte[] regionBiomesValueByte = { };
            foreach (RegionFile_Chunk chunk in chunksData)
            {
                regionBiomes = chunk.tag.FindTagByName("Level").FindTagByName("Biomes").GetValue();
                if (regionBiomes is int[])
                {
                    regionBiomesValueInt = (int[])regionBiomes;
                }
                else if (regionBiomes is byte[])
                {
                    regionBiomesValueByte = (byte[])regionBiomes;
                }
                else
                {
                    throw new Exception("Unknown biomes type.");
                }
                i      = 0;
                chunkX = (int)chunk.tag.FindTagByName("Level").FindTagByName("xPos").GetValue() - regionX * 32;
                chunkZ = (int)chunk.tag.FindTagByName("Level").FindTagByName("zPos").GetValue() - regionZ * 32;
                Bitmap chunkpic = new Bitmap(16, 16);
                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        if (regionBiomes is int[])
                        {
                            if (regionBiomesValueInt.Length == 256)
                            {
                                currentBiome = regionBiomesValueInt[i];
                                Color tmpcolor = JsonUtil.GetBiomeById(currentBiome).GetColor();
                                chunkpic.SetPixel(x, y, JsonUtil.GetBiomeById(currentBiome).GetColor());
                            }
                        }
                        else if (regionBiomes is byte[])
                        {
                            if (regionBiomesValueByte.Length == 256)
                            {
                                currentBiome = regionBiomesValueByte[i];
                                Color tmpcolor = JsonUtil.GetBiomeById(currentBiome).GetColor();
                                chunkpic.SetPixel(x, y, JsonUtil.GetBiomeById(currentBiome).GetColor());
                            }
                        }
                        else
                        {
                            throw new Exception("Unknown biomes type.");
                        }

                        i++;
                    }
                }
                pic = (Bitmap)MyGraphics.CombineBitmap(chunkpic, pic, chunkX * 16, chunkZ * 16);
            }
            return(pic);
        }