private void WriteTitleToLZ(string filename, int id) { DrawString2(storyList.Stories[id].Title); Graphics g3 = Graphics.FromImage(title_output); for (int i = 0; i < 7; i++) { var sRect = new Rectangle(i * 32, 0, 32, 16); var dRect = new Rectangle(0, i * 16, 32, 16); g3.DrawImage(title, dRect, sRect, GraphicsUnit.Pixel); } Color[] palette = new Color[16]; int palIndex = 14; LoadPalFile("obj.pal"); for (int j = 0; j < palette.Length; j++) { palette[j] = PALfilePalette[j + 16 * palIndex]; } byte[] raw = GBAGraphics.ToGBARaw(title_output, palette, GraphicsMode.Tile4bit); byte[] lzcomped = LZ77.Compress(raw); File.WriteAllBytes(filename, lzcomped); }
private void Form1_Load(object sender, EventArgs e) { ROM = new GBAROM(); ROM.OpenROM("..\\..\\rom\\input.gba"); GrayScalePalette = new Color[0x100]; WhiteToBlackPalette = new Color[0x100]; for (int x = 0; x < 0x10; x++) { for (int y = 0; y < 0x10; y++) { int value = x * 0x10 + y; int value2 = ((0x10 - x) * 0x10 + (0x10 - y)) & 0xFF; GrayScalePalette[x + y * 0x10] = Color.FromArgb(value, value, value); WhiteToBlackPalette[x + y * 0x10] = Color.FromArgb(value2, value2, value2); } } storyList.Load("story.xml"); UpdateListBox(); int empty; Color[] palette = new Color[16]; int palIndex = 14; LoadPalFile("obj.pal"); for (int j = 0; j < palette.Length; j++) { palette[j] = PALfilePalette[j + 16 * palIndex]; } rawGraphics = ROM.GetData(0x37CBCC, 0x8000); palette[0] = Color.Transparent; palette[3] = palette[6]; font2 = GBAGraphics.ToBitmap(rawGraphics, rawGraphics.Length, 0, palette, 16, GraphicsMode.Tile4bit, out empty); palIndex = 15; LoadPalFile("bg.pal"); for (int j = 0; j < palette.Length; j++) { palette[j] = PALfilePalette[j + 16 * palIndex]; } palette[0] = Color.Transparent; font = GBAGraphics.ToBitmap(rawGraphics, rawGraphics.Length, 0, palette, 16, GraphicsMode.Tile4bit, out empty); widthTable = File.ReadAllBytes("widthTable.bin"); title = new Bitmap(256, 16); title_output = new Bitmap(32, 112); CreateGraphics(); }
public void LoadRawPalFile(int offset) { byte[] rawPal = ROM.GetData(offset, 0x1FF); PALfilePalette = new Color[0x100]; Color[] temp = GBAGraphics.toPalette(rawPal, 0, 0x100); temp.CopyTo(PALfilePalette, 0x00); for (int i = 0; i < 0x100; i += 16) { PALfilePalette[i] = Color.Transparent; } }
private void button3_Click(object sender, EventArgs e) { Color[] palette = new Color[16]; int palIndex = 14; LoadPalFile("obj.pal"); for (int j = 0; j < palette.Length; j++) { palette[j] = PALfilePalette[j + 16 * palIndex]; } byte[] raw = GBAGraphics.ToGBARaw(title_output, palette, GraphicsMode.Tile4bit); File.WriteAllBytes("test.bin", raw); }