There might be some problem with type casting
Image.FromStream
return type is Image. try using that.
Bitmap is always an Image, but not every Image is a Bitmap
or u may use it in this way
For Convert you may use it:
static public Bitmap BitmapFromBitmapData(byte[] BitmapData)
{
MemoryStream ms = new MemoryStream(BitmapData);
return (new Bitmap(ms));
}
static public byte[] BitmapDataFromBitmap(Bitmap objBitmap, ImageFormat imageFormat)
{
MemoryStream ms = new MemoryStream();
objBitmap.Save(ms, imageFormat);
return (ms.GetBuffer());
}