I have a byte array representing a picture. I want to present the picture stored in that byte array in an aspx page. Can I do it using an image or imagemap control? If so - how? If not - what's the solution?
Create a ByteArrayInputStream object by passing the byte array (that is to be converted) to its constructor. Read the image using the read() method of the ImageIO class (by passing the ByteArrayInputStream objects to it as a parameter). Finally, Write the image to using the write() method of the ImageIo class.
A byte array is simply an area of memory containing a group of contiguous (side by side) bytes, such that it makes sense to talk about them in order: the first byte, the second byte etc..
Another thing you can do which is quicker would be to not use the asp.net Image control and use the basic img element in html. So within your asp.net page, create a img element with an id of img and runat set to server.
Then you could do something like this:
<img id="img" runat="server" alt=""/>
public DataRow ClaimPhotoRow { get; set; } protected void Page_Load(object sender, EventArgs e) { img.Src = "data:image/jpg;base64," + Convert.ToBase64String((byte[])ClaimPhotoRow[0]); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With