DigitalPersona SDK C# code

C

Ceefour

In case anyone is wondering...

(this is based on a conversation with "Juan C. Santaella"
I'm sharing here so anyone won't have to go through what I went through
again)

To display the DigitalPersona sample in a .NET Windows Forms PictureBox
:

Anyways, I found an alternative way that doesn't use
VisualBasic.Compatibility. It turns out the Picture is a standard
IPicture OLE object supported by the legacy Platform SDK. I can draw
the picture to anything in .NET that has a HDC handle. In this case I
use a .NET PictureBox to contain the picture :

private void axFPGetSampleX1_Done_1(object sender,
AxDPSDKOPSLib._IFPGetSampleXEvents_DoneEvent e)
{
IFPSample sample = (IFPSample)e.pSample;
IPicture picture = (IPicture)sample.Picture;
textBox1.Text = picture.Width.ToString() + "-" +
picture.Height.ToString();
using (Graphics graphics = pictureBox1.CreateGraphics())
{
IntPtr hDc = graphics.GetHdc();
picture.Render(hDc.ToInt32(), 0, 0, pictureBox1.Width,
pictureBox1.Height,
0, 0, picture.Width, picture.Height, IntPtr.Zero);
}
}

It worked for the moment. Maybe it's not very correct as it uses the
PictureBox's Graphics/DeviceContext instead of the Image's
(PictureBox.Image) Graphics/DeviceContext. But anyway it works so I
can save it to a GIF, BMP, JPEG, or save it to database if I want to.
And it works universally (meaning you can use it with C#, J#, or any
other .NET language). Not that you have to add a reference to stdole
COM library (that should be automatic). IPicture is contained in the
stdole namespace.

I'm not sure if you need any of this info. Maybe I'll post this
somewhere on google groups or forums so that more people will be able
to use DigitalPersona and not trying to bash their heads off in a
wall. (which may lead to more competition, but no good deed goes
unpunished).
 
N

Nicholas Paldino [.NET/C# MVP]

I am curious, why the aversion to using the helper function in the
Microsoft.VisualBasic.Compatability namespace?
 
C

Ceefour

Nicholas said:
I am curious, why the aversion to using the helper function in the
Microsoft.VisualBasic.Compatability namespace?

I'm not sure. Maybe I personally like the more "general" way of doing
things.

- VisualBasic.Compatibility is easier to use (good)
- The VisualBasic.Compatibility way is too specific. Well it works for
converting the IPicture to a .NET Image. But maybe you want to inspect
the IPicture directly. Or maybe you're not working with IPicture, but
any other interface supported by Windows OLE/COM, etc. (not specific to
this DigitalPersona case)
- I'm not sure, but I can't find VisualBasic.Compatibility in my VS
2005 documentation (though the .dll assembly exists)
- It requires additional reference to VisualBasic.Compatibility
assembly. Not really a minus, though. Using IPicture would just mean we
need a reference to stdole COM dll, which is probably a requirement
anyway if you do interop with most COM dlls.
- I'm also not sure, but I think VisualBasic.Compatibility ultimately
uses stdole, since it will need access to IPicture anyway.

I'd say my conclusion is that VisualBasic.Compatibility is more
high-level and IPicture is rather low-level.

What I hate about DigitalPersona's API is that they don't just return
IPicture type, but instead they return IDispatch, which is quite
confusing at first, since you have to cast it to IPicture. I'm not sure
but is this on purpose or because COM has no way of using types from
other type libraries? (for example, DigitalPersona returns IPicture
which is defined in stdole?) This also happens with also every other
thing returned, FPSample returned as IDispatch, FPTemplate returned as
IDispatch, etc. Good thing I got the Developer's Guide now, so I know
which things is using what type. It's not like it has a
EnumerateSupportedInterfaces() method. :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top