المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to retrieve a MPG picture from DB or convert byte[] to MPG?



C# Programming
11-09-2009, 01:25 AM
I Found a lot of articles explained how to store and retrieve a image into /from DB.They are helpful.But I got a problem when i used the same way to deal with a MPG picture.
First,I upload a mpg picture ,convert it into byte[],and store it into my DB,until now ,it's working well.
Then,I just need to convert the byte[] back to a MPG picture,as follows:
byte[] b = (byte[])cmd.ExecuteScalar();
if(b.Length > 0)
{
System.IO.MemoryStream stream = new System.IO.MemoryStream(b, true);
stream.Write(b, 0, b.Length);
Bitmap bmp = new Bitmap(stream)//Exception is threw here
//using Image img = Image.FromStream(stream )is the same;
}
I have found out mpg was not included in ImageFormat.So,what type is mpg,and how can get it from byte[]?