Exemplo n.º 1
0
        public void DrawSwatch(Graphics g, int nIndex)
        {
            Subpalette sp = m_palette.GetCurrentSubpalette();

            Font f = new Font("Arial Black", 10);

            // TODO: query fontmetrics and center text in box
            int[] nLabelXOffset = new int[16] {
                6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6
            };

            int pxX0 = 1;
            int pxY0 = 1;

            g.FillRectangle(sp.Brush(nIndex), pxX0, pxY0, k_pxSwatchSize, k_pxSwatchSize);

            // Draw the transparent color (index 0) using a pattern.
            if (nIndex == 0)
            {
                g.FillRectangle(m_brushTransparent, pxX0, pxY0, k_pxSwatchSize, k_pxSwatchSize);
            }

            // Draw the palette index in each swatch.
            if (Options.Sprite_ShowPaletteIndex)
            {
                int pxLabelOffsetX = nLabelXOffset[nIndex];
                int pxLabelOffsetY = 2;
                g.DrawString(sp.Label(nIndex), f, sp.LabelBrush(nIndex), pxX0 + pxLabelOffsetX, pxY0 + pxLabelOffsetY);
            }

            // Draw a border around each color swatch.
            g.DrawRectangle(Pens.White, pxX0, pxY0, k_pxSwatchSize, k_pxSwatchSize);

            g.DrawRectangle(Pens.Black, 0, 0, 2 + k_pxSwatchSize, 2 + k_pxSwatchSize);
        }
Exemplo n.º 2
0
        private void pbPalette_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.FillRectangle(Brushes.Black, 0, 0, 1000, 1000);

            Font f = new Font("Arial Black", 10);

            int[] nXOffset = new int[16] {
                6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6
            };

            for (int iColumn = 0; iColumn < k_nSwatches; iColumn++)
            {
                int nIndex = iColumn;

                int pxX0 = 1 + iColumn * k_pxSwatchSize;
                int pxY0 = 1;

                g.FillRectangle(m_subpalette.Brush(nIndex), pxX0, pxY0, k_pxSwatchSize, k_pxSwatchSize);

                // Draw the transparent color (index 0) using a pattern.
                if (nIndex == 0)
                {
                    g.FillRectangle(m_brushTransparent, pxX0, pxY0, k_pxSwatchSize, k_pxSwatchSize);
                }

                // Draw the palette index in each swatch.
                if (Options.Sprite_ShowPaletteIndex)
                {
                    int pxLabelOffsetX = nXOffset[nIndex];
                    int pxLabelOffsetY = 2;
                    g.DrawString(m_subpalette.Label(nIndex), f, m_subpalette.LabelBrush(nIndex), pxX0 + pxLabelOffsetX, pxY0 + pxLabelOffsetY);
                }

                // Draw a border around each color swatch.
                g.DrawRectangle(Pens.White, pxX0, pxY0, k_pxSwatchSize, k_pxSwatchSize);
            }

            g.DrawRectangle(Pens.Black, 0, 0, 2 + k_nSwatches * k_pxSwatchSize, 2 + k_pxSwatchSize);

            // Hilight the currently selected color.
            g.DrawRectangle(m_penHilight, (m_subpalette.CurrentColor * k_pxSwatchSize) + 1, 1, k_pxSwatchSize, k_pxSwatchSize);
        }
Exemplo n.º 3
0
        public void DrawTile(Graphics g, Tile t, int pxOriginX, int pxOriginY)
        {
            // create a new bitmap
            int pxSize = BigBitmapPixelSize;
            //int pxInset = pxSize / 4;
            Subpalette sp = m_sprite.Subpalette;

            Font f;

            int[] nXOffset;
            int   nYOffset;

            if (pxSize == 16)
            {
                f        = new Font("Arial", 9);
                nXOffset = new int[16] {
                    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3
                };
                nYOffset = 1;
            }
            else
            {
                f        = new Font("Arial Black", 10);
                nXOffset = new int[16] {
                    10, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 10
                };
                nYOffset = 6;
            }

            g.FillRectangle(Brushes.White, pxOriginX, pxOriginY, Tile.TileSize * pxSize, Tile.TileSize * pxSize);
            for (int iRow = 0; iRow < Tile.TileSize; iRow++)
            {
                for (int iColumn = 0; iColumn < Tile.TileSize; iColumn++)
                {
                    int nPaletteIndex = t.GetPixel(iColumn, iRow);

                    int pxX0 = pxOriginX + (iColumn * pxSize);
                    int pxY0 = pxOriginY + (iRow * pxSize);
                    g.FillRectangle(sp.Brush(nPaletteIndex), pxX0, pxY0, pxSize, pxSize);

                    // Draw the transparent color (index 0) using a pattern.
                    if (nPaletteIndex == 0 && BigBitmapPixelSize >= 8)
                    {
                        g.FillRectangle(m_brushTransparent, pxX0, pxY0, pxSize, pxSize);
                    }

                    if (Options.Sprite_ShowPaletteIndex && pxSize >= 16)
                    {
                        // Draw the palette index in each pixel.
                        int pxLabelOffsetX = nXOffset[nPaletteIndex];
                        int pxLabelOffsetY = nYOffset;
                        g.DrawString(sp.Label(nPaletteIndex), f, sp.LabelBrush(nPaletteIndex), pxX0 + pxLabelOffsetX, pxY0 + pxLabelOffsetY);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void pbCurrent_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.FillRectangle(Brushes.Black, 0, 0, 1000, 1000);

            g.FillRectangle(m_subpalette.Brush(), 1, 1, k_pxSwatchSize, k_pxSwatchSize);

            // Draw a border around each color swatch.
            g.DrawRectangle(Pens.White, 1, 1, k_pxSwatchSize, k_pxSwatchSize);
        }
Exemplo n.º 5
0
        public static void DrawPalette(Graphics g, Subpalette sp)
        {
            Font f = new Font("Arial Black", 10);

            // TODO: query fontmetrics and center text in box
            int[] nLabelXOffset = new int[16] {
                6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6
            };

            int nRows    = k_nPaletteRows;
            int nColumns = k_nPaletteColumns;
            int pxSize   = k_pxColorSize;

            for (int iRow = 0; iRow < nRows; iRow++)
            {
                for (int iColumn = 0; iColumn < nColumns; iColumn++)
                {
                    int nIndex = iRow * nColumns + iColumn;

                    int pxX0 = 1 + iColumn * pxSize;
                    int pxY0 = 1 + iRow * pxSize;

                    g.FillRectangle(sp.Brush(nIndex), pxX0, pxY0, pxSize, pxSize);

                    // Draw the transparent color (index 0) using a pattern.
                    if (nIndex == 0)
                    {
                        g.FillRectangle(m_brushTransparent, pxX0, pxY0, pxSize, pxSize);
                    }

                    // Draw the palette index in each swatch.
                    if (Options.Sprite_ShowPaletteIndex)
                    {
                        int pxLabelOffsetX = nLabelXOffset[nIndex];
                        int pxLabelOffsetY = 2;
                        g.DrawString(sp.Label(nIndex), f, sp.LabelBrush(nIndex), pxX0 + pxLabelOffsetX, pxY0 + pxLabelOffsetY);
                    }

                    // Draw a border around each color swatch.
                    g.DrawRectangle(Pens.White, pxX0, pxY0, pxSize, pxSize);
                }
            }

            g.DrawRectangle(Pens.Black, 0, 0, 2 + nColumns * pxSize, 2 + nRows * pxSize);

            // Hilight the currently selected color.
            int x = (sp.CurrentColor % nColumns) * pxSize;
            int y = (sp.CurrentColor / nColumns) * pxSize;

            g.DrawRectangle(m_penHilight, x + 1, y + 1, pxSize, pxSize);
        }
Exemplo n.º 6
0
        // create a bitmap from this tile data
        private Bitmap CreateBitmap(int pxSize)
        {
            // create a new bitmap
            Bitmap     bm = new Bitmap(TileSize * pxSize, TileSize * pxSize);        //, PixelFormat.Format32bppArgb);
            Graphics   g  = Graphics.FromImage(bm);
            Subpalette sp = m_sprite.Subpalette;

            g.FillRectangle(Brushes.White, 0, 0, TileSize * pxSize, TileSize * pxSize);
            for (int iRow = 0; iRow < TileSize; iRow++)
            {
                for (int iColumn = 0; iColumn < TileSize; iColumn++)
                {
                    g.FillRectangle(sp.Brush(GetPixel(iColumn, iRow)), iColumn * pxSize, iRow * pxSize, pxSize, pxSize);
                }
            }

            return(bm);
        }
Exemplo n.º 7
0
        public static void DrawPalette(Graphics g, Subpalette sp)
        {
            Font f = new Font("Arial Black", 10);

            // TODO: query fontmetrics and center text in box
            int[] nLabelXOffset = new int[16] { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6 };

            int nRows = k_nPaletteRows;
            int nColumns = k_nPaletteColumns;
            int pxSize = k_pxColorSize;

            for (int iRow = 0; iRow < nRows; iRow++)
            {
                for (int iColumn = 0; iColumn < nColumns; iColumn++)
                {
                    int nIndex = iRow * nColumns + iColumn;

                    int pxX0 = 1 + iColumn * pxSize;
                    int pxY0 = 1 + iRow * pxSize;

                    g.FillRectangle(sp.Brush(nIndex), pxX0, pxY0, pxSize, pxSize);

                    // Draw the transparent color (index 0) using a pattern.
                    if (nIndex == 0)
                        g.FillRectangle(m_brushTransparent, pxX0, pxY0, pxSize, pxSize);

                    // Draw the palette index in each swatch.
                    if (Options.Sprite_ShowPaletteIndex)
                    {
                        int pxLabelOffsetX = nLabelXOffset[nIndex];
                        int pxLabelOffsetY = 2;
                        g.DrawString(sp.Label(nIndex), f, sp.LabelBrush(nIndex), pxX0 + pxLabelOffsetX, pxY0 + pxLabelOffsetY);
                    }

                    // Draw a border around each color swatch.
                    g.DrawRectangle(Pens.White, pxX0, pxY0, pxSize, pxSize);
                }
            }

            g.DrawRectangle(Pens.Black, 0, 0, 2 + nColumns * pxSize, 2 + nRows * pxSize);

            // Hilight the currently selected color.
            int x = (sp.CurrentColor % nColumns) * pxSize;
            int y = (sp.CurrentColor / nColumns) * pxSize;
            g.DrawRectangle(m_penHilight, x + 1, y + 1, pxSize, pxSize);
        }