1

Windows ストア アプリを作成しました。画像サイズを変更したいのですが、以下のコードは画像を保存することです:

private async void saveImage(StorageFile destinationFile)
{
     if (destinationFile != null)
     {
         using (var readStream = await sourceFile.OpenReadAsync())
         {
               var decoder = await BitmapDecoder.CreateAsync(readStream);
               using (InMemoryRandomAccessStream writeStream = new InMemoryRandomAccessStream())
               {
                    BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(writeStream, decoder);
                    encoder.BitmapTransform.Bounds = new BitmapBounds()
                    {
                         X = (uint)Math.Round(selectedLeft, 0),
                         Y = (uint)Math.Round(selectedTop, 0),
                         Width = (uint)Math.Round(selectedWidth, 0),
                         Height = (uint)Math.Round(selectedHeight, 0),
                    };
                    await encoder.FlushAsync();
                    using (var stream = await destinationFile.OpenAsync(FileAccessMode.ReadWrite))
                    {
                         await RandomAccessStream.CopyAndCloseAsync(writeStream.GetInputStreamAt(0), stream.GetOutputStreamAt(0));
                    }
               }
       }
}

保存される画像サイズは 320x480 です。960x1240 にサイズ変更するにはどうすればよいですか? ありがとう

4

0 に答える 0