这是我做的一段程序,已经实现了。
procedure TfrmScan.btnBeginScanClick(Sender: TObject);
var
tmpJPEG:TJPEGImage;
tmpIniFile: TIniFile;
begin
{弹出保存文件窗体}
If not Assigned(frmSaveDlg) Then
frmSaveDlg:=TFrmSaveDlg.Create(Application);
If frmSaveDlg.ShowModal=mrCancel Then Exit;
{开始扫描各步骤}
Application.ProcessMessages;
ImgScan1.ScanTo:=1;
ImgScan1.DestImageControl:='ImgEdit1';
Try
If Not ImgScan1.ScannerAvailable then
ImgScan1.OpenScanner;
Except
MessageBox(Handle,'扫描仪没准备好','警告',MB_OK+MB_ICONWARNING);
Exit;
End;
Try
//开始扫描
ImgScan1.StartScan;
ImgScan1.CloseScanner;
If FileExists(ImgScan1.Image) Then Begin
//显示图像
Image1.Picture.LoadFromFile(ImgScan1.Image);
//删除过渡文件
DeleteFile(ImgScan1.Image);
//转换成JPG格式
tmpJPEG:=TJPEGImage.Create;
tmpJPEG.Assign(Image1.Picture.Bitmap);
{设置压缩率}
tmpIniFile:= TIniFile.Create(ExtractFilePath(Application.ExeName)+'../Setup.ini');
tmpJPEG.CompressionQuality:=tmpIniFile.ReadInteger('扫描图片','压缩率',65);
tmpIniFile.Free;
//保存成JPG文件
tmpJPEG.SaveToFile(Copy(ImgScan1.Image,1,Length(ImgScan1.Image)-4)+'.jpg');
End;
Finally
End;
End;
//选择扫描仪
procedure TfrmScan.btnSelBtnClick(Sender: TObject);
begin
Application.ProcessMessages;
ImgScan1.ShowSelectScanner;
end;
//显示选中图片
procedure TfrmScan.ShellListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
If Not Assigned(ShellListView1.Selected) Then Exit;
Try
Image1.Picture.LoadFromFile(ShellListView1.Folders[ShellListView1.Selected.index].PathName);
Except
End;
end;
//放大图像
procedure TfrmScan.Image1Click(Sender: TObject);
begin
If Not Assigned(Image1.Picture.Graphic) Then Begin
MessageBox(Handle,'无图像显示,请选择受理编号!','注意',MB_OK+MB_ICONWARNING);
Exit;
End;
If Not Assigned(frmZoomOut) Then
frmZoomOut:=TFrmZoomOut.Create(Self);
frmZoomOut.Image1.Picture.Bitmap.Assign(Self.Image1.Picture.Graphic);
frmZoomOut.ShowModal;
end;