BitArray LoadAlienSprite(int alien) { string filename = $"Invaders.jooyetech_icon_0{alien}_invader.bmp"; byte[] inv = BitmapLoader.LoadBMPResource(filename); Console.WriteLine($"{alien} has {inv.Length} bytes"); //bmp start at lower left //flip vertically - and flip the bits in the byte ~ // also reverse the bits for little endian ? byte[] flipinv = new byte[inv.Length]; for (int r = 39; r > 0; r--) { for (int i = 0; i < 8; i++) { flipinv[r * 8 + i] = Reverse((byte)~inv[(39 - r) * 8 + i]); } } // assume all are same size for now int[] d = BitmapLoader.LoadDimensions(filename); spriteW = d[0]; spriteH = d[1]; return(new BitArray(flipinv)); }
void InvaderTest(int alien) { byte[] inv = BitmapLoader.LoadBMPResource($"Invaders.jooyetech_icon_0{alien}_invader.bmp"); Console.WriteLine($"{inv.Length} bytes"); //bmp start at lower left //flip vertically - and flip the bits in the byte ~ // also reverse the bits for little endian ? byte[] flipinv = new byte[inv.Length]; for (int r = 39; r > 0; r--) { for (int i = 0; i < 8; i++) { flipinv[r * 8 + i] = Reverse((byte)~inv[(39 - r) * 8 + i]); } } graphics.Clear(); for (int x = 0; x < display.Width; x += 64) { for (int y = 0; y < display.Height; y += 40) { //display.DrawBitmap(x, y, 64 / 8, 40, flipinv, RandColor()); DrawBitmap(x, y, 64, 40, flipinv, RandColor()); // Console.WriteLine($"{x} {y}"); graphics.Show(); } } }