// Some of the functions in EZTWAIN require unsigned integers. However,
// it was not until the recent release of Delphi 4 that Inprise implemented
// this; they did so with LongWord/Cardinal. As far as D2 and D3 go, this
// unit will attempt to substitute an Integer instead. I don't know if it'll
// work though!
type
TW_FIX32 = record
Whole: SmallInt;
Frac: Word;
end;
function ToFix32(r: Double): UnsignedInt32;
var
fix: TW_FIX32;
v: Integer;
begin
v := Round(r * 65536.0 + 0.5);
fix.Whole := ShortInt(V shr 16);
fix.Frac := Word (v and $ffff);
ToFix32 := UnsignedInt32(fix);
end;
function Fix32ToFloat(fix: TW_FIX32): double;
var
v: Integer;
begin
v := (Integer(fix.Whole) shl 16) or (UnsignedInt32(fix.frac) and $ffff);
Fix32ToFloat := v / 65536.0;
end;
function TWAIN_GetCurrentResolution: double;
var
res: TW_FIX32;
begin
TWAIN_GetCapCurrent(ICAP_XRESOLUTION, TWTY_FIX32, @res);
TWAIN_GetCurrentResolution := Fix32ToFloat(res);
end;
function TWAIN_SetCurrentResolution(dRes: double): Integer;
begin
TWAIN_SetCurrentResolution := TWAIN_SetCapOneValue(ICAP_XRESOLUTION, TWTY_FIX32, ToFix32(dRes));
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hDib := 0;
w := 0; h := 0;
testDib := 0;
TWAIN_RegisterCallback(CallbackFxn);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if image1.Picture<>nil
then
image1.Picture:=nil;
TWAIN_SelectImageSource(0);
hdib := TWAIN_AcquireNative(0, 0);
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;
1﹑先將ACTIVEX控件加進去。(Kodak image系列)
2﹑imgscan1.ShowSelectScanner;
if not imgscan1.ScannerAvailable then
imgscan1.OpenScanner;
imgscan1.StartScan;
imgscan1.CloseScanner;
if imgedit1.ImageDisplayed=true then
begin
imgedit1.SaveAs('photo.bmp');
end;