[DllImport("user32.DLL", ExactSpelling=true)]
internal static extern long SetForegroundWindow(IntPtr hWnd);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_AcquireToClipboard(IntPtr handle,long t);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_SelectImageSource(IntPtr handle);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_IsAvailable();
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_SetHideUI(long nHide);
try
{
if ( TWAIN_AcquireToClipboard(this.Handle,(long)4) == 0 )
{
SetForegroundWindow(this.Handle);
return;
} SetForegroundWindow(this.Handle);
Image img = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
if ( img == null ) return;
this.picImage.SizeMode = PictureBoxSizeMode.StretchImage;
this.picImage.Image = img; this.CopyImage(); this.btnSave.Enabled = true;
}
catch ( Exception error )
{
MessageBox.Show(error.Message);
}
internal static extern long SetForegroundWindow(IntPtr hWnd);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_AcquireToClipboard(IntPtr handle,long t);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_SelectImageSource(IntPtr handle);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_IsAvailable();
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_SetHideUI(long nHide);
try
{
if ( TWAIN_AcquireToClipboard(this.Handle,(long)4) == 0 )
{
SetForegroundWindow(this.Handle);
return;
} SetForegroundWindow(this.Handle);
Image img = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
if ( img == null ) return;
this.picImage.SizeMode = PictureBoxSizeMode.StretchImage;
this.picImage.Image = img; this.CopyImage(); this.btnSave.Enabled = true;
}
catch ( Exception error )
{
MessageBox.Show(error.Message);
}
解决方案 »
- 安装sql 2008 express advanced版问题
- 新手小白问问题~~~~
- c# 点 事件触发
- 用C#写个简单的记事本的问题
- 新手,求wenform中怎样使button只能点击3次然后按钮变色
- 问一个using(SqlConnection conn = new SqlConnection(constring)) cmd.executenonquery();的效率问题
- 谁有全面点的API的资料啊,包括其中函数的参数说明和函数用途
- 已经生成的项目,怎样挂到互连网上,请高手指教!!!!(有分)
- 求助C# 发送邮件DIV样式失效
- 获得系统音量API还是不行,请思归等大侠进来看看,再送百分
- c#中的TYPEOF的问题?
- 绑定表到自定义控件属性的疑惑。
private AxScanLibCtl.AxImgScan axImgScan;private void buttonRead_Click(object sender, System.EventArgs e)
{
//侦测试扫描仪是否可用
if(axImgScan.ScannerAvailable())
{
//打开扫描仪
axImgScan.OpenScanner();
axImgScan.Image=this.imagePath;//设定扫描仪扫描的图片存放路径
axImgScan.StartScan();//开始扫描
axImgEdit.Image=axImgScan.Image;//设定图片编辑器要编辑的图片路径
axImgEdit.Display();//在编辑器中显示图片
//设定图片局部选择框事件
axImgEdit.SelectionRectDrawn += new AxImgeditLibCtl._DImgEditEvents_SelectionRectDrawnEventHandler(ImgEdit_SelectionRectDrawn);
//设定图片局部选择框
axImgEdit.DrawSelectionRect(0,0,125,160);
}
else
{
MessageBox.Show("数码相机未安装好!");
return;
}
axImgScan.CloseScanner();
}private void ImgEdit_SelectionRectDrawn(object sender, AxImgeditLibCtl._DImgEditEvents_SelectionRectDrawnEvent e)
{
//存在选定的图片区域
if(axImgEdit.SelectionRectangle)
{
axImgEdit.Display();
//将图片选定区域复制到剪切板
axImgEdit.ClipboardCopy(e.left,e.top,e.width,e.height);
//取得剪切板中的数据并赋给指定图片控件
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Bitmap))
this.pictureBox.Image = (Image)data.GetData(DataFormats.Bitmap); }
}