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


C# IRandomAccessStream.Seek方法代码示例

本文整理汇总了C#中IRandomAccessStream.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# IRandomAccessStream.Seek方法的具体用法?C# IRandomAccessStream.Seek怎么用?C# IRandomAccessStream.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRandomAccessStream的用法示例。


在下文中一共展示了IRandomAccessStream.Seek方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadIntoBuffer

 public static async Task<IBuffer> ReadIntoBuffer(IRandomAccessStream stream)
 {
     stream.Seek(0);
     var buffer = new Buffer((uint) stream.Size);
     await stream.ReadAsync(buffer, buffer.Capacity, InputStreamOptions.None);
     return buffer;
 }
开发者ID:joshholmes,项目名称:BulletTime,代码行数:7,代码来源:StorageIO.cs

示例2: PlayBackImage_ImageOpened

        private async void PlayBackImage_ImageOpened(IRandomAccessStream stream)
        {
            if (CurrentSong != null)
            {
                {
                    var device = new CanvasDevice();
                    var bitmap = await CanvasBitmap.LoadAsync(device, stream);

                    var renderer = new CanvasRenderTarget(device,
                                                          bitmap.SizeInPixels.Width,
                                                          bitmap.SizeInPixels.Height, bitmap.Dpi);

                    using (var ds = renderer.CreateDrawingSession())
                    {
                        var blur = new GaussianBlurEffect
                        {
                            Source = bitmap
                        };
                        blur.BlurAmount = 16.0f;
                        blur.BorderMode = EffectBorderMode.Hard;
                        ds.DrawImage(blur);
                    }

                    stream.Seek(0);
                    await renderer.SaveAsync(stream, CanvasBitmapFileFormat.Png);
                    stream.Seek(0);
                    BitmapImage image = new BitmapImage();
                    image.SetSource(stream);
                    BackgroundBlur.Source = image;
                    renderer = null;
                    bitmap = null;
                    device = null;
                    GC.Collect();
                }
            }
        }
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:36,代码来源:MainPage.xaml.cs

示例3: ApplyEffectAsync

        /// <summary>
        /// Apply filter to image
        /// </summary>
        /// <param name="fileStream"></param>
        private async Task ApplyEffectAsync(IRandomAccessStream fileStream, IImageProvider provider, SwapChainPanel target)
        {
            using (var _renderer = new SwapChainPanelRenderer(provider, target))
            {
                try
                {
                    // Rewind the stream to start.
                    fileStream.Seek(0);

                    // Set the imageSource on the effect and render.
                    ((IImageConsumer)provider).Source = new RandomAccessStreamImageSource(fileStream);
                    await _renderer.RenderAsync();
                }
                catch (Exception exception)
                {
                    System.Diagnostics.Debug.WriteLine(exception.Message);
                }
            }
            
        }
开发者ID:Jiihaa,项目名称:LondonHack2,代码行数:24,代码来源:MainPage.xaml.cs

示例4: ApplyEffectAsync

        /// <summary>
        /// TODO: Apply filter to image
        /// </summary>
        /// <param name="fileStream"></param>
        private async void ApplyEffectAsync(IRandomAccessStream fileStream)
        {
            double scaleFactor = 1.0;
            scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;

            _writeableBitmap = new WriteableBitmap((int)(Window.Current.Bounds.Width * scaleFactor), (int)(Window.Current.Bounds.Height * scaleFactor));
            _grayscaleEffect = new GrayscaleEffect();
            _brightnessEffect = new BrightnessEffect(_grayscaleEffect);
            //            m_renderer = new SwapChainPanelRenderer(_brightnessEffect, SwapChainPanelTarget);

            string errorMessage = null;

            try
            {
                // Rewind the stream to start.
                fileStream.Seek(0);

                // Set the imageSource on the effect and render.
                ((IImageConsumer)_grayscaleEffect).Source = new Lumia.Imaging.RandomAccessStreamImageSource(fileStream);
                await m_renderer.RenderAsync();

            }
            catch (Exception exception)
            {
                errorMessage = exception.Message;
            }
        }
开发者ID:GoreMaria,项目名称:LondonHack2,代码行数:31,代码来源:MainPage.xaml.cs

示例5: SaveFileAsync

        /// <summary>
        /// 指定されたフォルダーへファイルを保存する
        /// 既存の同名ファイルが存在している場合はファイルを上書きする
        /// </summary>
        /// <param name="folder">フォルダー</param>
        /// <param name="fileName">拡張子を含むファイル名</param>
        /// <param name="stream">保存するデータのストリーム</param>
        /// <returns>ファイル</returns>
        public static async Task<StorageFile> SaveFileAsync(this IStorageFolder folder, string fileName, IRandomAccessStream stream)
        {
            var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
            using (var outputStrm = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                // 書き込むファイルからデータを読み込む
                var imageBuffer = new byte[stream.Size];
                var ibuffer = imageBuffer.AsBuffer();
                stream.Seek(0);
                await stream.ReadAsync(ibuffer, (uint)stream.Size, InputStreamOptions.None);

                // データをファイルに書き出す
                await outputStrm.WriteAsync(ibuffer);
            }
            return file;
        }
开发者ID:CH3COOH,项目名称:Softbuild.Data,代码行数:24,代码来源:StorageExtensions.cs

示例6: SaveAsync

        /// <summary>
        /// ストリームを保存する
        /// </summary>
        /// <param name="file">ファイルストレージ</param>
        /// <param name="stream">保存するデータのストリーム</param>
        /// <returns>ファイル</returns>
        public static async Task<StorageFile> SaveAsync(this StorageFile file, IRandomAccessStream stream)
        {
            using (var outputStrm = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                // 書き込むファイルからデータを読み込む
                var imageBuffer = new byte[stream.Size];
                var ibuffer = imageBuffer.AsBuffer();
                stream.Seek(0);
                await stream.ReadAsync(ibuffer, (uint)stream.Size, InputStreamOptions.None);

                // データをファイルに書き出す
                await outputStrm.WriteAsync(ibuffer);
            }
            return file;
        }
开发者ID:CH3COOH,项目名称:Softbuild.Data,代码行数:21,代码来源:StorageExtensions.cs

示例7: loadWebViewToStream

 private async void loadWebViewToStream(WebView webview, IRandomAccessStream stream)
 {
     await Task.Delay(TimeSpan.FromMilliseconds(10));
     await webview.CapturePreviewToStreamAsync(stream);
     await stream.FlushAsync();
     stream.Seek(0);
 }
开发者ID:shannah,项目名称:CN1WindowsPort,代码行数:7,代码来源:SilverlightImplementation_2.cs

示例8: RotateCaptureImageByDisplayInformationAutoRotationPreferences

        public static async Task RotateCaptureImageByDisplayInformationAutoRotationPreferences(IRandomAccessStream inStream, IRandomAccessStream outStream)
        {

            BitmapDecoder decoder = await BitmapDecoder.CreateAsync(inStream);

            BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(outStream, decoder);

            var ort = DisplayInformation.GetForCurrentView().CurrentOrientation;
            Debug.WriteLine(ort);
            switch (ort)
            {
                //The same as Portrait
                case DisplayOrientations.None:
                    encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise90Degrees;
                    break;
                //The default view for capture. 
                case DisplayOrientations.Landscape:
                    encoder.BitmapTransform.Rotation = BitmapRotation.None;
                    break;
                case DisplayOrientations.Portrait:
                    encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise90Degrees;
                    break;
                case DisplayOrientations.LandscapeFlipped:
                    encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise180Degrees;
                    break;
                case DisplayOrientations.PortraitFlipped:
                    encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise270Degrees;
                    break;
                default:
                    break;
            }
            await encoder.FlushAsync();
            inStream.Seek(0);
            outStream.Seek(0);
        }
开发者ID:GJian,项目名称:UWP-master,代码行数:35,代码来源:BitmapHelper.cs

示例9: LoadKeyFile

        /// <summary>
        /// Loads the specified key file.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// The <paramref name="input"/> parameter cannot be <c>null</c>.
        /// </exception>
        private static async Task<IBuffer> LoadKeyFile(IRandomAccessStream input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            var buffer = WindowsRuntimeBuffer.Create(1024);

            switch (input.Size)
            {
                case 32: // Binary key file
                    return await input.ReadAsync(buffer, 32);

                case 64: // Hex text key file
                    buffer = await input.ReadAsync(buffer, 64);
                    var hex = CryptographicBuffer.ConvertBinaryToString(
                        BinaryStringEncoding.Utf8, buffer);

                    if (IsHexString(hex))
                        return CryptographicBuffer.DecodeFromHexString(hex);
                    break;
            }

            // XML
            input.Seek(0);
            var xml = LoadXmlKeyFile(input);
            if (xml != null)
                return xml;

            // Random keyfile
            input.Seek(0);
            return await GetFileHash(input, buffer);
        }
开发者ID:Confuset,项目名称:7Pass-Remake,代码行数:40,代码来源:PasswordData.cs

示例10: ResizeStreamAsync

        private async Task<IRandomAccessStream> ResizeStreamAsync(IRandomAccessStream stream, Size size, PhotoOrientation orientation)
        {
            var rotation = 0;

            switch (orientation)
            {
                case PhotoOrientation.Rotate180:
                    {
                        rotation = -180;
                    };
                    break;

                case PhotoOrientation.Rotate270:
                    {
                        rotation = -270;
                    };
                    break;

                case PhotoOrientation.Rotate90:
                    {
                        rotation = -90;
                    };
                    break;
            }

            using (var resizedStream = new InMemoryRandomAccessStream())
            {
                var buffer = new byte[stream.Size].AsBuffer();

                stream.Seek(0);

                await stream.ReadAsync(buffer, buffer.Length, InputStreamOptions.None);

                var resizeConfiguration = new AutoResizeConfiguration(
                    (uint)(size.Width * size.Height * 4 * 2), size,
                    new Size(0, 0), AutoResizeMode.Automatic, 0.7, ColorSpace.Yuv420);

                buffer = await JpegTools.AutoResizeAsync(buffer, resizeConfiguration);

                await resizedStream.WriteAsync(buffer);
                await resizedStream.FlushAsync();

                if (rotation != 0)
                {
                    resizedStream.Seek(0);

                    var filters = new List<IFilter>() { new RotationFilter(rotation) };

                    using (var source = new RandomAccessStreamImageSource(resizedStream))
                    using (var effect = new FilterEffect(source) { Filters = filters })
                    using (var renderer = new JpegRenderer(effect))
                    {
                        buffer = await renderer.RenderAsync();

                        using (var rotatedResizedStream = new InMemoryRandomAccessStream())
                        {
                            await rotatedResizedStream.WriteAsync(buffer);
                            await rotatedResizedStream.FlushAsync();

                            return rotatedResizedStream.CloneStream();
                        }
                    }
                }
                else
                {
                    return resizedStream.CloneStream();
                }
            }
        }
开发者ID:roachhd,项目名称:filter-explorer,代码行数:69,代码来源:PhotoModel.cs

示例11: TryWriteStreamAsync

 public static async Task<bool> TryWriteStreamAsync(this StorageFile storageFile, IRandomAccessStream stream)
 {
     stream.Seek(0);
     IBuffer buffer = new byte[stream.Size].AsBuffer();
     await stream.ReadAsync(buffer, buffer.Length, InputStreamOptions.None);
     return await TryWriteBufferAsync(storageFile, buffer);
 }
开发者ID:chenjianwp,项目名称:UWP_ToolKit_CommonLibrary,代码行数:7,代码来源:StorageManagerEx.cs


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