Advertisement
baratiistok3

functions

Oct 2nd, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1.     public int[,] GetIntArray(string file)
  2.         {
  3.             uint heigth = 2048;
  4.             uint width = 2048;
  5.             var result = new int[heigth, width];
  6.  
  7.             using (BinaryReader reader = new BinaryReader(File.Open(file, FileMode.Open)))
  8.             {
  9.                 for (int i = 0; i < heigth; i++)
  10.                 {
  11.                     for (int j = 0; j < width; j++)
  12.                     {
  13.                         result[j, i] = reader.ReadUInt16();
  14.                     }
  15.                 }
  16.             }
  17.             return result;
  18.         }
  19.  
  20.         public int[,] GetIntArray2(string file)
  21.         {
  22.             uint heigth = 2048;
  23.             uint width = 2048;
  24.             var result = new int[heigth, width];
  25.  
  26.             using (BinaryReader reader = new BinaryReader(File.Open(file, FileMode.Open)))
  27.             {
  28.                 for (int i = 0; i < heigth; i++)
  29.                 {
  30.                     for (int j = -1; j < width-1;)
  31.                     {
  32.                         UInt64 r = reader.ReadUInt64();
  33.                         result[++j, i] = (UInt16)(r >> 48);
  34.                         result[++j, i] = (UInt16)(r >> 32);
  35.                         result[++j, i] = (UInt16)(r >> 16);
  36.                         result[++j, i] = (UInt16)(r);
  37.                     }
  38.                 }
  39.             }
  40.             return result;
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement