Sunday, March 30, 2014

Saving a InMemoryAccessStream as jpg in Windows Store app

Hi,


The InMemoryRandomAccessStream has a method of GetInputStreamAt which can give you an IInputStream. And Windows.Storage.Stream also includes a DataReader class that you create based on an IInputStream object and then read numerous .NET objects from the stream as well as arrays of bytes.


http://ift.tt/1gRQyJL , http://ift.tt/WXVCkT



DataReader dataReader = new DataReader(inputStream);
await dataReader.LoadAsync((uint)size);
byte[] buffer = new byte[(int)size];
dataReader.ReadBytes(buffer);

Now you have a buffer containing all the read bytes. Then you can now save this buffer to a file http://ift.tt/1gRQz02



var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("MyWav.wav", Windows.Storage.CreationCollisionOption.ReplaceExisting);
await Windows.Storage.FileIO.WriteBytesAsync(file, buffer);

Best Wishes!






We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


No comments:

Post a Comment