本文整理汇总了C#中Windows.UI.Xaml.Media.Imaging.WriteableBitmap.Rotate方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.Rotate方法的具体用法?C# WriteableBitmap.Rotate怎么用?C# WriteableBitmap.Rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.Rotate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateImage
private async Task<StorageFile> RotateImage(int rotation, IStorageFile file)
{
var data = await FileIO.ReadBufferAsync(file);
var ms = new InMemoryRandomAccessStream();
var dw = new DataWriter(ms);
dw.WriteBuffer(data);
await dw.StoreAsync();
ms.Seek(0);
var bm = new BitmapImage();
await bm.SetSourceAsync(ms);
var wb = new WriteableBitmap(bm.PixelHeight, bm.PixelWidth);
ms.Seek(0);
await wb.SetSourceAsync(ms);
var rotated = wb.Rotate(rotation);
var result = await this.SaveCroppedImage(rotated);
return result;
}
示例2: GetPreviewFrameAsSoftwareBitmapAsync
/// <summary>
/// Gets the current preview frame as a SoftwareBitmap, displays its properties in a TextBlock, and can optionally display the image
/// in the UI and/or save it to disk as a jpg
/// </summary>
/// <returns>Task representing the async event status</returns>
private async Task GetPreviewFrameAsSoftwareBitmapAsync()
{
// Get information about the preview
VideoEncodingProperties previewProperties = this._mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
// Create the video frame to request a SoftwareBitmap preview frame
VideoFrame videoFrame = new VideoFrame(BitmapPixelFormat.Bgra8, (int)previewProperties.Width, (int)previewProperties.Height);
// Capture the preview frame
using (VideoFrame currentFrame = await this._mediaCapture.GetPreviewFrameAsync(videoFrame))
{
// Collect the resulting frame
SoftwareBitmap previewFrame = currentFrame.SoftwareBitmap;
// Show the frame information
Debug.WriteLine("{0}x{1} {2}", previewFrame.PixelWidth, previewFrame.PixelHeight, previewFrame.BitmapPixelFormat);
tempWriteableBitmap = new WriteableBitmap(previewFrame.PixelWidth, previewFrame.PixelHeight);
previewFrame.CopyToBuffer(tempWriteableBitmap.PixelBuffer);
// Crop to a square, based on the smallest side
int minEdge = Math.Min(tempWriteableBitmap.PixelWidth, tempWriteableBitmap.PixelHeight);
tempWriteableBitmap = tempWriteableBitmap
.Crop(0, 0, minEdge, minEdge)
.Resize(App.LedMatrix.PixelWidth, App.LedMatrix.PixelHeight, WriteableBitmapExtensions.Interpolation.Bilinear);
WriteableBitmap previewFrameImageSource =
tempWriteableBitmap.Rotate(90).Resize(
(int)this.postViewbox.Height,
(int)this.postViewbox.Width,
WriteableBitmapExtensions.Interpolation.NearestNeighbor);
this.previewFrameImage.Source = previewFrameImageSource;
}
}