Advertisement
Guest User

Untitled

a guest
May 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1.     public static List<byte[]> CompressMap()
  2.     {
  3.         byte[] rawinput = new byte[DimX * DimY * DimZ];
  4.  
  5.         for (int x = 0; x < DimX; x++)
  6.             for (int y = 0; y < DimY; y++)
  7.                 for (int z = 0; z < DimZ; z++)
  8.                     rawinput[DimX * DimY * DimZ] = map[x, y, z];
  9.  
  10.         MemoryStream output = new MemoryStream();
  11.         MemoryStream input = new MemoryStream(rawinput);
  12.  
  13.         using (GZipStream compress = new GZipStream(output, CompressionMode.Compress))
  14.         {
  15.             byte[] buff = new byte[DimX * DimY * DimZ];
  16.             int bytes;
  17.             while ((bytes = input.Read(buff, 0, buff.Length)) != 0)
  18.             {
  19.                 compress.Write(buff, 0, bytes);
  20.             }
  21.         }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement