0

i am using Visual studio 2010 with .Net 3.5 framework

my code work fine in my windows 8, IE 9

however it doesnt work in windows xp , IE7, i have no idea what is exactly happen

Byte[] byImg = ((byte[])dr["logo"]);
var vBase64String = Convert.ToBase64String(byImg);
logo.ImageUrl = string.Format("data:image/gif;base64,{0}", vBase64String); 

is there any support issue?

Low Chee Mun
  • 610
  • 1
  • 4
  • 9

2 Answers2

0

IE7 does not support data: protocol for images. It is implemented in IE8 and above.

If you need to support IE7 - server separate image files instead.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • @Alexi, is that other way to form a picture from byte[] to image without using data: protocol ? – Low Chee Mun Nov 09 '13 at 07:37
  • No... You need to generate Url (like "/generatedimages/imagehandler.ashx?id=image1234") and implement handler (like "ashx" file if using WebForms) that will serve bytes for that image. Search for something like "C# asp.Net render image" to find more info like http://stackoverflow.com/questions/186062/can-an-asp-net-mvc-controller-return-an-image (also this one for MVC) – Alexei Levenkov Nov 09 '13 at 20:49
0

Try this:

string imageDataParsed = imageData.Substring( imageData.IndexOf( ',' ) + 1 );
byte[] imageBytes = Convert.FromBase64String( imageDataParsed );
using ( var imageStream = new MemoryStream( imageBytes, false ) )
{
   Bitmap image = new Bitmap( imageStream );
}
Community
  • 1
  • 1