1

ロック画面の画像を変更する Windows Phone 8 アプリケーションを実装しようとしています。イメージを分離ストレージに書き込むコードの一部は次のとおりです。

private async void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    store.Remove();
                }
                BitmapImage bi = new BitmapImage();
                bi.SetSource(e.ChosenPhoto);
                WriteableBitmap wb = new WriteableBitmap(bi);
                byte[] buffer = null;
                using (var ms = new System.IO.MemoryStream())
                {
                    int quality = 80;
                    e.ChosenPhoto.Seek(0, SeekOrigin.Begin);

                    // TODO: Crop or rotate here if needed

                    wb.SaveJpeg(ms, wb.PixelWidth, wb.PixelHeight, 0, quality);
                    buffer = ms.ToArray();
                }
                var isoFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                var nextImageName = Guid.NewGuid() + ".jpg";
                var newImageFile = await isoFolder.CreateFileAsync(nextImageName, Windows.Storage.CreationCollisionOption.FailIfExists);
                using (var wfs = await newImageFile.OpenStreamForWriteAsync())
                {
                    wfs.Write(buffer, 0, buffer.Length);
                }
                Windows.Phone.System.UserProfile.LockScreen.SetImageUri(new Uri("ms-appdata:///Local/" + nextImageName, UriKind.Absolute));
                MessageBox.Show("You have successfully set a new background");
            }
        }

コードの途中に次のコメントがあります。

// TODO: Crop or rotate here if needed

私の質問は:

ネイティブ画像トリミングのコードは何ですか? (たとえば、ネイティブの Windows Phone ロック画面設定でロック画面の写真を選択したときに表示されるものなど)

4

1 に答える 1