I want to convert byte array to bitmap. I get this byte array from capture card. Rgb24 data include for this array. When i convert this array to bitmap object i got the "Parameter is not valid" error.
This is my byte array
myByteArray{byte[921600]}
MemoryStream mStream = new MemoryStream(myByteArray);
Bitmap bi = new Bitmap(mStream );
and
using (MemoryStream mStream = new MemoryStream(myByteArray))
{
Bitmap bi = (Bitmap)System.Drawing.Image.FromStream(mStream );
}
and
using (MemoryStream mStream = new MemoryStream())
{
mStream.Write(myByteArray, 0, myByteArray.Length);
mStream.Seek(0, SeekOrigin.Begin);
Bitmap bm = new Bitmap(mStream);
return bm;
}
Is this happen because of the size of the array? Can any one give a method to do this task? It will be greatly appreciated.
thank you
myByteArrayis neither aSystem.Drawing.Imagenor aSystem.Drawing.Bitmap. You have to convert it into one.myByteArray{byte[921600]}isn't valid C#. What is your actualbyte[]initialization? And there's noFromImage()method inSystem.Drawing.Image. If you show invalid code, you're only going to get useless answers.public static int ShowPIP(VIDEO_SAMPLE_INFO VideoInfo, IntPtr ptData, int lLength, long tRefTime, int lUserData) { byte[] bData = new byte[lLength]; Marshal.Copy(ptData, bData, 0, lLength); m_ShowPipForm.ShowPIP(VideoInfo, myByteArray); return 1; }