public void Draw(Bitmap bmp) { BackgroundGraphics gfx = (BackgroundGraphics) Parent.GetObject(typeof(BackgroundGraphics), GraphicsIndex); BackgroundPalette pal = (BackgroundPalette) Parent.GetObject(typeof(BackgroundPalette), PaletteIndex); gfx.Draw(bmp, pal); }
public void Draw(Graphics g) { BackgroundGraphics gfx = (BackgroundGraphics) Parent.GetObject(typeof(BackgroundGraphics), GraphicsIndex); BackgroundPalette pal = (BackgroundPalette) Parent.GetObject(typeof(BackgroundPalette), PaletteIndex); Bitmap bmp = new Bitmap(256, 256, PixelFormat.Format24bppRgb); gfx.Draw(bmp, pal); g.DrawImage(bmp, 0, 0); }
// This handler deals with background graphics and palettes as well, // even though those are technically separate "objects" public override void ReadClass(Rom rom) { // The only way to determine the bit depth of each BG palette is // to check the bit depth of the backgrounds that use it - so, // first we create an array to track palette bit depths: int[] palbits = new int[114]; int[] gfxbits = new int[103]; for (int i = 0; i < 327; i++) { BattleBG bg = new BattleBG(); rom.Add(bg); bg.Read(i); // Now that the BG has been read, update the BPP entry for its palette // We can also check to make sure palettes are used consistently: int pal = bg.PaletteIndex; if (palbits[pal] != 0 && palbits[pal] != bg.BitsPerPixel) { throw new Exception("Battle BG Palette Error - inconsistent bit depth"); } palbits[pal] = bg.BitsPerPixel; gfxbits[bg.GraphicsIndex] = bg.BitsPerPixel; } // Now load palettes for (int i = 0; i < 114; i++) { BackgroundPalette p = new BackgroundPalette(); rom.Add(p); p.BitsPerPixel = palbits[i]; p.Read(i); } // Load graphics for (int i = 0; i < 103; i++) { BackgroundGraphics g = new BackgroundGraphics(); rom.Add(g); g.BitsPerPixel = gfxbits[i]; g.Read(i); } }