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(); }
public void addPalette(Palette p) { if (standalone) p.beginEdit(); paletteListBox.Items.Add(p); if (paletteListBox.Items.Count == 1) paletteListBox.SelectedItem = p; }
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); } }
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; }
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(); }
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; }
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; }
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; } }
public override void replaceWithPal(Bitmap b, Palette p) { throw new InvalidOperationException("Not allowed on these image types!"); }
public abstract void replaceWithPal(Bitmap b, Palette p);
public abstract void replaceImgAndPal(Bitmap b, Palette p);
public abstract Bitmap render(Palette p);
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(); }
public void setPalette(Palette pal) { this.pal = pal; palettePicker1.SetPalette(pal); RenderBuffer(); RenderZoomCache(); drawingBox.Invalidate(); }
public Map16Tilemap(File f, int tileWidth, Image2D i, Palette[] pals, int a, int b) : base(f, tileWidth, i, pals, a, b) { }
public override void replaceImgAndPal(Bitmap b, Palette p) { p.pal = ImageIndexer.createPaletteForImage(b, p.pal.Length); replaceWithPal(b, p); }
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); }