public Image Scan(DeviceInfo device) { if (device == null) throw new ArgumentException("Device must be specified"); var scanner = device.Connect(); var wiaCommonDialog = new WPFCommonDialog(); var item = scanner.Items[1]; var image = (ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatBMP, false); string fileName = Path.GetTempFileName(); File.Delete(fileName); image.SaveFile(fileName); image = null; // add file to output list return Image.FromFile(fileName); }
public Image Scan(DeviceInfo device, PageSize pageSize, ColorDepth colorDepth, Resolution resolution, Orientation orientation, bool setSize = true) { if (device == null) throw new ArgumentException("Device must be specified"); var scanner = device.Connect(); var wiaCommonDialog = new WPFCommonDialog(); var item = scanner.Items[1]; SetupPageSize(item, pageSize, colorDepth, resolution, orientation, setSize); var image = (ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatBMP, false); string fileName = Path.GetTempFileName(); File.Delete(fileName); image.SaveFile(fileName); image = null; // add file to output list return Image.FromFile(fileName); }