当前位置: 首页>>代码示例>>C#>>正文


C# WriteableBitmap.Rotate方法代码示例

本文整理汇总了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;
        }
开发者ID:jamesmcroft,项目名称:WindowsAppCodeSnippets,代码行数:23,代码来源:CameraCapture.cs

示例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;
            }
        }
开发者ID:ms-iot,项目名称:LEDMatrix,代码行数:41,代码来源:MainPage.xaml.cs


注:本文中的Windows.UI.Xaml.Media.Imaging.WriteableBitmap.Rotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。