Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi all. This is the first time I'm working with the fingerprint scanner myself. I believe it kinda works the same as all the others, it reads your fingerprint into a byte array, then I need to convert it to a system image to put it into a picturebox, or save it on a harddrive as a jpg.

I'm getting the error "Parameter is not valid." When I am trying to convert to image. Obviously I'm doing something wrong, and I'm not quite sure what. Can someone please help me in the right direction?

 

Public Declare Function AET60_Capture Lib "AET60.dll" (ByRef Template As Byte, ByRef TemplateLength As Integer, ByVal TimeOut As Integer) As Integer

Public iRetcode As Integer

Private Sub sbCaptureFingerprint()

Try 
  Dim iProcTimeOut As Integer
  Dim iFpTemplateLength As Integer
  Dim tmpTemplate(0 To 767) As Byte

  iProcTimeOut = 60000
  iFpTemplateLength = 768

  Dim imgByte(0 To 767) As Byte

  iRetcode = AET60_Capture(imgByte(0), iFpTemplateLength, iProcTimeOut)

  PictureBox1.Image = fConvertTo(imgByte)

Catch ex As Exception
  MsgBox(Err.Description, MsgBoxStyle.Critical, "Saving Image")
End Try

End Sub

Public Overloads Function fConvertTo(ByVal ImageArray As Byte()) As System.Drawing.Image

Dim objMS As New System.IO.MemoryStream

  objMS.Write(ImageArray, 0, ImageArray.Length)

Try

   'and this is where I get the error
  fConvertTo = System.Drawing.Image.FromStream(objMS)

Catch ae As System.ArgumentException

  fConvertTo = Nothing

End Try

End Function

Edited by JohanPrinsloo
Posted

All other info there is:

 

?Err.Description

"Parameter is not valid."

 

and

 

?ae.GetBaseException

{"Parameter is not valid."}

System.ArgumentException: {"Parameter is not valid."}

Data: {System.Collections.ListDictionaryInternal}

HelpLink: Nothing

InnerException: Nothing

Message: "Parameter is not valid."

Source: "System.Drawing"

StackTrace: " at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) at System.Drawing.Image.FromStream(Stream stream) at SCARD_AUTH.frmSplash.fConvertTo(Byte[] ImageArray)"

TargetSite: {System.Reflection.RuntimeMethodInfo}

 

To answer you second quostion, no it is still far from a jpg. I am trying to convert it into a jpg. The fingerprintreader reads the fingerprint into the following var Dim imgByte(0 To 767) As Byte, and from there I am trying to convert it to a jpg.

Posted
What image format is the data in the byte array?

 

:confused:

 

That is exactly what I'm trying to do. It's not yet in a specific format. All that I can see is a few numbers. Even in the function fConvertTo in the line

 

objMS.Write(ImageArray, 0, ImageArray.Length)

 

There is still something inside ImageArray. It depends which finger, ImageArray = {4,0,0,1,1.....}

Posted

I also tried the following with the same results:

The error also appear at System.Drawing.Image.FromStream.

What am I doing wrong? What am I missing here?

 

iRetcode = AET60_Capture(imgByte(0), iFpTemplateLength, iProcTimeOut)

 

Dim image As Byte() = imgByte

Dim memStream As MemoryStream = New MemoryStream(image)

Dim bitImage As Bitmap = New Bitmap(System.Drawing.Image.FromStream(memStream))

 

bitImage.Save("C:\test.bmp")

  • Administrators
Posted

Does the documentation that comes (Assuming any did) indicate what format the data is returned in? Without knowing a bit more about the actual data returned it is going to be difficult to know what to do with the data to get any image format. IIRC the .Net Image classes expect the data to be one of a limited number of formats - if this function isn't returning the data in one of these you will get problems.

 

Is the file at http://www.acs.com.hk/download/API_AET60.pdf the documentation for this device / library? If so it seems to indicate the format of the AET60_BITMAP structure in section 1.3.2. Is that correct?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Hi, should I use the following perhaps? But how? I am a bit lost...

 

Public Declare Function AET60_ConvertBitmap Lib "AET60.dll" (ByRef SampleBuffer As FBITMAP, ByRef Length As Integer, ByRef bitData As Byte) As Integer

 

Public Structure FBITMAP

Dim Width As Integer

Dim Height As Integer

Dim Bitmap As fDataStructure

End Structure

 

Public Structure fDataStructure

Dim Length As Integer

Dim Data() As Byte

End Structure

  • Administrators
Posted (edited)

It looks as though that should populate the SampleBuffer with the data for the bitmap. From the documentation it looks as though the Data() is simply each byte of the image - not sure what the byte values mean though....

 

EDIT: If it is a DIB (which the pdf seems to indicate) then http://www.codeproject.com/KB/GDI-plus/DIBtoBitmap.aspx is probably worth a read as it should get the image into a BMP and from there you can do whatever you want with it.

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...