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


C# InMemoryRandomAccessStream.GetOutputStreamAt方法代码示例

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


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

示例1: GetImageSize

 public async static void GetImageSize(this Stream imageStream)
 {
     var image = new BitmapImage();
     byte[] imageBytes = Convert.FromBase64String(imageStream.ToBase64String());
     MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
     ms.Write(imageBytes, 0, imageBytes.Length);
     using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
     {
         using (DataWriter writer = new DataWriter(stream.GetOutputStreamAt(0)))
         {
             try
             {
                 writer.WriteBytes(imageBytes);
                 await writer.StoreAsync();
             }
             catch (Exception)
             {
                 // ignored
             }
         }
         try
         {
             await image.SetSourceAsync(stream);
         }
         catch (Exception)
         {
             // ignored
         }
     }
     ImageSize = new Size(image.PixelWidth, image.PixelHeight);
 }
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:31,代码来源:ImageExtensions.cs

示例2: GetBijinPicture

        public async Task<BitmapImage> GetBijinPicture(string Path)
        {
            var date = DateTime.Now;
            var url = "http://www.bijint.com/" + Path + "/tokei_images/" + date.ToString("HHmm") + ".jpg";

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Referrer = new Uri("http://www.bijint.com/" + Path);
            BitmapImage bitmap;
            using (var strm = await client.GetStreamAsync(new Uri(url)))
            {
                // BitmapImageインスタンスへはStream型をそのまま読み込ませることができないため、
                // InMemoryRandomAccessStreamへソースストリームをコピーする
                InMemoryRandomAccessStream ims = new InMemoryRandomAccessStream();
                var output = ims.GetOutputStreamAt(0);
                await RandomAccessStream.CopyAsync(strm.AsInputStream(), output);

                // BitmapImageへソースを設定し、Imageコントロールで表示させる
                bitmap = new BitmapImage();
                bitmap.SetSource(ims);
            }
            return bitmap;

            //var html = await client.GetStringAsync("http://www.bijint.com/kobe/cache/" + date.ToString("HHmm") + ".html");
            //this.html.NavigateToString(html);
        }
开发者ID:posaunehm,项目名称:MyBeautyClock,代码行数:25,代码来源:BeautyDataFactory.cs

示例3: Convert

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value != null && value is byte[])
            {

                //WriteableBitmap bitmap = new WriteableBitmap(100, 100);

                //System.IO.Stream bitmapStream = null;
                //bitmapStream = bitmap.PixelBuffer.AsStream();
                //bitmapStream.Position = 0;
                //bitmapStream.Write(value as byte[], 0, (value as byte[]).Length);

                //bitmapStream.Flush();

                InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();
                DataWriter writer = new DataWriter(randomAccessStream.GetOutputStreamAt(0));
                writer.WriteBytes(value as byte[]);
                var x = writer.StoreAsync().AsTask().Result;
                BitmapImage image = new BitmapImage();
                image.SetSource(randomAccessStream);

                return image;
            }

            return null;
        }
开发者ID:garymedina,项目名称:MyEvents,代码行数:26,代码来源:ByteToImageConverter.cs

示例4: AsRandomAccessStreamAsync

        public async static Task<IRandomAccessStream> AsRandomAccessStreamAsync(this Stream stream)
        {
            Stream streamToConvert = null;

            if (!stream.CanRead)
            {
                throw new Exception("Cannot read the source stream-");
            }
            if (!stream.CanSeek)
            {
                MemoryStream memoryStream = new MemoryStream();
                await stream.CopyToAsync(memoryStream);
                streamToConvert = memoryStream;
            }
            else
            {
                streamToConvert = stream;
            }

            DataReader dataReader = new DataReader(streamToConvert.AsInputStream());
            streamToConvert.Position = 0;
            await dataReader.LoadAsync((uint)streamToConvert.Length);
            IBuffer buffer = dataReader.ReadBuffer((uint)streamToConvert.Length);

            InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();
            IOutputStream outputstream = randomAccessStream.GetOutputStreamAt(0);
            await outputstream.WriteAsync(buffer);
            await outputstream.FlushAsync();

            return randomAccessStream;
        }
开发者ID:uwe-e,项目名称:BSE.Tunes,代码行数:31,代码来源:StreamExtensions.cs

示例5: GetBijinPicture

        private async void GetBijinPicture()
        {
            var date = DateTime.Now;
            var url = "http://www.bijint.com/jp/tokei_images/" + date.ToString("HHmm") + ".jpg";

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Referrer = new Uri("http://www.bijint.com/jp/");
            using (var strm = await client.GetStreamAsync(new Uri(url)))
            {
                // BitmapImageインスタンスへはStream型をそのまま読み込ませることができないため、
                // InMemoryRandomAccessStreamへソースストリームをコピーする
                InMemoryRandomAccessStream ims = new InMemoryRandomAccessStream();
                var output = ims.GetOutputStreamAt(0);
                await RandomAccessStream.CopyAsync(strm.AsInputStream(), output);

                // BitmapImageへソースを設定し、Imageコントロールで表示させる
                var bitmap = new BitmapImage();
                bitmap.SetSource(ims);
                image.Source = bitmap;

                // Save用にbyte配列に保存
                ims.Seek(0);
                imageBuffer = new byte[ims.Size];
                IBuffer ibuffer = imageBuffer.AsBuffer();
                await ims.ReadAsync(ibuffer, (uint)ims.Size, InputStreamOptions.None);
            }
        }
开发者ID:KarinoTaro,项目名称:MetroDokei,代码行数:27,代码来源:MainPage.xaml.cs

示例6: ConvertToRandomAccessStream

        public static async Task<IRandomAccessStream> ConvertToRandomAccessStream(Stream source)
        {
            Stream streamToConvert = null;
            
            if (!source.CanRead)
                throw new Exception("The source cannot be read.");

            if (!source.CanSeek)
            {
                var memStream = new MemoryStream();
                await source.CopyToAsync(memStream);
                streamToConvert = memStream;
            }
            else
            {
                streamToConvert = source;
            }

            var reader = new DataReader(streamToConvert.AsInputStream());
            streamToConvert.Position = 0;
            await reader.LoadAsync((uint) streamToConvert.Length);
            var buffer = reader.ReadBuffer((uint) streamToConvert.Length);

            var randomAccessStream = new InMemoryRandomAccessStream();
            var outputStream = randomAccessStream.GetOutputStreamAt(0);
            await outputStream.WriteAsync(buffer);
            await outputStream.FlushAsync();

            return randomAccessStream;
        }
开发者ID:bendewey,项目名称:LeadPro,代码行数:30,代码来源:ImageStreamConverter.cs

示例7: Convert

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (!(value is byte[]))
            {
                return null;
            }

            using (InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream())
            {
                // Writes the image byte array in an InMemoryRandomAccessStream
                // that is needed to set the source of BitmapImage.
                using (DataWriter writer = new DataWriter(ms.GetOutputStreamAt(0)))
                {
                    writer.WriteBytes((byte[])value);

                    // The GetResults here forces to wait until the operation completes
                    // (i.e., it is executed synchronously), so this call can block the UI.
                    writer.StoreAsync().GetResults();
                }

                var image = new BitmapImage();
                image.SetSource(ms);
                return image;
            }
        }
开发者ID:famoser,项目名称:OfflineMedia,代码行数:25,代码来源:ByteToBitmapConverter.cs

示例8: Convert

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value != null)
            {

                byte[] bytes = (byte[])value;
                BitmapImage myBitmapImage = new BitmapImage();
                if (bytes.Count() > 0)
                {


                    InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();
                    DataWriter writer = new DataWriter(stream.GetOutputStreamAt(0));

                    writer.WriteBytes(bytes);
                    writer.StoreAsync().GetResults();
                    myBitmapImage.SetSource(stream);
                }
                else
                {
                    myBitmapImage.UriSource = new Uri("ms-appx:///Assets/firstBackgroundImage.jpg");
                }

                return myBitmapImage;
            }
            else
            {
                return new BitmapImage();
            }
        }
开发者ID:garicchi,项目名称:Neuronia,代码行数:30,代码来源:ByteToBitmapConverterForBackground.cs

示例9: GetBijinInfo

        // TODO: 一分ごとに画像と名前を取得する
        private async void GetBijinInfo()
        {
            var date = this.Current;
            getKawaii(this.path + this.Current.ToString("HHmm"));
            var url = "http://www.bijint.com/" + Path + "/tokei_images/" + date.ToString("HHmm") + ".jpg";

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Referrer = new Uri("http://www.bijint.com/" + path);
            using (var strm = await client.GetStreamAsync(new Uri(url)))
            {
                // BitmapImageインスタンスへはStream型をそのまま読み込ませることができないため、
                // InMemoryRandomAccessStreamへソースストリームをコピーする

                InMemoryRandomAccessStream ims = new InMemoryRandomAccessStream();
                
                var output = ims.GetOutputStreamAt(0);
                await RandomAccessStream.CopyAsync(strm.AsInputStream(), output);

                // BitmapImageへソースを設定し、Imageコントロールで表示させる
                var bitmap = new BitmapImage();
                bitmap.SetSource(ims);
                this.Image = bitmap;
            }

            var html = await client.GetStringAsync("http://www.bijint.com/" + Path + "/cache/" + date.ToString("HHmm") + ".html");
            var lines = html.Split('\n').Select(input => input.Trim()).Where(input => input != "\r" || input != "").ToList();
            var nameLineIndex = lines.IndexOf("<thead>") + 2;
            var nameLine = lines[nameLineIndex];
            var temp = nameLine.Substring(0, nameLine.Length - 5);
            var lastEnd = temp.LastIndexOf('>');
            this.Subtitle = temp.Substring(lastEnd + 1);


        }
开发者ID:posaunehm,项目名称:MyBeautyClock,代码行数:35,代码来源:SampleDataItem.cs

示例10: Update

        private async void Update()
        {
            var writer1 = new BarcodeWriter
            {
                Format = BarcodeFormat.QR_CODE,
                Options = new ZXing.Common.EncodingOptions
                {
                    Height = 200,
                    Width = 200
                },

            };

            var image = writer1.Write(Text);//Write(text);


            using (InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream())
            {
                using (DataWriter writer = new DataWriter(ms.GetOutputStreamAt(0)))
                {
                    writer.WriteBytes(image);
                    await writer.StoreAsync();
                }

                var output = new BitmapImage();
                await output.SetSourceAsync(ms);
                ImageSource = output;
            }


        }
开发者ID:smndtrl,项目名称:Signal-UWP,代码行数:31,代码来源:QrCode.xaml.cs

示例11: Stream2IRandomAccessStream

 public async Task<IRandomAccessStream> Stream2IRandomAccessStream(byte[] bytes)
 {
     InMemoryRandomAccessStream memoryStream = new InMemoryRandomAccessStream();
     DataWriter datawriter = new DataWriter(memoryStream.GetOutputStreamAt(0));
     datawriter.WriteBytes(bytes);
     await datawriter.StoreAsync();
     return memoryStream;
 }
开发者ID:haoas,项目名称:Wp8.1WeiXinAssistant,代码行数:8,代码来源:StreamConvent.cs

示例12: ColorThread

		private async void ColorThread()
		{
			try
			{
                var reader = new DataReader( Client.InputStream );
                reader.InputStreamOptions = InputStreamOptions.Partial;
                reader.ByteOrder = ByteOrder.LittleEndian;

                while ( IsConnected ) {
                    await reader.LoadAsync( 4 );
                    var size = reader.ReadUInt32();

                    await reader.LoadAsync( size );
                    byte[] bytes = new byte[size];
                    reader.ReadBytes( bytes );

                    MemoryStream ms = new MemoryStream( bytes );
					BinaryReader br = new BinaryReader(ms);

                    ColorFrameReadyEventArgs args = new ColorFrameReadyEventArgs();
                    ColorFrameData cfd = new ColorFrameData();

                    cfd.Format = (ImageFormat)br.ReadInt32();
					cfd.ImageFrame = br.ReadColorImageFrame();

                    MemoryStream msData = new MemoryStream( bytes, (int)ms.Position, (int)(ms.Length - ms.Position) );
                    if (cfd.Format == ImageFormat.Raw)
                    {
                        cfd.RawImage = ms.ToArray();
                    }
                    else
                    {
                        InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
                        DataWriter dw = new DataWriter(ras.GetOutputStreamAt(0));
                        dw.WriteBytes(msData.ToArray());
                        await dw.StoreAsync();   

                        // Set to the image
                        BitmapImage bImg = new BitmapImage();
                        bImg.SetSource(ras);
                        cfd.BitmapImage = bImg;
                    }

					ColorFrame = cfd;
					args.ColorFrame = cfd;

                    if (ColorFrameReady != null)
                    {
                        ColorFrameReady(this, args);
                    }
				}
			}
			catch(IOException)
			{
				Disconnect();
			}
		}
开发者ID:kaorun55,项目名称:KinectService,代码行数:57,代码来源:ColorClient.cs

示例13: AsInMemoryRandomAccessStream

 public static InMemoryRandomAccessStream AsInMemoryRandomAccessStream(byte[] data)
 {
     InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();
     using (DataWriter writer = new DataWriter(randomAccessStream.GetOutputStreamAt(0)))
     {
         writer.WriteBytes(data);
         writer.StoreAsync().GetResults();
     }
     return randomAccessStream;
 }
开发者ID:bytetrail,项目名称:Hexiverse,代码行数:10,代码来源:Adapters.cs

示例14: ConvertToRandomAccessStream

 public static async Task<IRandomAccessStream> ConvertToRandomAccessStream(MemoryStream memoryStream)
 {
     var randomAccessStream = new InMemoryRandomAccessStream();
     var outputStream = randomAccessStream.GetOutputStreamAt(0);
     var dw = new DataWriter(outputStream);
     var task = Task.Factory.StartNew(() => dw.WriteBytes(memoryStream.ToArray()));
     await task;
     await dw.StoreAsync();
     await outputStream.FlushAsync();
     return randomAccessStream;
 }
开发者ID:nhannguyen2204,项目名称:VnFeeds_Win8,代码行数:11,代码来源:BooleanNegationConverter.cs

示例15: DrawImage

        public void DrawImage(Point center, Size s, Byte[] img_bytes)
        {

            InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream();
            DataWriter writer = new DataWriter(ms.GetOutputStreamAt(0));
            writer.WriteBytes(img_bytes);
            writer.StoreAsync().GetResults();
            BitmapImage image = new BitmapImage();
            image.SetSource(ms);

            DrawImage(center, s, image);

        }
开发者ID:Leelow,项目名称:link.io.csharp.poc,代码行数:13,代码来源:CanvasInteraction.cs


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