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:
string picture_path = "~/Picture/CT_Axial_Z/CT_Axial-Z_0111.png";
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 < gget.m_nH; i++)
{
for (int j = 0; j < 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;
}
}
}
I need to convert it to base64 and display it on canvas, how should I do it?
Sorry,my english maybe not good,But hope someone can help me~Thanks!