【发布时间】:2017-06-22 19:36:33
【问题描述】:
这个问题似乎已经被问过了,但是我找不到相关的答案。
我在 UWP 应用程序中将 BMP 图像加载到内存中,我想将其旋转 90、180 或 270,但我找不到执行此操作的方法。
imgSource.rotate() 似乎不再存在 RotateTransform 与 xaml 一起使用 ....
请问有人可以添加缺少的代码吗?
public async Task LoadImage()
{
StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("test.bmp");
using (var stream = await file.OpenAsync(FileAccessMode.Read))
{
var decoder = await BitmapDecoder.CreateAsync(stream);
bitmap = await decoder.GetSoftwareBitmapAsync(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied);
var imgSource = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight);
// Code to rotate image by 180 to be added
bitmap.CopyToBuffer(imgSource.PixelBuffer);
}
}
【问题讨论】: