1) FileOpenPicker オブジェクトを使って、目的のファイルに対応する StorageFile オブジェクトを作成 2) StorageFile オブジェクトの OpenAsync メソッドで目的のファイルに対するストリーム(random-access stream)を取得 3) BitmapImage オブジェクトの SetSource メソッドでストリームを渡す 4) BitmapImage そのものを、Image コントロールの Source プロパティにセット
private async Task DisplayImageFileAsync(StorageFile file)
{
// Request persisted access permissions to the file the user selected.
// This allows the app to directly load the file in the future without relying on a
// broker such as the file picker.
m_fileToken = m_futureAccess.Add(file);
// Display the image in the UI.
BitmapImage src = new BitmapImage();
src.SetSource(await file.OpenAsync(FileAccessMode.Read));
Image1.Source = src;
AutomationProperties.SetName(Image1, file.Name);
// Use BitmapDecoder to attempt to read EXIF orientation and image dimensions.
await GetImageInformationAsync(file);
ExifOrientationTextblock.Text = Helpers.GetOrientationString(m_exifOrientation);
UpdateImageDimensionsUI();
ScaleSlider.IsEnabled = true;
RotateLeftButton.IsEnabled = true;
RotateRightButton.IsEnabled = true;
SaveButton.IsEnabled = true;
SaveAsButton.IsEnabled = true;
CloseButton.IsEnabled = true;
}
▲ Microsoft の実際のサンプルコード FileAccessMode enumeration
|
|
【Win8 ストアアプリの最新記事】
- C# : HttpClient で Post と Get する汎用 static クラス
- Win8.1 ストアアプリ(JS) : Visual Studio 2013 で Three.js(v65) の WebGLRenderer の動作を確認しました
- WinJS ストア : Three.js を組み込んで、『画像を飛ばす』テンプレート( Bird.js を利用 )
- WinJS ストア : 『背景画像をチェンジする2画面アプリ』のテンプレート
- VS2012ストア(C#) : WebView テンプレート
- VS2012(C#)ストア : ListView Twitter 検索テンプレート
- イラストを背景にして2ページの画面遷移を解りやすくした Windows Store テンプレート
- Twitter API の自分のアプリのトークンを使って投稿するだけの class VS2012_Twitter
- Win8 ストア(C#) / PDF viewer sample (Windows 8.1)
- ストアアプリの TextBox のスクロールバー
- Win8 ストアアプリの、メモリ上にページを残す画面遷移と、前画面のコントロールの参照
- Win8 ストアアプリで、『選択肢を応答するダイアログ』を簡単に使うための MessageBox クラス
- Win8 ストアから Post 投稿
- Win8ストア XAML の AppBarButtonStyle のContent に指定する 16進数 Unicode の取得
- Win8 ストア : UrlEncode と UrlDecode
- Win8 ストア : HttpClient + XDocument で RSS の取得
- Win8 ストア : リストボックス テンプレート
- Win8 ストア : ファイルアクセス テンプレート
- Win8 ストア : ストアブランク テンプレート
- AppBar テンプレート / Win8 ストアアプリ(C#)


1) FileOpenPicker オブジェクトを使って、目的のファイルに対応する StorageFile オブジェクトを作成
2) StorageFile オブジェクトの 



