title: Convert 2D short array to Base64
body: <p>I have a 2D short array coming from a C++ library. The array contains the pixels of a 16 bit grayscale image. I am trying to convert it to Base64 to display it. My C# code is as follows:</p>
  <pre class="lang-cs prettyprint-override"><code>
  string picture_path = &quot;~/Picture/CT_Axial_Z/CT_Axial-Z_0111.png&quot;;
  string path = System.Web.Hosting.HostingEnvironment.MapPath(picture_path);
      
  if (File.Exists(path))
  {
      IntPtr gpget = Open16BitGrayImage(path);
      CImage_DLL gget = (CImage_DLL)Marshal.PtrToStructure(gpget, typeof(CImage_DLL));
      int short_size = sizeof(short);
      int p_s_cursor = 0;
      
      Array pshImageData = Array.CreateInstance(typeof(short), gget.m_nH, gget.m_nW);
      
      for (int i = 0; i &lt; gget.m_nH; i++)
      {
          for (int j = 0; j &lt; gget.m_nW; j++)
          {
              short data = (short)Marshal.PtrToStructure(gget.pshImageData + p_s_cursor, typeof(short));
              pshImageData.SetValue(data, i, j);
              p_s_cursor += short_size;
          }
      }
  }
  
  </code></pre>
  <p>I need to convert it to Base64 and display it on a canvas. How should I do it?</p>