This project has moved. For the latest updates, please go here.

Reading into MemoryStream c#

Mar 9, 2015 at 10:07 AM
I need to convert an image into different format and without saving that file, I need to download that file using Memorystream.


I got this code but not sure how to download it after writing into memory stream
Could you please help with the code?
                   var lowResolution = new MagickImage(image) { Quality = 100, Format = "png",      BackgroundColor = new MagickColor("#FFF") };
                    using (MemoryStream memStream = new MemoryStream())
                    {
                        lowResolution.Write(memStream);
                    }
Mar 9, 2015 at 10:54 AM
Edited Mar 9, 2015 at 4:36 PM
I found the solution for it.
Sorry I was not looked for the code in discussion forum before creating this thread
I am getting my required solution with below code
                  var lowResolution = new MagickImage(image) { 
                                                         Quality = 100, Format = "png",      
                                                           BackgroundColor = new               
                                                          MagickColor("#FFF") };
                        using (MemoryStream memStream = new MemoryStream())
                        {
                               lowResolution.Write(memStream);
                         }
                       // Read image from file
                        using (MagickImage output = new MagickImage(lowRez))
                        {
                            // Create byte array that contains a jpeg file
                             var result = new MemoryStream(output.ToByteArray());
                             return result;
                        }