I have a java server and a c# client.
I want to read an .png file on the server, convert it to an byte[], send it through the socket and then convert it back to an imagesource.
This is the java server to convert the image to a byte array:
BufferedImage originalImage = ImageIO.read(new File(ImageName));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write( originalImage, "png", baos );
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();
return imageInByte;
This is the C# client to convert the byte Array to an Image/Imagesource:
BitmapImage biImg = new BitmapImage();
MemoryStream ms = new MemoryStream(imageData);
biImg.BeginInit();
biImg.StreamSource = ms;
biImg.EndInit();
ImageSource imgSrc = biImg as ImageSource;
return imgSrc;
The problem is that i get a NotSupportetException on biImg.EndInit();