خرید بک لینک

Vote count: 0

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();
retu 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;
retu imgSrc;

The problem is that i get a NotSupportetException on biImg.EndInit();

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 21 فروردين 1395 ساعت: 15:51

صفحه بندی