//----------------------------------------------------------------- // BITMAP FILE FORMAT // 0 'B','M' // 2 uint count = 4 bytes // 6 Bitmap type : // 0 = int record list // 1 = uint bitmap // 2 = rec# indexes // 7 '0' // 8 uint data //----------------------------------------------------------------- private long SaveBitmapToFile(WAHBitArray bmp) { long off = _lastBitmapOffset; WAHBitArray.TYPE t; uint[] bits = bmp.GetCompressed(out t); byte[] b = new byte[bits.Length * 4 + 8]; // write header data b[0] = ((byte)'B'); b[1] = ((byte)'M'); Buffer.BlockCopy(Helper.GetBytes(bits.Length, false), 0, b, 2, 4); b[6] = (byte)t; b[7] = (byte)(0); for (int i = 0; i < bits.Length; i++) { byte[] u = Helper.GetBytes((int)bits[i], false); Buffer.BlockCopy(u, 0, b, i * 4 + 8, 4); } _bitmapFileWrite.Write(b, 0, b.Length); _lastBitmapOffset += b.Length; return(off); }
private void WriteFile() { WAHBitArray.TYPE t; uint[] ints = _bits.GetCompressed(out t); MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write((byte)t);// write new format with the data type byte foreach (var i in ints) { bw.Write(i); } File.WriteAllBytes(_path + _filename, ms.ToArray()); }
private void WriteFreeListBMPFile(string filename) { if (_freeList != null) { WAHBitArray.TYPE t; uint[] ints = _freeList.GetCompressed(out t); MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write((byte)t);// write new format with the data type byte foreach (var i in ints) { bw.Write(i); } File.WriteAllBytes(filename, ms.ToArray()); } }
//----------------------------------------------------------------- // BITMAP FILE FORMAT // 0 'B','M' // 2 uint count = 4 bytes // 6 Bitmap type : // 0 = int record list // 1 = uint bitmap // 2 = rec# indexes // 7 '0' // 8 uint data //----------------------------------------------------------------- private long SaveBitmapToFile(WAHBitArray bmp) { long off = _lastBitmapOffset; WAHBitArray.TYPE t; uint[] bits = bmp.GetCompressed(out t); byte[] b = new byte[bits.Length * 4 + 8]; // write header data b[0] = ((byte)'B'); b[1] = ((byte)'M'); Buffer.BlockCopy(Helper.GetBytes(bits.Length, false), 0, b, 2, 4); b[6] = (byte)t; b[7] = (byte)(0); for (int i = 0; i < bits.Length; i++) { byte[] u = Helper.GetBytes((int)bits[i], false); Buffer.BlockCopy(u, 0, b, i * 4 + 8, 4); } _bitmapFileWrite.Write(b, 0, b.Length); _lastBitmapOffset += b.Length; return off; }