public void UpdateTile(Theme theme, byte tileId, byte properties) { Tile2bpp tileModel = theme.Background.Tileset[tileId]; this.tile.Dispose(); this.tile = new BackgroundTile(tileModel.Graphics, tileModel.Palettes, properties, this.Front); int width = this.Width; int height = this.Height; if (this.BorderStyle == BorderStyle.Fixed3D) { width -= SystemInformation.Border3DSize.Width * 2; height -= SystemInformation.Border3DSize.Height * 2; } Bitmap zoomedBitmap = new Bitmap(width, height, PixelFormat.Format32bppPArgb); using (Graphics g = Graphics.FromImage(zoomedBitmap)) { g.PixelOffsetMode = PixelOffsetMode.Half; g.InterpolationMode = InterpolationMode.NearestNeighbor; g.Clear(theme.BackColor); g.DrawImage(this.tile.Bitmap, 0, 0, width, height); } this.image.Dispose(); this.image = zoomedBitmap; this.Refresh(); }
private void TestGetColorIndexAt(byte[] gfx, byte[] palData, byte properties) { Palettes palettes = new Palettes(palData); Tile2bpp tile = new Tile2bpp(gfx, palettes, properties); Palette palette = new Palette(null, 0, palData); TileTests.TestGetColorIndexAt(tile, palette, false); }
public BackgroundTilePanel() { // Initializing fields to avoid null checks before disposing if (Context.Game != null) // Avoid designer issues { Tile2bpp tile = Context.Game.Themes[0].Background.Tileset[0]; this.tile = new BackgroundTile(tile.Graphics, null); } this.image = new Bitmap(1, 1, PixelFormat.Format32bppPArgb); }
private static Tile[] GetTiles(byte[] romBuffer, int offset, byte[] itemGfx) { byte tileIndex = (byte)(romBuffer[offset] & 0x7F); byte properties = romBuffer[offset + 1]; Tile[] tiles = new Tile2bpp[4]; for (int i = 0; i < tiles.Length; i++) { tiles[i] = ItemIconGraphics.GetTile((byte)(tileIndex + i), properties, itemGfx); } return(tiles); }
private void TestGenerateGraphics(byte[] palData, byte[] gfx, Tile2bppProperties properties) { byte[] palsData = new byte[512]; Buffer.BlockCopy(palData, 0, palsData, 0, palData.Length); Palettes pals = new Palettes(palsData); byte props = properties.GetByte(); Tile2bpp tile = new Tile2bpp(gfx, pals, props); Tile2bpp tile2 = new Tile2bpp(new byte[gfx.Length], pals, props); tile2.Bitmap = tile.Bitmap; // Trigger graphics update Assert.AreEqual(gfx, tile2.Graphics); }
public ItemIconGraphics(byte[] romBuffer, Offsets offsets) { byte[] itemGfx = Codec.Decompress(romBuffer, offsets[Offset.ItemIconGraphics]); int itemCount = Enum.GetValues(typeof(ItemType)).Length; int startOffset = offsets[Offset.ItemIconTileLayout]; this.tiles = new Tile2bpp[itemCount][]; for (int i = 0; i < itemCount; i++) { int offset = startOffset + i * 2; this.tiles[i] = ItemIconGraphics.GetTiles(romBuffer, offset, itemGfx); } int topBorderOffset = offsets[Offset.TopBorderTileLayout]; byte tileIndex = (byte)(romBuffer[topBorderOffset] & 0x7F); byte properties = romBuffer[topBorderOffset + 1]; this.topBorder = ItemIconGraphics.GetTile(tileIndex, properties, itemGfx); }