IsolatedStorage의 html 페이지에서 사용할 때 "이미지 경로"와 관련하여 뭔가 이상하고 유선이 있습니다.격리 된 저장소에서 html 페이지로 로컬 이미지로드
응용 프로그램의 webBrowser 객체에서 사용하는 html 페이지를 만들고 싶습니다. 그래서 IsolatedStorage에서 html 페이지를 만든 다음이 페이지를 webBroswser.Navigate와 함께 사용합니다.
이미지를 제외한 모든 것이 정상적으로 작동합니다.
1) IsolatedStorage의 루트에 이미지와 HTML 페이지를 만들면 모든 것이 정상적으로 작동하며 코드 <img src="image.png">
이 작동하고 페이지 페이지에서 이미지를 볼 수 있습니다.
2)하지만, 이미 디렉토리에 여러 개의 디렉토리가 있으므로 루트에서 페이지와 이미지를 저장하는 방법은 좋은 생각이 아닙니다. 따라서 새로운 디렉토리 "Html"을 만들고 거기에 모든 페이지를 저장하십시오.
이제이 페이지를 열면 이미지가 보이지 않습니다. src 링크의 여러 변형을 시도했지만 여전히 답을 찾을 수 없습니다.
계층 구조 인 경우, <img src=...">
태그에 올바른 링크를 수있는 것들 :
IsolatedStorage -> html로 (폴더) -> index.html을 (파일)
(1) IsolatedStorage -> Html (folder) -> image.png (file)
(2) IsolatedStorage -> Html (folder) -> Images (folder) -> image.png (file)
실제로, 나는 (1)에 대해 <img src="image.png">
과 같을 것이라고 생각했지만 몇 가지 유사한 버전을 시도했지만 그 중 아무 것도 작동하지 않았습니다. 이 방법은 IsolatedStorage에 사진을 저장합니다
하지만, HTML의 img 태그에서 사용하는 것을 허용하지 않습니다 :
using (IsolatedStorageFile isopicsFile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isopicsFile.FileExists(Constants.HtmlFolderName + "launch.png") == false)
{
Stream yourFilepath = Application.GetResourceStream(new Uri("/someUri/launch.png", UriKind.Relative)).Stream;
BitmapImage b = new BitmapImage();
b.SetSource(yourFilepath);
WriteableBitmap wb = new WriteableBitmap(b);
using (var isoFileStream = isopicsFile.CreateFile(Constants.HtmlFolderName + "launch.png"))
{
var width = wb.PixelWidth;
var height = wb.PixelHeight;
// Theoretically, there may be the problem, as the file extention is png, not jpg
System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, isoFileStream, width, height, 0, 100);
}
}
}
그리고이 이상한 조금 보인다
가능한 복제본 [웹 브라우저 컨트롤에서 로컬 이미지 사용] (http://stackoverflow.com/questions/10363174/use-local-images-in-webbrowser-control) –