Пример #1
0
        public void SetPalette(Palette pal) {
            this.pal = pal;
            SelectedFG = 1;
            SelectedBG = 0;
            PalSize = pal.pal.Length;
            rows = (PalSize + 15) / 16;
            Height = rows * 12 + 26;

            if (PalBuffer == null) {
                PalBuffer = new Bitmap(16 * 12 + 2, rows * 12 + 2);
            }

            Graphics g = Graphics.FromImage(PalBuffer);

            g.Clear(Color.Black);

            for (int i = 0; i < pal.pal.Length; i++)
            {
                int x = 2 + (i % 16) * 12;
                int y = 2 + (i / 16) * 12;
                g.FillRectangle(new SolidBrush(pal.pal[i]), x, y, 10, 10);
            }

            drawingBox.Invalidate();
        }
Пример #2
0
        public void addPalette(Palette p)
        {
            if (standalone)
                p.beginEdit();

            paletteListBox.Items.Add(p);
            if (paletteListBox.Items.Count == 1)
                paletteListBox.SelectedItem = p;
        }
Пример #3
0
 public override void replaceWithPal(Bitmap b, Palette p)
 {
     for (int x = 0; x < getWidth(); x++)
         for (int y = 0; y < getHeight(); y++)
         {
             Color c = b.GetPixel(x, y);
             int i = p.getClosestColor(c);
             setPixel(x, y, i);
         }
 }
Пример #4
0
        public override Bitmap render(Palette p)
        {
            int w = getWidth();
            int h = getHeight();

            Bitmap b = new Bitmap(w, h);
            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++)
                    b.SetPixel(x, y, p.getColorSafe(getPixel(x, y)));

            return b;
        }
Пример #5
0
        public Tilemap(File f, int tileWidth, Image2D i, Palette[] pals, int tileOffset, int paletteOffset)
        {
            this.f = f;
            this.width = tileWidth;
            this.tileOffset = tileOffset;
            this.paletteOffset = paletteOffset;

            this.tileset = i;
            this.palettes = pals;
            this.tileCount = tileset.getWidth() * tileset.getHeight() / 64;

            load();
        }
Пример #6
0
        public override Bitmap render(Palette p)
        {
            if (color0 == true)
            {
                p.pal[0] = Color.Transparent;
            }
            int w = getWidth();
            int h = getHeight();

            Bitmap b = new Bitmap(w, h);
            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++)
                    b.SetPixel(x, y, p.getColorSafe(getPixel(x, y)));

            return b;
        }
Пример #7
0
        public override Bitmap render(Palette p)
        {
            int w = getWidth();
            int h = getHeight();

            Bitmap b = new Bitmap(w, h);

            ByteArrayInputStream f5data = new ByteArrayInputStream(f5.getContents());
            ByteArrayInputStream data = new ByteArrayInputStream(f.getContents());

            for (uint y = 0; y < h/4; y++)
                for (uint x = 0; x < w/4; x++)
                {
                    ushort palDat = f5data.readUShort();
                    ushort palOffs = (ushort)((palDat & 0x3FFF) * 2);
                    ushort mode = (ushort)((palDat >> 14) & 3);

                    for (uint yy = 0; yy < 4; yy++)
                    {
                        byte row = data.readByte();
                        for (uint xx = 0; xx < 4; xx++)
                        {
                            byte color = (byte)(row >> (byte)(xx * 2));
                            color &= 3;
                            Color col;
                            col = p.getColorSafe(palOffs + color);
                            switch (mode)
                            {
                                case 0:
                                    if (color == 3) col = Color.Transparent;
                                    break;
                                case 1:
                                    if (color == 2) col = ImageTiler.colorMean(p.getColorSafe(palOffs), p.getColorSafe(palOffs + 1), 1, 1);
                                    if (color == 3) col = Color.Transparent;
                                    break;
                                case 3:
                                    if (color == 2) col = ImageTiler.colorMean(p.getColorSafe(palOffs), p.getColorSafe(palOffs + 1), 5, 3);
                                    if (color == 3) col = ImageTiler.colorMean(p.getColorSafe(palOffs), p.getColorSafe(palOffs + 1), 3, 5);
                                    break;
                            }
                            b.SetPixel((int)x * 4 + (int)xx, (int)y * 4 + (int)yy, col);
                        }
                    }
                } 
            return b;
        }
Пример #8
0
        private void setImageAndPalette(PalettedImage i, Palette p)
        {
            if (!(i is PalettedImage)) return;
            if (i == null || p == null) return;

//            Console.WriteLine(i + " " + p);

            graphicsEditor1.setPalette(p);
            graphicsEditor1.setImage(i as PalettedImage);

            tileWidthNumber.Enabled = i is Image2D;
            tileOffsetNumber.Enabled = i is Image2D;
            fourBppCheckBox.Enabled = i is Image2D;

            if (i is Image2D)
            {
                tileWidthNumber.Value = (i as Image2D).width / 8;
                tileOffsetNumber.Value = (i as Image2D).tileOffset;
                fourBppCheckBox.Checked = (i as Image2D).is4bpp;
            }
        }
Пример #9
0
 public override void replaceWithPal(Bitmap b, Palette p)
 {
     throw new InvalidOperationException("Not allowed on these image types!");
 }
Пример #10
0
 public abstract void replaceWithPal(Bitmap b, Palette p);
Пример #11
0
 public abstract void replaceImgAndPal(Bitmap b, Palette p);
Пример #12
0
 public abstract Bitmap render(Palette p);
Пример #13
0
        public override void replaceImgAndPal(Bitmap b, Palette p)
        {
            ImageTexeler it = new ImageTexeler(b, (int)p.pal.Length / 4);
            f.replace(it.texdata, this);
            f5.replace(it.f5data, this);

            p.pal = it.finalPalette;
            p.save();
        }
Пример #14
0
 public abstract void replaceWithPal(Bitmap b, Palette p);
Пример #15
0
 public void setPalette(Palette pal)
 {
     this.pal = pal;
     palettePicker1.SetPalette(pal);
     RenderBuffer();
     RenderZoomCache();
     drawingBox.Invalidate();
 }
Пример #16
0
 public abstract void replaceImgAndPal(Bitmap b, Palette p);
Пример #17
0
 public Map16Tilemap(File f, int tileWidth, Image2D i, Palette[] pals, int a, int b) :
     base(f, tileWidth, i, pals, a, b)
 { }
Пример #18
0
 public override void replaceImgAndPal(Bitmap b, Palette p)
 {
     p.pal = ImageIndexer.createPaletteForImage(b, p.pal.Length);
     replaceWithPal(b, p);
 }
Пример #19
0
        public override Bitmap render(Palette p)
        {
            int w = getWidth();
            int h = getHeight();

            Bitmap b = new Bitmap(w, h);

            ByteArrayInputStream f5data = new ByteArrayInputStream(f5.getContents());
            ByteArrayInputStream data   = new ByteArrayInputStream(f.getContents());

            for (uint y = 0; y < h / 4; y++)
            {
                for (uint x = 0; x < w / 4; x++)
                {
                    ushort palDat  = f5data.readUShort();
                    ushort palOffs = (ushort)((palDat & 0x3FFF) * 2);
                    ushort mode    = (ushort)((palDat >> 14) & 3);

                    for (uint yy = 0; yy < 4; yy++)
                    {
                        byte row = data.readByte();
                        for (uint xx = 0; xx < 4; xx++)
                        {
                            byte color = (byte)(row >> (byte)(xx * 2));
                            color &= 3;
                            Color col;
                            col = p.getColorSafe(palOffs + color);
                            switch (mode)
                            {
                            case 0:
                                if (color == 3)
                                {
                                    col = Color.Transparent;
                                }
                                break;

                            case 1:
                                if (color == 2)
                                {
                                    col = ImageTiler.colorMean(p.getColorSafe(palOffs), p.getColorSafe(palOffs + 1), 1, 1);
                                }
                                if (color == 3)
                                {
                                    col = Color.Transparent;
                                }
                                break;

                            case 3:
                                if (color == 2)
                                {
                                    col = ImageTiler.colorMean(p.getColorSafe(palOffs), p.getColorSafe(palOffs + 1), 5, 3);
                                }
                                if (color == 3)
                                {
                                    col = ImageTiler.colorMean(p.getColorSafe(palOffs), p.getColorSafe(palOffs + 1), 3, 5);
                                }
                                break;
                            }
                            b.SetPixel((int)x * 4 + (int)xx, (int)y * 4 + (int)yy, col);
                        }
                    }
                }
            }
            return(b);
        }
Пример #20
0
 public override void replaceWithPal(Bitmap b, Palette p)
 {
     throw new InvalidOperationException("Not allowed on these image types!");
 }
Пример #21
0
 public override void replaceImgAndPal(Bitmap b, Palette p)
 {
     p.pal = ImageIndexer.createPaletteForImage(b, p.pal.Length);
     replaceWithPal(b, p);
 }
Пример #22
0
 public abstract Bitmap render(Palette p);