cyberfan's blog

正其谊不谋其利,明其道不计其功

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  15 随笔 :: 489 文章 :: 44 评论 :: 0 Trackbacks
在Delphi中通过扫描仪获得所需的图象信息呢?不外乎有三种基本的方法:
通过图象处理软件,比如说Photoshop等,通过它们的扫描图象的功能,加工成一

定格式的图象后再在自己的系统中利用;

通过扫描仪接口Twain.DLL 。该接口是在安装扫描仪时提供的,它实际上是一个

Plugin插件,它通过一系列函数来控制扫描仪;

通过构件技术来控制扫描仪。

---- 利用第一种方法能减少编程的复杂度,但是系统的集成度不高,用户使用上

也不方便;第二种方法能在驱动程序级直接控制扫描仪,能在编程上提供最大的

灵活性和可控性;第三种方法能充分利用Delphi的可视化构件技术,安全、灵活

、自由地利用扫描仪。其实第三种方法也是建立在扫描仪接口Twain.DLL之上的。

本文论述的方法就采用第三种。

---- Windows9X在其附件中提供了“映象”可选件,该附件是采用OCX构件来控制

扫描仪的,共有imgEdit、imgAnntool、imgScan、imgAdmin 四个,有这四个构件

基本上就能完全控制扫描仪。在Delphi中的用法如下:

在Windows9x中选择安装“映象”。(在控制面板中选择“添加/删除程序”,再

选择“安装Windows”,点击“附件”复选框,然后从“详细资料”按钮中可以找

到“映象”)

启动Delphi,选择“Component”菜单项下的“Import ActiveX Control”,这时

可以看到列表中有“Wang 图象编辑控制、Wang 图象扫描控制、Wang 图象管理控

制、Wang 图象缩略图控制”,选中这四项,然后点击“Install”按钮,这时在

构件面板上的ActiveX舌标下就可以看到这四个构件的图标。

---- ImgScan 的主要属性:FileType:图象的文件类型(该构件支持三种:TIF

F,BMP,AWD);

ScanTo:返回或设置被扫描图象的目的;

可取值 含义

0 (缺省) 显示被扫描的图象.

1 显示被扫描的图象并写入一个文件.

2 把图象写入一个文件

3 以模板方式把图象写入文件并显示.

4 . 以模板方式把图象写入文件

5 传真被扫描的图象

注意:如果取缺省值0,

必须和 Wang ImgEdit 构件配合使用。

DestImageControl:Wang ImgEdit构件名;

Zoom:图象的放缩比例

ImgScan 的主要方法:OpenScanner :打开扫描仪;

CloseScanner :关闭扫描仪;

StartScan : 开始扫描;

StopScan : 停止扫描

 

---- ImgEdit 的属性主要是控制扫描图象的分辨率、图象的宽高、是否允许对图

象进行局部选 择等;其方法主要有拷贝、剪切图象到粘贴板,从粘贴板复制图象

,旋转、放缩、 镜象图象;打印、保存、刷新图象等。

---- 关于上述四个OCX构件的详细使用说明可在Delphi中查看其自带的帮助系统



---- 下面是使用这两个构件的一些例子:

procedure Tscanf.N1Click(Sender: TObject);

begin

ImgScan1.ShowSelectScanner;

//选择系统中已安装的扫描仪

end;

procedure Tscanf.N2Click(Sender: TObject);

begin

imgedit1.zoom:=100; //设置图象的放缩因子

if not imgscan1.ScannerAvailable then

//如果选择的扫描仪不可用

imgscan1.OpenScanner;//打开扫描仪

imgscan1.StartScan; //开始扫描图象

imgscan1.CloseScanner; //关闭扫描仪

end;

 

procedure Tscanf.N8Click(Sender: TObject);

begin

if (imgedit1.IsClipboardDataAvailable

and imgedit1.ImageDisplayed ) then

imgedit1.ClipboardPaste(selleft,seltop);

//从剪贴板粘贴图象,其参数为Imgedit的显示区域的起始坐标

end;

procedure Tscanf.N1801Click(Sender: TObject);

begin

if imgedit1.ImageDisplayed then

imgedit1.Flip; //镜象图象

end;

procedure Tscanf.N901Click(Sender: TObject);

begin

if imgedit1.ImageDisplayed then

imgedit1.RotateRight //向右旋转图象

end;

procedure Tscanf.N6Click(Sender: TObject);

begin

imgedit1.DrawSelectionRect(selleft,

seltop,selwidth,selheight);//进行图象局部选择

imgedit1.ClipboardCut(selleft,seltop,

selwidth,selheight);//剪切所选区域

end;

 

---- 注意:在DELPHI中使用Imgedit构件的拷贝和剪切功能时,会出现以下问题



---- 1、 如果把整幅图象都选中,没有任何问题;

---- 2、 如果选择了局部区域,则拷贝和剪切的区域会发生漂移;

---- 3、 如果DELPHI做的是MS SQL后端数据库的客户端界面,那么在把图象内容

写入数据库的图象字段中时,BDE(数据库引擎)会报错。这是DELPHI3。0和4。

0的BUG,4。0的升级包可以解决这个问题。

---- 至于第二个问题,可这样解决:在Imgedit的onSelectionRectDrawn事件中

写一段代码,把选择区域的边界值保存到四个全局变量中,在拷贝和剪切之前用

先前保存的变量再进行一次选择即可(当然,这一切都在后台进行的,见前面的

例子)。
posted on 2005-08-12 15:53 cyberfan 阅读(355) 评论(12)  编辑 收藏 引用 所属分类: delphi

评论

# www.3.com.cn扫描仪 2007-11-23 13:52 扫描仪
扫描仪http://www.3r.com.cn/  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-10 10:16 fadfa
[url=http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp]磨具磨料[/url]
[url=http://www.huaxing-tw.com/product.asp]金刚石砂轮[/url]
[url=http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp]金刚石砂轮[/url]
[url=http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp]磨具磨料[/url]

  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-10 10:16 fadfa

[url=http://www.szxxm.com]UV油墨[/url]
[url=http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com]硅胶制品[/url]
[url=http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com]硅胶棍[/url]
[url=http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com]硅胶板[/url]
[url=http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com">http://www.szsongx.com]硅胶管[/url]  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-15 15:03 fdf
[url=http://www.szjucai.net">http://www.szjucai.net]深圳聚才空压机[/url]
[url=http://www.szjucai.net">http://www.szjucai.net]汽车监控器[/url]
[url=http:// www.szhyl.net.cn]铝材专业五金拉手五金电镀[/url]
[url=http://www.szxinchang.net]求购五金电动工具[/url]
[url=http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com]挂绳[/url]
[url=http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com]挂带[/url]
[url=http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com]手机绳[/url]
[url=http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com">http://www.panxinbo.com]u盘挂绳[/url]
  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-24 13:44 fdsdss
[url=http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp]磨具磨料[/url]
[url=http://www.huaxing-tw.com/product.asp]金刚石砂轮[/url]
[url=http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp]金刚石砂轮厂[/url]
[url=http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com/index1.asp]磨具磨料厂[/url]
  回复  更多评论
  

# dewa fwef 2007-12-25 16:32 wfafe
[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com">http://www.huaxing-tw.com">http://www.huaxing-tw.com]磨具磨料[/url]
[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com">http://www.huaxing-tw.com">http://www.huaxing-tw.com]金刚石砂轮[/url]
[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com">http://www.huaxing-tw.com">http://www.huaxing-tw.com]金刚石砂轮厂[/url]

[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]镀镍钢网[/url]
[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]深圳镀镍钢网[/url]
[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]镀镍钢网厂[/url]
[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]龙岗镀镍钢网[/url]  回复  更多评论
  

# dewa fwef 2007-12-25 16:33 wfafe


[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]镀镍钢网[/url]
[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]深圳镀镍钢网[/url]
[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]镀镍钢网厂[/url]
[url=http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn">http://www.szqunwei.cn]龙岗镀镍钢网[/url]  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-25 22:46 saf
[url=http://www.fcpk001.com">http://www.fcpk001.com]热收缩薄膜[/url]
[url=http://www.fcpk001.com">http://www.fcpk001.com]收缩膜[/url]
[url=http://www.fcpk001.com">http://www.fcpk001.com/about.asp]收缩膜[/url]
[url=http://www.fcpk001.com">http://www.fcpk001.com/about.asp]热收缩薄膜[/url]
[url=http://www.fcpk001.com">http://www.fcpk001.com/shebei.asp]收缩膜[/url]
[url=http://www.fcpk001.com">http://www.fcpk001.com/shebei.asp]热收缩薄膜[/url]
[url=http://www.fcpk001.com">http://www.fcpk001.com/product.asp]收缩膜[/url]  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-27 11:48 rtytu
<a href=" http://www.chinaredleaf.cn/rxjj-1.asp.htm ">stretcher</a>网提供stretcher产品、stretcher等stretcher相关服务,欢迎选择2026122612733<a href=" http://www.zjgshuanghe.cn ">超声波清洗机</a>信息网,提供超声波清洗机知识,超声波清洗机产品,超声波清洗机型号,以及超声波清洗机咨询等超声波清洗机相关服务,欢迎选择2026122612847<a href="http://www.chinaredleaf.cn/rxjj.asp.htm ">担架</a>信息网,提供担架知识,担架产品,担架型号,以及担架咨询等担架相关服务,欢迎选择2026122612847
威马[url=http://www.tjweima.com">http://www.tjweima.com">http://www.tjweima.com">http://www.tjweima.com]乐泰胶[/url]是一家专业的[url=http://www.tjweima.com">http://www.tjweima.com">http://www.tjweima.com">http://www.tjweima.com] 天津乐泰胶公司[/url],凭借高品质的乐泰胶产品为您提供值得信赖的乐泰胶服务。
<a href=" http://www.sfchiller.com">http://www.sfchiller.com ">冷水机</a>网提供冷水机产品、冷水机咨询等冷水机相关服务,欢迎选择2026122612733
<a href=" http://www.sfchiller.com">http://www.sfchiller.com ">模温机</a>网提供模温机产品、模温机咨询等模温机相关服务,欢迎选择2026122612733
<a href=" http://www.sfchiller.com">http://www.sfchiller.com/product.html ">冷水机</a>网提供冷水机产品、冷水机咨询等冷水机相关服务,欢迎选择2026122612733
<a href=" http://www.sfchiller.com">http://www.sfchiller.com/product.html ">模温机</a>网提供模温机产品、模温机咨询等模温机相关服务,欢迎选择2026122612733
<a href=" http://www.tjweima.com">http://www.tjweima.com">http://www.tjweima.com">http://www.tjweima.com ">乐泰胶</a>信息网,提供乐泰胶知识,乐泰胶产品,乐泰胶型号,以及乐泰胶咨询等乐泰胶相关服务,欢迎选择2026120812847
<a href=http://www.cnzjgsl.com>工业吸尘器</a>网提供工业吸尘器产品、工业吸尘器咨询等工业吸尘器相关服务,欢迎选择202611161325
[url=http://www.cnzjgsl.com/one.html]工业吸尘器[/url]<a href=" http://www.minlianjx.cn ">弯管机</a>
<a href=" http://www.wzhuaxing.com ">铝箔纸</a>网提供铝箔纸产品、铝箔纸咨询等铝箔纸相关服务
<A href= http://www.xinmaoyuan.cn">http://www.xinmaoyuan.cn ">合金管</A>[url=http://www.xinmaoyuan.cn">http://www.xinmaoyuan.cn]合金管[/url]
  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2007-12-28 21:58 dfdfsfds
[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com/index1.asp">http://www.huaxing-tw.com">http://www.huaxing-tw.com/index1.asp]磨具磨料[/url]
[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com/product.asp">http://www.huaxing-tw.com">http://www.huaxing-tw.com/product.asp]金刚石砂轮[/url]


[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com]磨具磨料[/url]
[url=http://www.huaxing-tw.com">http://www.huaxing-tw.com]金刚石砂轮[/url]
  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2008-04-02 15:26 dfsd
[url=http://www.szxiangshen.com">http://www.szxiangshen.com">http://www.szxiangshen.com">http://www.szxiangshen.com]深圳玻璃钢制品[/url]
[url=http://www.szxiangshen.com">http://www.szxiangshen.com">http://www.szxiangshen.com">http://www.szxiangshen.com]深圳篮球架[/url]
[url=http://www.szxiangshen.com">http://www.szxiangshen.com">http://www.szxiangshen.com">http://www.szxiangshen.com]深圳保安亭[/url]
[url=http://www.szxinwang.com]深圳不干胶[/url]
[url=http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com]防静电升降椅[/url]
[url=http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com]防静电工作椅[/url]
[url=http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com]防静电椅[/url]
[url=http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com">http://www.szxinsitong.com]防静电圆凳[/url]  回复  更多评论
  

# re: 在delphi里面直接操纵扫描仪 2008-04-02 15:27 dfsd
<a href="http://www.szxinwang.com">深圳不干胶</a>
<a href="http://www.szxiangshen.com">防静电升降椅</a>
<a href="http://www.szxinsitong.com">防静电工作椅</a>
<a href="http://www.szxinsitong.com">防静电椅</a>
<a href="http://www.szxinsitong.com">防静电圆凳</a>
<a href="http://www.szxinsitong.com">防静电皮革椅</a>
<a href="http://www.szxinsitong.com">防静电靠背椅</a>
<a href="http://www.cnrijia.cn">钛螺丝</a>
<a href="http://www.huaxing-tw.com">磨具磨料</a>
<a href="http://www.huaxing-tw.com">金刚石砂轮</a>
<a href="http://www.zhuchengmj.com">木模</a>
<a href="http://www.zhuchengmj.com">铸造模具</a>  回复  更多评论
  

只有注册用户登录后才能发表评论。