當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。