本文整理汇总了C#中ItemClass.TakePicture方法的典型用法代码示例。如果您正苦于以下问题:C# ItemClass.TakePicture方法的具体用法?C# ItemClass.TakePicture怎么用?C# ItemClass.TakePicture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemClass
的用法示例。
在下文中一共展示了ItemClass.TakePicture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartScan
public List<Image> StartScan()
{
//return null;
wiaManager = new WiaClass();
wiaDevs = wiaManager.Devices as CollectionClass;
//if (string.IsNullOrEmpty(DefaultScaner))
//{
object selectUsingUI = System.Reflection.Missing.Value; // = Nothing
wiaRoot = (ItemClass)wiaManager.Create(ref selectUsingUI); // let user select device
if (wiaRoot != null)
{
string selectId = wiaRoot.GetPropById((WiaItemPropertyId)WiaDeviceInfoPropertyId.DeviceInfoDevId) as string;
XmlHelper.UpdateConfig("DefaultScan", selectId);
}
//}
else
{
foreach (object info in (wiaManager.Devices as CollectionClass))
{
//string selectId = wiaRoot.GetPropById((WiaItemPropertyId)WiaDeviceInfoPropertyId.DeviceInfoDevId) as string;
//if (selectId == DefaultScaner)
//{
// wiaRoot = (ItemClass)info.Create();
// break;
//}
}
}
try
{
//wiaManager = new WiaClass(); // create COM instance of WIA manager
//wiaDevs = wiaManager.Devices as CollectionClass; // call Wia.Devices to get all devices
// this call shows the common WIA dialog to let the user select a picture:
//wiaPics = wiaRoot.GetItemsFromUI(WiaFlag.SingleImage, WiaIntent.ImageTypeColor) as CollectionClass;
//if (wiaPics == null)
//{
// return null;
//}
//string imageFileName = string.Empty;
//bool takeFirst = true; // this sample uses only one single picture
//foreach (object wiaObj in wiaPics) // enumerate all the pictures the user selected
//{
//if (takeFirst)
//{
string imageFileName = string.Empty;
ItemClass wiaObj =(ItemClass) wiaRoot.TakePicture();
//wiaItem = (ItemClass)Marshal.CreateWrapperOfType(wiaObj, typeof(ItemClass));
imageFileName = Path.GetTempFileName(); // create temporary file for image
Cursor.Current = Cursors.WaitCursor; // could take some time
//this.Refresh();
//wiaRoot.TakePicture();
wiaObj.Transfer(imageFileName, false); // transfer picture to our temporary file
Image img = Image.FromFile(imageFileName); // create Image instance from file
//takeFirst = false; // first and only one done.
imgs.Add(img);
//}
// Marshal.ReleaseComObject(wiaObj); // release enumerated COM object
//}
}
catch (Exception ee)
{
//MessageBox.Show(this, "Acquire from WIA Imaging failed\r\n" + ee.Message, "WIA", MessageBoxButtons.OK, MessageBoxIcon.Stop);
//Application.Exit();
}
finally
{
if (wiaItem != null)
Marshal.ReleaseComObject(wiaItem); // release WIA image COM object
if (wiaPics != null)
Marshal.ReleaseComObject(wiaPics); // release WIA collection COM object
if (wiaRoot != null)
Marshal.ReleaseComObject(wiaRoot); // release WIA root device COM object
if (wiaDevs != null)
Marshal.ReleaseComObject(wiaDevs); // release WIA devices collection COM object
if (wiaManager != null)
Marshal.ReleaseComObject(wiaManager); // release WIA manager COM object
Cursor.Current = Cursors.Default; // restore cursor
}
return imgs;
// ImageFile imageFile;
// DeviceManagerClass manager = new DeviceManagerClass();
// Device WiaDev = null;
// CommonDialogClass devCdc = new WIA.CommonDialogClass();
// if (string.IsNullOrEmpty(DefaultScaner))
// {
// WiaDev = devCdc.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, true, false);
// if (WiaDev != null)
// {
// XmlHelper.UpdateConfig("DefaultScan", WiaDev.DeviceID);
//.........这里部分代码省略.........