display image on picture box control which got From Biometric device in c# (urgent)

Apr 26 2007 9:56 AM
Hi
I am working on Biomatric Solution Project.I am using SecuGen BSP Device for This purpose.Device return Finger image data in string .I want to display this Finger image into Picture Box Control. For This I kept The output string in Byte array and then i write it in Memory Stream and at last
create a bitmap to display image(at this stage i got error "Parameter is Not Valid")

Problem:-Code Give error when i create a bitmap to display image.
red line show the error point.The error syntax is
"Parameter is Not Valid".

My Code is:-

try
{
//Create Device API Interface object
SECUBSPCOMLib.APIInterface objSecuBSP = new SECUBSPCOMLib.APIInterface();
long deviceID;
objSecuBSP.EnumerateDevice();
//Open Device
objSecuBSP.OpenDevice(2);
string szFIRTextData;
objSecuBSP.Enroll(null);
//Get Data of Image(Fingure Print) into a string

szFIRTextData = objSecuBSP.FIRTextData;

//Get string into Stream Format means into Byte array from string
byte[] arrBytes = new byte[szFIRTextData.Length];
int i = 0;
foreach (char c in szFIRTextData.ToCharArray())
{
arrBytes[i] = (byte)c;
i++;
}
// Open a stream for the image and write the bytes into it
System.IO.MemoryStream memStream = new System.IO.MemoryStream(arrBytes, true);
memStream.Write(arrBytes, 0, arrBytes.Length);
// Create a bitmap from the stream for Display it on Picture Box Control
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(memStream);
pictureBox1.Image = bmp;
memStream.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

Ranjeet Kumar Singh

Answers (3)