Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have tried to convert but i cant...

What I have tried:

Stream stream = new MemoryStream();
                        myImage.Save(stream, ImageFormat.Bmp);
                        result = stream;
Posted
Updated 16-Jan-18 22:56pm
Comments
F-ES Sitecore 17-Jan-18 4:51am    
There is nothing wrong with the code you posted, the problem is in the greater context you're trying to get the working in and the large bits of information you are not supplying, such as what is "stream"? What is "result"? What is the ultimate aim of this code?

Your code saves an image to a stream in bitmap format.

To convert a stream containing a supported image type to a bitmap, use the Image.FromStream Method (System.Drawing)[^]:
C#
using (Image image = Image.FromStream(stream))
{
    // Upon success image contains the bitmap
    //  and can be saved to a file:
    image.Save(fileName);
}
 
Share this answer
 
The solution given is in VB.Please use C# equivalent.

Bitmap to Memory Stream and Vice Versa[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900