Example #1
0
        public override void Process(String compName, ResourcePack rp)
        {
            Int32 numTilesWide = (TargetBitmap.Width) / (Constants.TileSize);
              Int32 numTilesHigh = (TargetBitmap.Height) / (Constants.TileSize);

              Room r = new Room();
              r.Name = compName;

              Int32 numTilesAdded = 0;
              for (Int32 y = 0; y < numTilesHigh; y++)
              {
            for (Int32 x = 0; x < numTilesWide; x++)
            {
              Tile b = new Tile();

              Int32 tileX = x * (Constants.TileSize);
              Int32 tileY = y * (Constants.TileSize);

              b.SliceFromBitmap(TargetBitmap, tileX, tileY);
              b.Name = compName;

              if (rp.Add(b))
              {
            numTilesAdded++;
              }

              r.SetTile(x, y, b);
            }
              }

              rp.Add(r);
        }
Example #2
0
        public override void Process(String compName, ResourcePack rp)
        {
            Int32 gapX = (Int32)gapInX.Value;
              Int32 gapY = (Int32)gapInY.Value;

              Bitmap edgedBitmap = new Bitmap(TargetBitmap, TargetBitmap.Width + Constants.TileSize, TargetBitmap.Height + Constants.TileSize);
              using (Graphics edgeGfx = Graphics.FromImage(edgedBitmap))
              {
            edgeGfx.Clear(colourSwatch.BackColor);

            edgeGfx.InterpolationMode = InterpolationMode.NearestNeighbor;
            edgeGfx.DrawImage(TargetBitmap, new Rectangle(0, 0, TargetBitmap.Width, TargetBitmap.Height), 0, 0, TargetBitmap.Width, TargetBitmap.Height, GraphicsUnit.Pixel);
              }

              Int32 curX = 0, curY = 0;
              while (curY < TargetBitmap.Height)
              {
            while (curX < TargetBitmap.Width)
            {
              Tile b = new Tile();

              b.SliceFromBitmap(edgedBitmap, curX, curY);
              b.Name = compName;

              rp.Add(b);

              curX += Constants.TileSize + gapX;
            }

            curX = 0;
            curY += Constants.TileSize + gapY;
              }
        }