Windows phone 7 在HTML文件中加载PNG图像
在我的Windows Phone7.1应用程序中,我从WebBrowser的本地路径加载HTML文件。为此,我Windows phone 7 在HTML文件中加载PNG图像,windows-phone-7,windows-phone-7.1,Windows Phone 7,Windows Phone 7.1,在我的Windows Phone7.1应用程序中,我从WebBrowser的本地路径加载HTML文件。为此,我 使用以下代码将PNG图像转换为base64格式,问题是图像路径的base64格式未在webbrowser中加载图像。 请帮帮我哪里出错了 string s = "data:image/jpg;base64,"; imgStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NewUIChanges.Html
使用以下代码将PNG图像转换为base64格式,问题是图像路径的base64格式未在webbrowser中加载图像。 请帮帮我哪里出错了
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);
string s=“数据:图像/jpg;base64”;
imgStream=Assembly.getExecutionGassembly().GetManifestResourceStream(“NewUIChanges.Htmlfile.round1.png”);
字节[]数据=新字节[(int)imgStream.Length];
整数偏移=0;
while(偏移量<数据长度)
{
int bytesRead=imgStream.Read(data,offset,data.Length-offset);
如果(bytesRead如果您没有错误,则数据
包含您的图像,并且htmlcontent
中存在round1.png
,则可能是图像类型错误,请尝试以下操作:
string s = "data:image/png;base64,";