2011-10-09 2 views
1

사용자가 내 앱에서 이미지를 가져 와서 격리 된 저장소에 이미지를 저장하도록했습니다. 또한 내 응용 프로그램에서 HubTiles를 사용하지만 HubTiles는 Source 속성에서 Uri를 사용하지만 isostore :/..... Uris를 인식 할 수 없습니다.HubTiles에서 격리 된 저장소 이미지 사용

이 문제를 어떻게 해결할 수 있습니까?

답변

0

URI가 예상되는 모든 곳에서 isostore:/ URI가 작동하지 않는다는 사실만이 아닙니다. 이 잘 작동

// define data array to hold image data to be read from isolated storage 
    byte[] imageBytes; 
    using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) 
    { 
     // open image file 
     using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("MyPreviouslySavedImage.jpg", FileMode.Open, FileAccess.Read)) 
     { 
      // allocate array large enough to hold the whole file 
      imageBytes = new byte[fileStream.Length]; 

      // read all data to memory 
      fileStream.Read(imageBytes, 0, imageBytes.Length); 
      fileStream.Close(); 
     } 
    } 

    // create memory stream and bitmap 
    MemoryStream memoryStream = new MemoryStream(imageBytes); 
    BitmapImage bitmapImage = new BitmapImage(); 

    // memory stream is source of bitmap 
    bitmapImage.SetSource(memoryStream); 

    // finally assign image to hub tile 
    hubTile1.Source = bitmapImage; 

(이미지는 물론 isostore에있을 경우) : 당신은 전통적인 접근 방식을 손으로 이미지를로드 할 필요 같은 것 같습니다.

+0

도와 주셔서 감사합니다. Heinrich Ulbricht :) –

+0

환영합니다 :) –

관련 문제