There is a server application on pc on c # on sockets. There is a client application on wp following the example of msdn . It is necessary to transfer the image and output it in the wp application. I transfer the size, transfer the image by byte, the size when receiving matches. When you try to transfer to Bitmapimage, the application crashes. Checked on the client-pc, the image is obtained and output. Output byte-by-byte on wp and on the server, the figure is the same in the figure. The problem is in the translation byte [] in Bitmapimage. Took the standard picture / Assets/BadgeLogo.png. In the application translated into byte [], then back, everything works. That is, the method is correct, but does not work with data from the server. I copied the same standard image to the server, displayed it byte-by-byte and compared it with the output in the application. Various. Apparently, bitmap and bitmapimage represent the image differently? The beginning, as I suspect, is responsible for the extension and therefore coincides. I don’t know what to do next, I tried different ways to represent a bitmap in byte [], the result is the same everywhere and results in application crashes. Like a Bitmap or Image on a server on a regular c #, transfer it to a Windows Phone 8.1 application in a silverlight in BitmapImage, from a server to customer?

in the application I use:

public static BitmapImage BytesToImage(byte[] bytes) { BitmapImage bitmapImage = new BitmapImage(); try { using (MemoryStream ms = new MemoryStream(bytes)) { bitmapImage.SetSource(ms); return bitmapImage; } } finally { bitmapImage = null; } } 

on server:

  public byte[] imageToByteArray(System.Drawing.Image imageIn) { MemoryStream ms = new MemoryStream(); imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png); return ms.ToArray(); } 

    0