我有一个 Windows 8 应用程序,我想在其中旋转图像文件。
在镜头中,我想打开一个图像文件,旋转它并将内容保存回文件。
这在 WinRT 中可能吗?如果是这样,怎么做?谢谢。
更新:
根据 Vasile 的回答,我可以在这方面做一些工作。但是我不确定下一步该怎么做:
public static async Task RotateImage(StorageFile file)
{
if (file == null)
return;
var data = await FileIO.ReadBufferAsync(file);
// create a stream from the file
var ms = new InMemoryRandomAccessStream();
var dw = new DataWriter(ms);
dw.WriteBuffer(data);
await dw.StoreAsync();
ms.Seek(0);
// find out how big the image is, don't need this if you already know
var bm = new BitmapImage();
await bm.SetSourceAsync(ms);
// create a writable bitmap of the right size
var wb = new WriteableBitmap(bm.PixelWidth, bm.PixelHeight);
ms.Seek(0);
// load the writable bitpamp from the stream
await wb.SetSourceAsync(ms);
wb.Rotate(90);
//How should I save the image to the file now?
}