I found how to do this in .NET 4.0, but I think that JpegBitmapEncoder does not exist in Silverlight:
MemoryStream memStream = new MemoryStream();
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(imageC));
encoder.Save(memStream);
var bytes = memStream.GetBuffer();
How to convert image to bytes [] in silverlight?
UPDATE:
I have a Contact model that has a Photo property. Whenever I add a new contact, I would like to load the local default image and convert it and set the Photo property for it.
var bitmapImage = new BitmapImage
{
UriSource = new Uri("pack://application:,,,/xxx;component/Images/default.JPG")
};
var image = new Image{Source = bitmapImage};
Is this the right way to load an image first?
source
share