private void FixedCoding(string fileName, int predictorType, string acceptedError) { var writer = new BitWriter("../../../Images/" + fileName); writer.WriteNBits(new BitArray(_origImageHeader)); //asta inca nu e ok writer.WriteString("p" + predictorType); writer.WriteString("k" + acceptedError); writer.WriteString("s" + "F"); //write quantized prediction Error to File for (int i = 0; i < _coder.QuatizedPredictionError.GetLength(0); i++) { for (int j = 0; j < _coder.QuatizedPredictionError.GetLength(1); j++) { writer.WriteIntOnNBits(_coder.QuatizedPredictionError[i, j], 9); } } writer.FlushLastBits(); }
static void Main(string[] args) { var x = new BitReader("Test.txt"); var y = new BitWriter("TestWrite.txt"); //bool? bla; //do //{ // bla = x.Read(); // if (bla != null) // Console.Write((bool)bla ? 1 : 0); //} while (bla != null); //***************************************************************/ //BitArray bla; // do // { // bla = x.ReadNBits(8); // if (bla != null) // { // for(int i=0;i<bla.Length;i++) // { // Console.Write(bla[i]?1:0); // } // Console.WriteLine(); // } // } while (bla != null); //*******************************************// //bool? bla; //do //{ // bla = x.Read(); // if (bla != null) // y.WriteBit((bool)bla); //} while (bla != null); //y.FlushLastBits(); //Process.Start("TestWrite.txt"); //********************************************// BitArray bla; do { bla = x.ReadNBits(3); if (bla != null) { y.WriteNBits(bla); } } while (bla != null); y.FlushLastBits(); Process.Start("TestWrite.txt"); }