static void Main(string[] args) { byte[] b = new byte[800 * 10]; new Random().NextBytes(b); Fountain f = new Fountain(1234, b, 10); Bucket bucket = new Bucket(f.BlockSize, f.BlockCount); List<bool[]> progresses = new List<bool[]>(); while (!bucket.IsComplete) { bucket.AddPacket(f.CreatePacket()); progresses.Add(bucket.ProgressIndicator().ToArray()); } Bitmap image = new Bitmap(f.BlockCount, progresses.Count); int x = 0; int y = 0; foreach (var item in progresses) { foreach (var pix in item) { image.SetPixel(x, y, pix ? Color.Green : Color.Red); x++; } x = 0; y++; } image.Save("Progress chart.bmp"); }
public void EncodeDecode() { Fountain f = new Fountain(1234, data, 4); Bucket bucket = new Bucket(f.BlockSize, f.BlockCount); DigitalFountain.Packet packet; bool cont = true; do { packet = f.CreatePacket(); cont = !bucket.AddPacket(packet); } while (cont); byte[] decoded = bucket.GetData(); Assert.AreEqual(decoded.Length, data.Length); for (int i = 0; i < decoded.Length; i++) Assert.AreEqual(decoded[i], data[i]); }
public void CreateBucket() { Bucket b = new Bucket(1, 2); }