internal override void SetXml(XmlNamespaceManager nsm, XmlNode node)
        {
            if (_xml == null)
            {
                InitXml(nsm, node, "");
            }
            CheckTypeChange(NodeName);
            _xml.SetXmlNodeBool("@rotWithShape", RotateWithShape);
            if (TileFlip == eTileFlipMode.None)
            {
                _xml.DeleteNode("@flip");
            }
            else
            {
                _xml.SetXmlNodeString("@flip", TileFlip.ToString().ToLower());
            }

            if (ShadePath == eShadePath.Linear && LinearSettings.Angel != 0 && LinearSettings.Scaled == false)
            {
                _xml.SetXmlNodeAngel("a:lin/@ang", LinearSettings.Angel);
                _xml.SetXmlNodeBool("a:lin/@scaled", LinearSettings.Scaled);
            }
            else if (ShadePath != eShadePath.Linear)
            {
                _xml.SetXmlNodeString("a:path/@path", GetPathString(ShadePath));
                _xml.SetXmlNodePercentage("a:path/a:fillToRect/@b", FocusPoint.BottomOffset, true, int.MaxValue / 10000);
                _xml.SetXmlNodePercentage("a:path/a:fillToRect/@t", FocusPoint.TopOffset, true, int.MaxValue / 10000);
                _xml.SetXmlNodePercentage("a:path/a:fillToRect/@l", FocusPoint.LeftOffset, true, int.MaxValue / 10000);
                _xml.SetXmlNodePercentage("a:path/a:fillToRect/@r", FocusPoint.RightOffset, true, int.MaxValue / 10000);
            }
        }
Esempio n. 2
0
 public ChrTile(
     int tileIndex,
     int paletteIndex,
     LayerPriority layerPriority,
     TileFlip tileFlip)
 {
     value  = (ushort)(tileIndex & TileIndexMask);
     Value |= (paletteIndex & PaletteMask) << PaletteOffset;
     Value |= ((int)layerPriority & PriorityMask) << PriorityOffset;
     Value |= ((int)tileFlip & FlipMask) << FlipOffset;
 }
        public static Bitmap GetBitmapFrom2bppPlanar(byte[] gfx, Palettes palettes, Tile2bppProperties properties)
        {
            // Each tile is made up of 8x8 pixels, coded on 16 bytes (2 bits per pixel)

            Palette    palette     = palettes[properties.PaletteIndex];
            int        subPalIndex = properties.SubPaletteIndex;
            TileFlip   flip        = properties.Flip;
            Bitmap     bitmap      = new Bitmap(Tile.Size, Tile.Size, PixelFormat.Format32bppPArgb);
            FastBitmap fBitmap     = new FastBitmap(bitmap);

            for (int y = 0; y < Tile.Size; y++)
            {
                byte val1 = gfx[y * 2];
                byte val2 = gfx[y * 2 + 1];
                for (int x = 0; x < Tile.Size; x++)
                {
                    int mask       = 1 << x;
                    int colorIndex = ((val1 & mask) >> x) + (((val2 & mask) >> x) << 1);

                    if (colorIndex > 0) // If pixel is not transparent
                    {
                        int xPos = (flip & TileFlip.X) != 0 ?
                                   x : (Tile.Size - 1) - x;

                        int yPos = (flip & TileFlip.Y) == 0 ?
                                   y : (Tile.Size - 1) - y;

                        Color color = palette[subPalIndex + colorIndex];

                        fBitmap.SetPixel(xPos, yPos, color);
                    }
                }
            }

            fBitmap.Release();
            return(bitmap);
        }
Esempio n. 4
0
        public static void Convert(ref uint globalId, out TileFlip flip)
        {
            flip = (TileFlip)((globalId & FLIIPED) >> 29);

            globalId &= ~FLIIPED;
        }