Hi!
I have been playing around with developing WP8 apps, and noticed I can through an API save contacts to the Peoples Hub programmatically.
I found an example on a website that looks like this:
In this example, photo is of type stream.
My issue is that I have the photo as an Image type created using an urisource. I have spent the past hours trying to get a stream from this property, but with no luck. This my first vb.net project, so I have done all my tests using C#, figured I would translate it to vb.net once I figured it out.
I came up with this code:
But it doesn't work. I do a quickwatch on both the ms and the wb objects, and there is definetly data there. But it won't show up in the app.
I got the original idea from:
http://christian-helle.blogspot.mx/
but on that blog there is not an actual working example, just some made up code with the photo as a member variable of type Stream.
Does anyone have an idea on how to get this working? As far as I understand it, an object of type BitmapImage with urisource doesn't hold the actual byte array which represents the image, but it is evaluated at runtime, right?
Help!
_/S
I have been playing around with developing WP8 apps, and noticed I can through an API save contacts to the Peoples Hub programmatically.
I found an example on a website that looks like this:
Code:
if (photo != null)
await contact.SetDisplayPictureAsync(photo.AsInputStream());
My issue is that I have the photo as an Image type created using an urisource. I have spent the past hours trying to get a stream from this property, but with no luck. This my first vb.net project, so I have done all my tests using C#, figured I would translate it to vb.net once I figured it out.
I came up with this code:
Code:
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmap wb = new WriteableBitmap(Picture);
wb.SaveJpeg(ms, 200, 200, 0, 80);
await contact.SetDisplayPictureAsync(ms.AsInputStream());
}
I got the original idea from:
http://christian-helle.blogspot.mx/
but on that blog there is not an actual working example, just some made up code with the photo as a member variable of type Stream.
Does anyone have an idea on how to get this working? As far as I understand it, an object of type BitmapImage with urisource doesn't hold the actual byte array which represents the image, but it is evaluated at runtime, right?
Help!
_/S