public void SaveToFile(String filepath) { //store dmax, smallDelta, bigDelta, cqueue, iqueue, aqueue List<int> aqueueList = null; if (this.optimizedAQueue != null) aqueueList = optimizedAQueue; else aqueueList = new List<int>(this.aqueue); CompResult results = new CompResult(aqueueList, cqueue, iqueue, bigDelta, smallDelta, a, dmax,bitmap.Width,bitmap.Height); StreamWriter sw = new StreamWriter(filepath); sw.WriteLine(bigDelta); sw.WriteLine(smallDelta); sw.WriteLine(a); sw.WriteLine(dmax); sw.WriteLine(bitmap.Width); sw.WriteLine(bitmap.Height); sw.WriteLine(aqueueList.Count); for (int i = 0; i < aqueueList.Count; i++) sw.WriteLine(aqueueList[i]); sw.WriteLine(cqueue.Count); Queue<Double>.Enumerator enumerator = cqueue.GetEnumerator(); while (enumerator.MoveNext()) { sw.WriteLine(enumerator.Current); } sw.WriteLine(iqueue.Count); Queue<MappedPoint>.Enumerator enumerator2 = iqueue.GetEnumerator(); while (enumerator2.MoveNext()) { int x = enumerator2.Current.X; sw.WriteLine(x); sw.WriteLine(enumerator2.Current.Y); sw.WriteLine(enumerator2.Current.Val); enumerator2.MoveNext(); sw.WriteLine(enumerator2.Current.Val); enumerator2.MoveNext(); x = enumerator2.Current.X - x; sw.WriteLine(enumerator2.Current.Val); enumerator2.MoveNext(); sw.WriteLine(enumerator2.Current.Val); sw.WriteLine(x); } sw.Close(); }
public static CompResult DeserializeCompResult(string filepath) { List<int> aQueue = new List<int>(); Queue<double> cQueue = new Queue<double>(); Queue<MappedPoint> iQueue = new Queue<MappedPoint>(); StreamReader sr = new StreamReader(filepath); int bigDelta = Int32.Parse(sr.ReadLine()); int smallDelta = Int32.Parse(sr.ReadLine()); int a = Int32.Parse(sr.ReadLine()); int dmax = Int32.Parse(sr.ReadLine()); int width = Int32.Parse(sr.ReadLine()); int height = Int32.Parse(sr.ReadLine()); int aCount = Int32.Parse(sr.ReadLine()); for (int i = 0; i < aCount; i++) aQueue.Add(Int32.Parse(sr.ReadLine())); int cCount = Int32.Parse(sr.ReadLine()); for (int i = 0; i < cCount; i++) { cQueue.Enqueue(Double.Parse(sr.ReadLine())); } int iCount = Int32.Parse(sr.ReadLine()); for (int i = 0; i < iCount / 4; i++) { int x = Int32.Parse(sr.ReadLine()); int y = Int32.Parse(sr.ReadLine()); double val = Double.Parse(sr.ReadLine()); double val1 = Double.Parse(sr.ReadLine()); double val2 = Double.Parse(sr.ReadLine()); double val3 = Double.Parse(sr.ReadLine()); int tempX = Int32.Parse(sr.ReadLine()); iQueue.Enqueue(new MappedPoint(x, y, val)); iQueue.Enqueue(new MappedPoint(x, y - tempX, val1)); iQueue.Enqueue(new MappedPoint(x + tempX, y - tempX, val2)); iQueue.Enqueue(new MappedPoint(x + tempX, y, val3)); } sr.Close(); CompResult result = new CompResult(aQueue, cQueue, iQueue, bigDelta, smallDelta, a, dmax, width, height); return result; }