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

Discussion in 'C#' started by ranjeetsingh_6, Apr 27, 2007.

  1. ranjeetsingh_6

    ranjeetsingh_6 New Member

    Joined:
    Apr 27, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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:-
    Code:
    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);
    }
     
    Last edited by a moderator: Apr 27, 2007

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice