0
我正在處理將圖像從選定文件夾加載到gridView的應用程序。使用Bitmap.SetSource時出錯
當我使用SetSource來設置BitmapImage源我加載一些圖像後收到錯誤「內存不足」。
當我使用Uri路徑的構造函數,它工作正常。但它只會顯示來自項目目錄的圖像。
StorageFolder folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(RecentToken);
StorageFile file = await folder.GetFileAsync(path);
IRandomAccessStream stream = await file.OpenReadAsync();
image = new BitmapImage(new Uri(file.Path));//loads only within project directory
image.SetSource(stream);//causes insufficient memory
stream.Dispose();