先用SelectImageSource得到图片源,再用GetImageFromImageSource得到图片
[DllImport("Eztw32.dll")]
private static extern int TWAIN_AcquireToClipboard(int hwndApp, int wPixTypes);
[DllImport("Eztw32.dll")]
private static extern int TWAIN_SelectImageSource(int hwndApp);
/// <summary>
/// 选择设备
/// </summary>
public static void SelectImageSource()
{
Func.TWAIN_SelectImageSource(0);
}
public static Image GetImageFromImageSource()
{
TWAIN_AcquireToClipboard(0,0);
IDataObject obj1 = Clipboard.GetDataObject();
if (obj1.GetDataPresent(DataFormats.Bitmap))
{
return (Image)obj1.GetData(DataFormats.Bitmap);
}
return null;
}