2013-01-10 407 views
0

在我的Windows Phone7.1应用程序中,Iam从WebBrowser中的本地路径加载HTML文件。为此我
使用下面的代码将PNG图像转换为base64格式,问题是基本64格式的图像路径未在webbrowser中加载图像。 请帮我在哪里我犯了错误?在HTML文件中加载PNG图像

string s = "data:image/jpg;base64,"; 
imgStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NewUIChanges.Htmlfile.round1.png"); 
     byte[] data = new byte[(int)imgStream.Length]; 
     int offset = 0; 
     while (offset < data.Length) 
     { 
      int bytesRead = imgStream.Read(data, offset, data.Length - offset); 
      if (bytesRead <= 0) 
      { 
       throw new EndOfStreamException("Stream wasn't as long as it claimed"); 
      } 
      offset += bytesRead; 
     } 
     base64 = Convert.ToBase64String(data); 

     Stream htmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NewUIChanges.Htmlfile.equity_built.html"); 
     StreamReader reader = new StreamReader(htmlStream); 
     string htmlcontent = reader.ReadToEnd(); 
     htmlcontent = htmlcontent.Replace("round1.png", s + base64); 


     wb.NavigateToString(htmlcontent); 

回答

0

如果没有错误,那data包含你的形象,round1.png存在htmlcontent,那么它只是可能是图像类型的错误,试试这个:

string s = "data:image/png;base64,"; 
+0

VO它不工作具有相同问题。 – GY1