我需要在扫描后自动将图片上传到PictureBox
。
这是PictureBox的名称PictureBox ptbImgDocEmp
这是扫描仪类
Scanner.cs
public class Scanner
{
Device oDevice;
Item oItem;
CommonDialogClass dlg;
public Scanner()
{
dlg = new CommonDialogClass();
try
{
oDevice = dlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, true, false);
}
catch (Exception Exp)
{ MessageBox.Show("printer not detected");}
}
这是一个扫描仪按钮
private void btnSca_Click(object sender, EventArgs e)
{
Scanner oScanner = new Scanner();
oScanner.Scann();
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.FileName = "test.jpg";
saveFileDialog.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*";
if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ptbImgDocEmp.Image = Image.FromFile(saveFileDialog.FileName);
ptbImgDocEmp.Refresh();
}
}