ギャラリーで見ることができ、後で使用できるイメージとしてStorageFileを保存します。 StorageFileには、カメラで撮影した画像またはギャラリーから撮影した画像が含まれ、StorageFileで変換されます。Windows phone 8.1 save StorageFile as image
答えて
private async void SaveCroppedImage(object sender, RoutedEventArgs e)
{
StorageFile file = await KnownFolders.CameraRoll.CreateFileAsync("edited.jpg", CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream stream =await file.OpenAsync(FileAccessMode.ReadWrite))
{
await EncodeWriteableBitmap(WB_CroppedImage, stream, BitmapEncoder.JpegEncoderId);
}
}
private static async Task EncodeWriteableBitmap(WriteableBitmap bmp, IRandomAccessStream writeStream, Guid encoderId)
{
// Copy buffer to pixels
byte[] pixels;
using (var stream = bmp.PixelBuffer.AsStream())
{
pixels = new byte[(uint)stream.Length];
await stream.ReadAsync(pixels, 0, pixels.Length);
}
// Encode pixels into stream
var encoder = await BitmapEncoder.CreateAsync(encoderId, writeStream);
encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied,
(uint)bmp.PixelWidth, (uint)bmp.PixelHeight,
96, 96, pixels);
await encoder.FlushAsync();
}
素晴らしいです。しかし、画像がカメラで撮影されると、BitmapImageが取得されます。 BitmapImageをWriteableBitmapに変換するのに、このメソッドを使用していますが、保存されたイメージは完全に黒です。コード: パブリックasync void CreateWriteableBitmap() { WriteableBitmap newImg; var obj = AppとしてのApp.Current; BitmapImage originalPic = obj.ImageToEdit; StorageFileファイル= obj.fileTransfer; newImg = new WriteableBitmap(originalPic.PixelWidth、originalPic.PixelHeight); using(var stream = await file.OpenReadAsync()) {newImg.SetSourceAsync(await)}} –
フィルタやトリミングを適用していますか? – Archana
いいえ、元の未編集の画像です。 –
既知の画像拡張子(.jpgや.pngなど)を使用してstoragefileをパブリックフォルダに保存すると、ギャラリーに表示されます。
- 1. Windows phone 8.1 StorageFileを閉じるには?
- 2. Windows Phone 8.1のイメージキャッシュ
- 3. WebView windows phone 8.1
- 4. Windows phone 8.1ランタイムアプリ
- 5. Windows phone 8.1 StatusBar Themeing
- 6. Smaato on Windows Phone 8.1
- 7. Publish Windows Phone 8.1 app
- 8. Windows Phoneの音量レベル8.1
- 9. Windows Phoneでのアプリケーションクラッシュ8.1
- 10. DrawerLayoutアクセス違反Windows Phone 8.1
- 11. System.Windows.Controls Windows Phone 8.1のChildWindow
- 12. Windows Phone 8.1の塗り幅
- 13. windows phone 8.1コールレストapi c#
- 14. AES暗号化Windows Phone 8.1
- 15. プロジェクトをWindows Phone 8.1 SilverlightからWindows Phone 8.1 Runtimeに変換する方法
- 16. Windows phone UWPアプリ - Image Cloud Storage
- 17. javascript 'save as'ポップアップ
- 18. Windows PhoneでGoogleドライブからtxtファイルをダウンロードする8.1
- 19. Windows Phone 8.1 webrequest POSTレスポンスを取得
- 20. GRPC C#ライブラリWindows 8.1 Phone Appの場合
- 21. Windows Phone 8.1のアプリケーションでクリップボードにコピー
- 22. Windows Phone 8.1でのファイアウォールルールの追加
- 23. Telerik RadListViewとドラッグ&ドロップ(Windows Phone 8.1用)
- 24. Windows Phone 8.1のデバイス登録エラーコード0x64
- 25. Windows Phone 8.1でキャンバスアニメーションを動かす
- 26. のWindows Phone 8.1結合ビングマップ画鋲
- 27. Windows PhoneでのMVVMリストビューのインクリメンタルローディング8.1
- 28. Windows Phone 8.1を隠しているナビゲーションボタン
- 29. VBA EXCEL/WORD - SAVE AS
- 30. CF Save AsダイアログボックスでSave Type Asを設定
あなたの質問はありますか? –
ギャラリーに画像が見えるようにStorageFileファイルを電話に保存するには –
編集した画像を保存するのですか? – Archana