StreamSocket to Stream in windows phone 8
Posted
by
Abouzar Nouri
on Stack Overflow
See other posts from Stack Overflow
or by Abouzar Nouri
Published on 2013-07-15T02:32:09Z
Indexed on
2014/06/13
15:25 UTC
Read the original article
Hit count: 178
I am trying to use Bluetooth in WP8 to send an image from my app on a device and show it in my app on another device. The receiver has a StreamSocket object to read the data from it like the code below
await _dataReader.LoadAsync(4);
uint messageLen = (uint)_dataReader.ReadInt32();
await _dataReader.LoadAsync(messageLen);
string imageData _dataReader.ReadString(messageLen);
Then I have to save all the received data (image) on the device and then create a Stream object from the stored data to give it to the BitmapSource.SetSource(Stream) function to be able to show this image on my app.
var image = new BitmapImage();
image.SetSource(stream);
All I want to do is not to skip this double work and directly convert the StreamSocket object (from Bluetooth connection) to a Stream object and make the BitmapSource image. Is there any way to do this?
© Stack Overflow or respective owner