这是一个demo,我有点看不明白,谁能帮我解释一下?(15分)

  • 主题发起人 主题发起人 qq172
  • 开始时间 开始时间
Q

qq172

Unregistered / Unconfirmed
GUEST, unregistred user!
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ImageEnView, ImageEnIO, ComCtrls, ieview;

type
TForm1 = class(TForm)
ImageEnIO1: TImageEnIO;
ImageEnView1: TImageEnView;
Panel1: TPanel;
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
GroupBox2: TGroupBox;
ComboBox1: TComboBox;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
ComboBox2: TComboBox;
CheckBox2: TCheckBox;
GroupBox3: TGroupBox;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Button1: TButton;
Button2: TButton;
ProgressBar1: TProgressBar;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
procedure FormActivate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ImageEnIO1Progress(Sender: TObject; per: Integer);
procedure CheckBox5Click(Sender: TObject);
private
{ Private declarations }
procedure FillBack; // copy twain parameters to the controls
procedure FillIn; // copy controls to twain parameters
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormActivate(Sender: TObject);
var
i: integer;
begin
// fills TWain sources
for i := 0 to ImageEnIO1.TWainParams.SourceCount - 1 do
ComboBox1.Items.Add(ImageEnIO1.TWainParams.SourceName);
// Select first scanner
ComboBox1.ItemIndex := 0;
ImageEnIO1.TWainParams.SelectedSource := ComboBox1.ItemIndex;
ImageEnIO1.TWainParams.AppVersionInfo := '1.0';
ImageEnIO1.TWainParams.AppManufacturer := 'HiComponents';
ImageEnIO1.TWainParams.AppProductFamily := 'Image processing';
ImageEnIO1.TWainParams.AppProductName := 'ImageEn demo';
FillBack;
end;

// Select scanner

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
ImageEnIO1.TWainParams.SelectedSource := ComboBox1.ItemIndex;
FillBack;
end;

// negotiate parameters (verify that scanner supports Frame rectangle, Dpi...)

procedure TForm1.Button2Click(Sender: TObject);
begin
FillIn;
ImageEnIO1.TWainParams.Update; // verify here...
FillBack;
end;

// copy twain parameters to the controls

procedure TForm1.FillBack;
const
COLORS: array[0..9] of string = ('Black&White', 'GrayScale', 'RGB', 'Palette', 'CMY', 'CMYK', 'YUV', 'YUVK', 'CIEXYZ', 'LAB');
var
i, v: integer;
begin
Edit1.Text := FloatToStr(ImageEnIO1.TWainParams.YResolution.CurrentValue);
Edit2.Text := FloatToStr(ImageEnIO1.TWainParams.XResolution.CurrentValue);
// Fill Colors (0=B/W 1=GrayScale 2=RGB) combobox
ComboBox2.Clear;
for i := 0 to ImageEnIO1.TWainParams.PixelType.Count - 1 do
begin
v := ImageEnIO1.TWainParams.PixelType;
if v <= high(COLORS) then
ComboBox2.Items.Add(COLORS[v]);
end;
ComboBox2.ItemIndex := ImageEnIO1.TWainParams.PixelType.IndexOf(ImageEnIO1.TWainParams.PixelType.CurrentValue);
// frame
Edit3.Text := FloatToStr(ImageEnIO1.TWainParams.AcquireFrameLeft);
Edit4.Text := FloatToStr(ImageEnIO1.TWainParams.AcquireFrameTop);
Edit5.Text := FloatToStr(ImageEnIO1.TWainParams.AcquireFrameRight);
Edit6.Text := FloatToStr(ImageEnIO1.TWainParams.AcquireFrameBottom);
end;

// copy controls values to twain parameters

procedure TForm1.FillIn;
begin
ImageEnIO1.TWainParams.VisibleDialog := CheckBox1.Checked;
ImageEnIO1.TWainParams.ProgressIndicators := CheckBox2.Checked;
ImageEnIO1.TWainParams.AcquireFrameLeft := StrToFloat(Edit3.Text);
ImageEnIO1.TWainParams.AcquireFrameTop := StrToFloat(Edit4.Text);
ImageEnIO1.TWainParams.AcquireFrameRight := StrToFloat(Edit5.Text);
ImageEnIO1.TWainParams.AcquireFrameBottom := StrToFloat(Edit6.Text);
ImageEnIO1.TWainParams.PixelType.CurrentValue := ComboBox2.ItemIndex;
ImageEnIO1.TWainParams.YResolution.CurrentValue := StrToInt(edit1.text);
ImageEnIO1.TWainParams.XResolution.CurrentValue := StrToInt(edit2.text);
ImageEnIO1.TWainParams.BufferedTransfer := CheckBox4.Checked;
end;

// Acquire

procedure TForm1.Button1Click(Sender: TObject);
begin
FillIn;
ImageEnIO1.Acquire(ieaTWain);
ProgressBar1.Position := 0;
end;

// progress

procedure TForm1.ImageEnIO1Progress(Sender: TObject; per: Integer);
begin
ProgressBar1.Position := per;
if CheckBox3.Checked then
begin
ImageEnView1.Update;
application.processmessages;
end;
end;

// enable/disable acquire frame

procedure TForm1.CheckBox5Click(Sender: TObject);
begin
edit3.enabled := CheckBox5.Checked;
edit4.enabled := CheckBox5.Checked;
edit5.enabled := CheckBox5.Checked;
edit6.enabled := CheckBox5.Checked;
ImageEnIO1.TWainParams.AcquireFrameEnabled := CheckBox5.Checked;
ImageEnIO1.TWainParams.Update;
FillBack;
end;

end.
 
后退
顶部