Пример #1
0
        public string serialize()
        {
            // convert the byte[,] array into a KSP-savefile-safe variant of Base64
            MemoryStream    mem  = new MemoryStream();
            BinaryFormatter binf = new BinaryFormatter();

            binf.Serialize(mem, coverage);
            string blob = Convert.ToBase64String(CLZF2.Compress(mem.ToArray()));

            return(blob.Replace("/", "-").Replace("=", "_"));
        }
Пример #2
0
 public void deserialize(string blob)
 {
     try {
         blob = blob.Replace("-", "/").Replace("_", "=");
         byte[] bytes = Convert.FromBase64String(blob);
         bytes = CLZF2.Decompress(bytes);
         MemoryStream    mem  = new MemoryStream(bytes, false);
         BinaryFormatter binf = new BinaryFormatter();
         coverage = (byte[, ])binf.Deserialize(mem);
     } catch (Exception e) {
         coverage  = new byte[360, 180];
         heightmap = new float[360, 180];
         throw e;
     }
     resetImages();
 }