Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 display image get From Biometric device in c#

Author  Topic 

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2007-04-26 : 07:27:57
Hi
Hi
I am working on Biomatric Solution Project.I am using SecuGen BSP Device for This purpose.Device return Fingure image data in string .I want to display this Fingure 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

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-26 : 08:30:27
This part:


//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++;
}


might be causing some issues; what datatype is szFIRTextData? A string? I am not sure that converting it to a char array, and then casting each char to a byte, will do the job for you. A char datatype is 16 bits.

see: http://zone.ni.com/devzone/cda/ph/p/id/4

It really doesn't make any sense at all to put binary image data as a string.

To typically convert a string to an array of bytes, you'd use an encoding, like this:

byte b[] = System.Text.Encoding.Unicode.GetBytes(yourstringhere);

You can give something like that a shot, but I still am not sure it will work for you.




- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-26 : 08:31:57
On a side note, since this is very technical and has absolutely nothing to do with databases, this is not really the place to be asking this type of question. You are much better off at a forum that specializes in C# or .NET.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2007-04-26 : 09:33:28
Hi
Since My Device return image data(Device Kept it in FIRFormate) into a string,Then i got image data in only this String.

How can i save and display the picture image through this string

Ranjeet Kumar Singh
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-04-26 : 09:48:25
This is a stab in the dark, but maybe it's what you want: a very common way to encode binary data in a string is base64. is your string base64 encoded? if so there are methods in C# for converting back to a byte array. have a look at System.Convert.FromBase64String()

I have never heard of FIRFormat. I googled it and came up with nothing but typos and some norwegian and danish pages.


www.elsasoft.org
Go to Top of Page

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2007-04-26 : 10:35:47
hi
you are right may be you never heard of FIRFormat because this is
depend on my Biomatric Device specefic.Can u tell me some good
C# forum site.

Ranjeet Kumar Singh
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-04-26 : 11:01:19
I like http://www.codeproject.com but I don't know if they have forums. Jeff may have some he likes.

I suggest you contact support for the maker of your device though. maybe the manufacturer has a forum?


www.elsasoft.org
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-26 : 11:09:09
Maybe try the MSDN forums ?

http://forums.microsoft.com/msdn/showforum.aspx?forumid=31&siteid=1

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

karuppaiya
Starting Member

2 Posts

Posted - 2011-08-24 : 10:25:20
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);
}
Go to Top of Page

karuppaiya
Starting Member

2 Posts

Posted - 2011-08-24 : 10:27:35
Please help me some one i want capture thumb image and display image format in image control how can i do .
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2011-08-24 : 11:56:56
What's this got to do with SQL Data? Please read the FAQ's before posting. There are more useful websites for stuff like this. Try StackOverflow.
Go to Top of Page
   

- Advertisement -