I am making a remote desktop sharing application in which I take a desktop image and compress it and send it to the recipient. To compress the image, I need to convert it to byte [].
I am currently using this:
public byte[] imageToByteArray(System.Drawing.Image imageIn) { MemoryStream ms = new MemoryStream(); imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif); return ms.ToArray(); } public Image byteArrayToImage(byte[] byteArrayIn) { MemoryStream ms = new MemoryStream(byteArrayIn); Image returnImage = Image.FromStream(ms); return returnImage; }
But I donβt like it, because I have to save it in ImageFormat, and also use resources (Slow Down), and also create different compression results. I read about using Marshal.Copy and memcpy, but I can not understand them.
So, is there any other way to achieve this?
c # memory bytearray bitmap
user2529551 Jun 27 '13 at 19:54 2013-06-27 19:54
source share