//CALL STACK: LoadData -> ReadLayerFromStream private static CompressedLayer _ReadLayerFromStream(BinaryReader br, BahnLib.ZoomFactor zoomFactor, GraphicVersion graphicVersion) { if (br == null) { throw new ArgumentNullException("br"); } CompressedLayer l = new CompressedLayer(); l.X0 = br.ReadInt16(); l.Y0 = br.ReadInt16(); l.Width = br.ReadInt16(); l.Height = br.ReadInt16(); if (graphicVersion == GraphicVersion.Version2) { int layerLength = br.ReadInt32(); List <uint> data = new List <uint>(); for (int i = 0; i < layerLength; i++) { data.Add(br.ReadUInt32()); } l.LayerData = data.ToArray(); } else if (graphicVersion < GraphicVersion.Version2) { uint[,] decompressedLayer = _ReadLayerFromStreamVersion0(br, l.Width, l.Height); l = CompressLayer(_FillLayer(decompressedLayer, l.X0, l.Y0, zoomFactor), zoomFactor); } else { throw new ArgumentOutOfRangeException("graphicVersion"); } return(l); }
private static void _WriteLayerToStream(CompressedLayer layer, BinaryWriter bw, BahnLib.ZoomFactor zoomFactor) { if (bw == null) { throw new ArgumentNullException("bw"); } bw.Write(layer.X0); //x0 bw.Write(layer.Y0); //y0 bw.Write(layer.Width); //width bw.Write(layer.Height); //height bw.Write(layer.LayerData.Length); foreach (uint item in layer.LayerData) { bw.Write(item); } }