public static Sprite LoadChaotixSprite(byte[] file, int addr) { short left = ByteConverter.ToInt16(file, addr); addr += 2; short right = ByteConverter.ToInt16(file, addr); addr += 2; sbyte top = (sbyte)file[addr]; addr += 2; sbyte bottom = (sbyte)file[addr]; addr += 2; BitmapBits bmp = new BitmapBits(right - left + 1, bottom - top + 1); sbyte y; while (true) { sbyte xl = (sbyte)file[addr++]; sbyte xr = (sbyte)file[addr++]; if (xl == xr) { break; } y = (sbyte)file[addr]; addr += 2; Array.Copy(file, addr, bmp.Bits, bmp.GetPixelIndex(xl - left, y - top), xr - xl); addr += xr - xl; } return(new Sprite(bmp, new Point(left, top))); }