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


C# IRandomAccessStream.GetInputStreamAt方法代码示例

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


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

示例1: ConvertIRandomAccessStreamByte

 private static async Task<byte[]> ConvertIRandomAccessStreamByte(IRandomAccessStream stream)
 {
     DataReader read = new DataReader(stream.GetInputStreamAt(0));
     await read.LoadAsync((uint)stream.Size);
     byte[] temp = new byte[stream.Size];
     read.ReadBytes(temp);
     return temp;
 }
开发者ID:GuojieLin,项目名称:CnBlogs,代码行数:8,代码来源:ImageStorageHelper.cs

示例2: GetPhotoBits

 /// <summary>
 /// Returns a byte array with the content of the stream.
 /// </summary>
 /// <param name="stream">stream to get bytes for</param>
 /// <returns>awaitable byte array</returns>
 public static async Task<byte[]> GetPhotoBits(IRandomAccessStream stream)
 {
     Debug.Assert(stream != null, "GetPhotoBits should not be called with a null stream.");
     var reader = new DataReader(stream.GetInputStreamAt(0));
     var bytes = new byte[stream.Size];
     await reader.LoadAsync((uint)stream.Size);
     reader.ReadBytes(bytes);
     return bytes;
 }
开发者ID:fireelf,项目名称:Winuibuh,代码行数:14,代码来源:OcrClientUtils.cs

示例3: IRandomAccessStreamToByteArr

        public static async Task<byte[]> IRandomAccessStreamToByteArr(IRandomAccessStream irStream)
        {
            DataReader reader = new Windows.Storage.Streams.DataReader(irStream.GetInputStreamAt(0));
            await reader.LoadAsync((uint)irStream.Size);

            byte[] pixels = new byte[irStream.Size];
            reader.ReadBytes(pixels);

            return pixels;
        }
开发者ID:yjlintw,项目名称:YJToolkit,代码行数:10,代码来源:FileConvert.cs

示例4: SaveVideo

 private async Task SaveVideo(IRandomAccessStream videoStream)
 {
     StorageFile videoFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("MyCam.mp4");
     using (DataReader reader = new DataReader(videoStream.GetInputStreamAt(0)))
     {
         await reader.LoadAsync((uint)videoStream.Size);
         byte[] data = new byte[(int)videoStream.Size];
         reader.ReadBytes(data);
         await FileIO.WriteBytesAsync(videoFile, data);
     }
 }
开发者ID:krishnan-unni,项目名称:FFMPEGHelper,代码行数:11,代码来源:VideoProcessing.xaml.cs

示例5: RandomAccessStreamToBytes

 internal static byte[] RandomAccessStreamToBytes(IRandomAccessStream randomstream)
 {
     Stream stream = randomstream.GetInputStreamAt(0).AsStreamForRead();
     var memoryStream = new MemoryStream();
     if (stream != null)
     {
         return StreamToBytes(stream);
     }
     else
     {
         return null;
     }
 }
开发者ID:chenrensong,项目名称:ImageLib.UWP,代码行数:13,代码来源:Extensions.cs

示例6: streamToString

        //stream to base64
        public static async Task<string> streamToString(IRandomAccessStream fileStream)
        {
            string Base64String = "";
            var reader = new DataReader(fileStream.GetInputStreamAt(0));
            await reader.LoadAsync((uint)fileStream.Size);
            byte[] byteArray = new byte[fileStream.Size];
            reader.ReadBytes(byteArray);
            Base64String = Convert.ToBase64String(byteArray);
            //string s = ByteToString(byteArray);

            return Base64String;


        }
开发者ID:im16,项目名称:I-m-imaginecup2016-,代码行数:15,代码来源:Convert_module.cs

示例7: ImageInitialize

        public async Task<byte[]> ImageInitialize(IRandomAccessStream stream)
        {
           

                var size = stream.Size;

                 byte[] bytes = new byte[size];
            
                var reader = new DataReader(stream.GetInputStreamAt(0));
                await reader.LoadAsync((uint)size);
                reader.ReadBytes(bytes);
                return bytes;
            
        }
开发者ID:garicchi,项目名称:Neuronia,代码行数:14,代码来源:SettingData.cs

示例8: Play

        private async Task Play(IRandomAccessStream buffer)
        {
            if (buffer == null)
                throw new ArgumentNullException("buffer");

            var storageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;

            if (!string.IsNullOrEmpty(_fileName))
            {
                var oldFile = await storageFolder.GetFileAsync(_fileName);
                await oldFile.DeleteAsync();
            }

            await Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                async () =>
                {
                    var storageFile = await storageFolder.CreateFileAsync(AudioFileName, CreationCollisionOption.GenerateUniqueName);

                    _fileName = storageFile.Name;

                    using (var fileStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        await RandomAccessStream.CopyAndCloseAsync(
                            buffer.GetInputStreamAt(0),
                            fileStream.GetOutputStreamAt(0));

                        await buffer.FlushAsync();
                        buffer.Dispose();
                    }

                    var stream = await storageFile.OpenAsync(FileAccessMode.Read);
                    playBack.SetSource(stream, storageFile.FileType);

                    playBack.Play();
                });
        }
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:37,代码来源:Audio.xaml.cs

示例9: UnprotectPDFStream

        public static async Task<IRandomAccessStream> UnprotectPDFStream(IRandomAccessStream source)
        {
            // Create a DataProtectionProvider object.
            DataProtectionProvider Provider = new DataProtectionProvider();

            InMemoryRandomAccessStream unprotectedData = new InMemoryRandomAccessStream();
            IOutputStream dest = unprotectedData.GetOutputStreamAt(0);

            await Provider.UnprotectStreamAsync(source.GetInputStreamAt(0), dest);
            await unprotectedData.FlushAsync();
            unprotectedData.Seek(0);

            return unprotectedData;
        }
开发者ID:modulexcite,项目名称:windows8,代码行数:14,代码来源:DownloadManager.cs

示例10: ProtectPDFStream

        public static async Task<IRandomAccessStream> ProtectPDFStream(IRandomAccessStream source)
        {
            // Create a DataProtectionProvider object for the specified descriptor.
            DataProtectionProvider Provider = new DataProtectionProvider("LOCAL=user");

            InMemoryRandomAccessStream protectedData = new InMemoryRandomAccessStream();
            IOutputStream dest = protectedData.GetOutputStreamAt(0);

            await Provider.ProtectStreamAsync(source.GetInputStreamAt(0), dest);
            await dest.FlushAsync();

            //Verify that the protected data does not match the original
            //DataReader reader1 = new DataReader(source.GetInputStreamAt(0));
            //DataReader reader2 = new DataReader(protectedData.GetInputStreamAt(0));
            //var size1 = await reader1.LoadAsync((uint)(source.Size < 10000 ? source.Size : 10000));
            //var size2 = await reader2.LoadAsync((uint)(protectedData.Size < 10000 ? protectedData.Size : 10000));
            //IBuffer buffOriginalData = reader1.ReadBuffer((uint)size1);
            //IBuffer buffProtectedData = reader2.ReadBuffer((uint)size2);

            //if (CryptographicBuffer.Compare(buffOriginalData, buffProtectedData))
            //{
            //    throw new Exception("ProtectPDFStream returned unprotected data");
            //}

            //protectedData.Seek(0);
            //await protectedData.FlushAsync();

            // Return the encrypted data.
            return protectedData;
        }
开发者ID:modulexcite,项目名称:windows8,代码行数:30,代码来源:DownloadManager.cs

示例11: GetStringFromStream

 public static async Task<string> GetStringFromStream(IRandomAccessStream stream)
 {
     using (var dataReader = new DataReader(stream.GetInputStreamAt(0)))
     {
         var size = await dataReader.LoadAsync((uint)stream.Size);
         return dataReader.ReadString(size);
     }
 }
开发者ID:modulexcite,项目名称:windows8,代码行数:8,代码来源:DownloadManager.cs

示例12: StoreToFolderAsync

        public static async Task<StorageFile> StoreToFolderAsync(string fullName, StorageFolder folder, IRandomAccessStream inputStream, CancellationToken cancelToken = default(CancellationToken))
        {
            if (fullName == "") return null;

            var file = await folder.CreateFileAsync(fullName, CreationCollisionOption.ReplaceExisting);

            using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                await RandomAccessStream.CopyAndCloseAsync(inputStream.GetInputStreamAt(0), stream.GetOutputStreamAt(0)).AsTask(cancelToken);
            }

            return file;
        }
开发者ID:modulexcite,项目名称:windows8,代码行数:13,代码来源:DownloadManager.cs

示例13: GetStreamToBytesAsync

 // ToDo refactor please if EncodeHelper is not the apropiate place
 public static async Task<byte[]> GetStreamToBytesAsync(IRandomAccessStream fileStream)
 {
     using (DataReader reader = new DataReader(fileStream.GetInputStreamAt(0)))
     {
         await reader.LoadAsync((uint)fileStream.Size);
         byte[] pixeByte = new byte[fileStream.Size];
         reader.ReadBytes(pixeByte);
         return pixeByte;
     }
 }
开发者ID:GeekyTheory,项目名称:GeekyTool,代码行数:11,代码来源:EncodeHelper.cs

示例14: GetBytesFromStream

 public async Task<byte[]> GetBytesFromStream(IRandomAccessStream randomStream)
 {
     var reader = new DataReader(randomStream.GetInputStreamAt(0));
     var bytes = new byte[randomStream.Size];
     await reader.LoadAsync((uint)randomStream.Size);
     reader.ReadBytes(bytes);
     return bytes;
 }
开发者ID:Romaxaqaz,项目名称:Onliner,代码行数:8,代码来源:ParsingNewsSection.cs

示例15: ConvertImagetoByte

 /// <summary>
 /// Convert ImageObject to Byte Array
 /// </summary>
 /// <param name="fileStream">IRandomAccessStream</param>
 /// <returns>Byte Array</returns>
 public static async Task<byte[]> ConvertImagetoByte(IRandomAccessStream fileStream)
 {
     var reader = new DataReader(fileStream.GetInputStreamAt(0));
     await reader.LoadAsync((uint)fileStream.Size);
     byte[] pixels = new byte[fileStream.Size];
     reader.ReadBytes(pixels);
     return pixels;
 }
开发者ID:liqinghuang,项目名称:UWP-Helpers,代码行数:13,代码来源:Utils.cs


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