Click here to Skip to main content
15,889,852 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please Help me With this Problem..
Posted
Comments
EasyHero 3-Feb-15 5:27am    
you have to describe exactly what you want to achieve and place sample code for further illustration
Tomas Takac 3-Feb-15 5:39am    
Not clear - improve your question. BTW have a look on the Image[^] class.

1 solution

yes you can do like this


below code will convert image in byte array
C#
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
 MemoryStream ms = new MemoryStream();
 imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
 return  ms.ToArray();
}


and you can convert back byte array to image by below function

C#
public Image byteArrayToImage(byte[] byteArrayIn)
{
     MemoryStream ms = new MemoryStream(byteArrayIn);
     Image returnImage = Image.FromStream(ms);
     return returnImage;
}


So by converting image to byte array you can store your image in memory variable and than when you need image back you can convert byte array to image
 
Share this answer
 
v2

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