0

I've saved some bitmaps to a database as an array of bytes.

using (var stream = new MemoryStream())
{
    bitmap.Save(stream, ImageFormat.Bmp);
    stream.Position = 0;
    bitmapData = new byte[stream.Length];
    stream.Read(bitmapData, 0, (int)stream.Length);
    stream.Close();
}

I'd like to transfer the data using MVC4 Web API to a javascript client. Do I need to change anything or is it possible like this? Can I just convert the byte array to a base64 string and use it directly inside image element ?

3
  • 1
    You need to use a data: URI. Commented May 11, 2014 at 21:23
  • Yeah but can i just use the converted bitmap object bytes as base64 Commented May 11, 2014 at 21:27
  • 1
    Yes, except that you should use PNG or JPEG (for photos) instead of BMP. Commented May 11, 2014 at 21:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.