我让用户在我的应用中拍摄图像并将图像保存在隔离存储中。我也在我的应用程序中使用HubTiles,但HubTiles在其Source属性中使用了Uri但它无法识别isostore:/ ..... Uris ..
我知道如何解决这个问题?
答案 0 :(得分:0)
您并不是唯一一个遇到isostore:/
URI在每个地方都无法运行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中有图像的话)。