I have a WEB-APP that is a Web-Cam App that takes images and stores into a database as bytes, Now with that being said I also don't want to save the images those are taken and save it in any kind of folder right now the only way to show the image that is captured for me to save it and view it again to do that I have a input stream that's fired when the capture image is clicked.
using (StreamReader reader = new StreamReader(Request.InputStream))
{
hexString = Server.UrlEncode(reader.ReadLine());
string imageName = DateTime.Now.ToString("dd-MM-yy hh-mm-ss");
string imagePath = string.Format("~/Pictures/{0}.png", imageName);
File.WriteAllBytes(Server.MapPath(imagePath), ConvertHexToBytes(hexString));
Session["Byte"] = hexString;
// Session["CapturedImage"] = ResolveUrl(imagePath);
Image1.ImageUrl = "data:image/jpg;base64," + Convert.ToBase64String(ConvertHexToBytes(hexString));
}
I have a method that converts that hex string to bytes:
private static byte[] ConvertHexToBytes(string hex)
{
// MemoryStream stream = new MemoryStream();
byte[] bytes = new byte[hex.Length / 2];
for (int i = 0; i < hex.Length; i += 2)
{
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
return bytes;
}
I want to Display that image using the bytes, I don't want to save the image in any folder. How do I take those bytes and put them into a image?
I have a slandered image tag Image1.imageUrl =? I tried the base64 version but it doesn't work.