| hi all how to use image from database in radgridview vb.net window application using telerik components . |
Loading
| hi all how to use image from database in radgridview vb.net window application using telerik components . |
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
danish jafferyPosted Oct 12, 2010, 2:31 PM
Here is the Code!
private static byte[] ConvertImageToByteArray(System.Drawing.Image imageToConvert,
ImageFormat formatOfImage)
{
byte[] Ret;
try
{
using (MemoryStream ms = new MemoryStream())
{
imageToConvert.Save(ms,formatOfImage);
Ret = ms.ToArray();
}
}
catch (Exception) { throw;}
return Ret;
}
When you are ready to convert the byte array back
to an image, you can include the following code
in your method.
System.Drawing.Image newImage;
using (MemoryStream ms = new MemoryStream(myByteArray,0,myByteArray.Length))
{
ms.Write(myByteArray,0,myByteArray.Length);
newImage = Image.FromStream(ms,true);
// work with image here.
// You'll need to keep the MemoryStream open for
// as long as you want to work with your new image.
}
If you need further help or Any Questions related to Telerik (C#.NET) you can email me [email protected],