Ejemplo n.º 1
0
        public override void Process(String compName, ResourcePack rp)
        {
            const Int32 MidPoint = (Constants.RoomSize * Constants.TileSize) / 2;
              Point assembleAtPoint;

              Bitmap edgedBitmap = new Bitmap(TargetBitmap, TargetBitmap.Width + Constants.TileSize, TargetBitmap.Height + Constants.TileSize);
              edgedBitmap.MakeTransparent();

              using (Graphics edgeGfx = Graphics.FromImage(edgedBitmap))
              {
            edgeGfx.Clear(Color.Transparent);

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

              foreach (ExtractedObject eo in ObjectExtents)
              {
            StateObject ob = new StateObject();
            ob.Name = compName;

            if (alignToCenter.Checked)
              assembleAtPoint = new Point(MidPoint - eo.bounds.Width / 2, MidPoint - eo.bounds.Height / 2);
            else
              assembleAtPoint = new Point(0, 0);

            foreach (Rectangle r in eo.slices)
            {
              Sprite b = new Sprite();

              b.SliceFromBitmap(edgedBitmap, r.Left, r.Top, 128);
              b.Name = compName;

              rp.Add(b);
              ob.AddSprite(b, assembleAtPoint.X + (r.Left - eo.bounds.Left), assembleAtPoint.Y + (r.Top - eo.bounds.Top), 1.0f, false);
            }

            rp.Add(ob);
              }
        }
Ejemplo n.º 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);
              if (bgTrans.Checked)
            edgedBitmap.MakeTransparent();

              using (Graphics edgeGfx = Graphics.FromImage(edgedBitmap))
              {
            if (bgTrans.Checked)
              edgeGfx.Clear(Color.Transparent);
            else
              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)
            {
              Sprite b = new Sprite();

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

              rp.Add(b);

              curX += Constants.TileSize + gapX;
            }

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