本文整理汇总了C#中System.Item.Transfer方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Transfer方法的具体用法?C# Item.Transfer怎么用?C# Item.Transfer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.Transfer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransferJpgItem
public static void TransferJpgItem(Item item, string path)
{
var itemName = item.Properties["Item Name"].get_Value();
if (!item.Formats.Cast<string>().Contains(FormatID.wiaFormatJPEG))
{
Console.WriteLine("Unexpected formats for item {0}, skipping.", itemName);
return;
}
var targetName = itemName + ".jpg";
Directory.CreateDirectory(path);
ImageFile file = (ImageFile)item.Transfer(FormatID.wiaFormatJPEG);
Console.WriteLine("Copying {0}", targetName);
file.SaveFile(Path.Combine(path, targetName));
}
示例2: TransferImage
/// <summary>
/// Transfers an image from the capture device
/// </summary>
private static WiaResult TransferImage(Item item, WiaFormat format, string outputPath, out string fileName)
{
fileName = string.Empty;
try
{
//Initiate transfer
ImageFile image = item.Transfer(format.ComGuid) as ImageFile;
if (image != null)
//Ensure something was obtained.
{
string tempFileName = string.Format("{0}.{1}", Guid.NewGuid().ToString(), format.FileExtension);
if (!outputPath.EndsWith("\\"))
{
outputPath += "\\";
}
tempFileName = outputPath + tempFileName;
image.SaveFile(tempFileName);
//An exception will be thrown if the image cannot be saved, by getting here
//we know that the save succeeded.
fileName = tempFileName;
//If the image was not saved in Jpg format then transcode it here
if (!WiaFormats.IsJpg(format.ComGuid))
{
string transcodedFileName;
WiaResult transcodeResult = TranscodeImageToJpg(fileName, out transcodedFileName);
if (!transcodeResult.Succeeded)
{
return transcodeResult;
}
else
{
fileName = transcodedFileName;
}
}
return WiaResult.Success;
}
else
{
return new WiaResult(string.Format(ERROR_MESSAGE_FORMAT,
"transfer the image from the device",
"The image returned could not be cast to an ImageFile interface"));
}
}
catch (COMException ce)
{
if (logger.IsDebugEnabled)
{
logger.Debug(WiaConstants.LoggingConstants.ExceptionOccurred, ce);
}
return new WiaResult(string.Format(ERROR_MESSAGE_FORMAT,
"transfer the image from the device",
WiaError.GetErrorMessage(ce)));
}
}
示例3: GetPagesFromScanner
private List<Image> GetPagesFromScanner(ScanSource source, Item item)
{
SetDeviceProperty(ref _device, 3088, (int)source);
List<Image> images = new List<Image>();
int handlingStatus = GetDeviceProperty(ref _device, WIA_DPS_DOCUMENT_HANDLING_STATUS);
if ((source == ScanSource.DocumentFeeder && handlingStatus == FEED_READY) || (source == ScanSource.Flatbed && handlingStatus == FLATBED_READY))
{
do
{
ImageFile wiaImage = null;
try
{
wiaImage = item.Transfer(WIA_FORMAT_JPEG);
}
catch (COMException ex)
{
if ((uint)ex.ErrorCode == WIA_ERROR_PAPER_EMPTY)
break;
else
throw;
}
if (wiaImage != null)
{
System.Diagnostics.Trace.WriteLine(String.Format("Image is {0} x {1} pixels", (float)wiaImage.Width / 150, (float)wiaImage.Height / 150));
Image image = ConvertToImage(wiaImage);
images.Add(image);
}
}
while (source == ScanSource.DocumentFeeder);
}
return images;
}
示例4: ShowTransfer
public object ShowTransfer(Item Item, string FormatID = "{00000000-0000-0000-0000-000000000000}", bool CancelError = false)
{
return Item.Transfer(FormatID);
}