I can convert byte [] to image:
byte[] myByteArray = ...; // ByteArray to be converted MemoryStream ms = new MemoryStream(my); BitmapImage bi = new BitmapImage(); bi.SetSource(ms); Image img = new Image(); img.Source = bi;
But I canβt convert the image back to byte []! I found on the Internet a solution that works for WPF:
var bmp = img.Source as BitmapImage; int height = bmp.PixelHeight; int width = bmp.PixelWidth; int stride = width * ((bmp.Format.BitsPerPixel + 7) / 8); byte[] bits = new byte[height * stride]; bmp.CopyPixels(bits, stride, 0);
The Silverlight library is so small that the BitmapImage class does not have a property called Format!
Is there an idea that solves my problem.
I searched the Internet for a long time to find a solution, but there is no solution that works in silverlight!
Thanks!
silverlight
Sperl christoph
source share