⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faxconv.pas

📁 将图像转换为传真文件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    end;
  end;
  if Ext = '.txt' then
  begin
    if cbxEnhTextEnabled.Checked then
      ApdFaxConverter1.InputDocumentType := idTextEx
    else
      ApdFaxConverter1.InputDocumentType := idText;
    ApdFaxConverter1.DocumentFile:=edtFileName.text;
  end
  else if Ext = '.bmp' then
  begin
    ApdFaxConverter1.InputDocumentType := idBMP;
    ApdFaxConverter1.DocumentFile := edtFileName.Text;
  end
  else if Ext='.fcp' then
  begin
     ConvertFCPToAPF(edtFileName.text, 0, 0, '', '', '', '', ApdFaxConverter1Status);
  end
  else if Ext = '.tif' then
  begin
    ApdFaxConverter1.InputDocumentType := idTIFF;
    ApdFaxConverter1.DocumentFile := edtFileName.Text;
  end
  else if Ext = '.pcx' then
  begin
    ApdFaxConverter1.InputDocumentType := idPCX;
    ApdFaxConverter1.DocumentFile := edtFileName.Text;
  end
  else if Ext = '.dcx' then
  begin
    ApdFaxConverter1.InputDocumentType := idDCX;
    ApdFaxConverter1.DocumentFile := edtFileName.Text;
  end
  else  ApdFaxConverter1.InputDocumentType := idNone;
  if ApdFaxConverter1.InputDocumentType = idNone then
  begin
     btnConvert.Caption := '转换';
     Exit;
  end;
  ApdFaxConverter1.OutFileName := edtOutFileName.Text;
  Try
    ApdFaxConverter1.ConvertToFile;
    MessageDlg('转换成功!',mtconfirmation,[mbok],0);
  except
  end;
  btnConvert.Caption := '转换';
end;

procedure TFaxConversionForm.ApdFaxConverter1Status(F: TObject; Starting,
  Ending: Boolean; PagesConverted, LinesConverted: Integer; BytesConverted,
  BytesToConvert: Longint; var Abort: Boolean);
begin
  Abort := Cancelled;
  if (BytesToConvert <> 0) then
    Meter.Position := (BytesConverted * 100) div BytesToConvert;
end;

procedure TFaxConversionForm.btnEnhFontClick(Sender: TObject);
begin
  FontDialog1.Font := ApdFaxConverter1.EnhFont;
  if FontDialog1.Execute then begin
    ApdFaxConverter1.EnhFont := FontDialog1.Font;
    lblFontName.Caption := ApdFaxConverter1.EnhFont.Name;
    lblFontSize.Caption := IntToStr(ApdFaxConverter1.EnhFont.Size);
  end;
end;

procedure TFaxConversionForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(IniName);
  try
    Ini.WriteString('FaxConvert', 'LastInDir', LastInDir);
    Ini.WriteString('FaxConvert', 'LastOutDir', LastOutDir);
    Ini.WriteBool('FaxConvert', 'EnhTextEnabled', cbxEnhTextEnabled.Checked);
    Ini.WriteString('FaxConvert', 'EnhFont.Name', ApdFaxConverter1.EnhFont.Name);
    Ini.WriteInteger('FaxConvert', 'EnhFont.Size', ApdFaxConverter1.EnhFont.Size);
    Ini.WriteInteger('FaxConvert', 'LeftMargin', ApdFaxConverter1.LeftMargin);
    Ini.WriteInteger('FaxConvert', 'TopMargin', ApdFaxConverter1.TopMargin);
    Ini.WriteInteger('FaxConvert', 'LinesPerPage', ApdFaxConverter1.LinesPerPage);
    Ini.WriteInteger('FaxConvert', 'TabStop', ApdFaxConverter1.TabStop);
    Ini.WriteBool('FaxConvert', 'Options.DoubleWidth', coDoubleWidth in ApdFaxConverter1.Options);
    Ini.WriteBool('FaxConvert', 'Options.HalfHeight', coHalfHeight in ApdFaxConverter1.Options);
    Ini.WriteBool('FaxConvert', 'Options.CenterImage', coCenterImage in ApdFaxConverter1.Options);
    Ini.WriteBool('FaxConvert', 'Options.Yield', coYield in ApdFaxConverter1.Options);
    Ini.WriteBool('FaxConvert', 'Options.YieldOften', coYieldOften in ApdFaxConverter1.Options);
    Ini.WriteInteger('FaxConvert', 'Resolution', Ord(ApdFaxConverter1.Resolution));
    Ini.WriteInteger('FaxConvert', 'Width', Ord(ApdFaxConverter1.Width));
  finally
    Ini.Free;
  end;
end;

procedure TFaxConversionForm.cbxCenterImageClick(Sender: TObject);
begin
  if cbxCenterImage.Checked then
    ApdFaxConverter1.Options := ApdFaxConverter1.Options + [coCenterImage]
  else
    ApdFaxConverter1.Options := ApdFaxConverter1.Options - [coCenterImage];
end;

procedure TFaxConversionForm.cbxYieldClick(Sender: TObject);
begin
  if not cbxYield.Checked then cbxYieldOften.Checked:=false;
  if cbxYield.Checked then
    ApdFaxConverter1.Options := ApdFaxConverter1.Options + [coYield]
  else
    ApdFaxConverter1.Options := ApdFaxConverter1.Options - [coYield];
end;

procedure TFaxConversionForm.cbxYieldOftenClick(Sender: TObject);
begin
  if cbxYieldOften.Checked then cbxYield.Checked:=true;
  if cbxYieldOften.Checked then
    ApdFaxConverter1.Options := ApdFaxConverter1.Options + [coYieldOften]
  else
    ApdFaxConverter1.Options := ApdFaxConverter1.Options - [coYieldOften];
end;

procedure TFaxConversionForm.rgpResolutionClick(Sender: TObject);
begin
  ApdFaxConverter1.Resolution := TFaxResolution(rgpResolution.ItemIndex);
end;

procedure TFaxConversionForm.rgpWidthClick(Sender: TObject);
begin
  ApdFaxConverter1.Width := TFaxWidth(rgpWidth.ItemIndex);
end;

procedure TFaxConversionForm.edtLeftMarginExit(Sender: TObject);
begin
  ApdFaxConverter1.LeftMargin := StrToInt(edtLeftMargin.Text);
end;

procedure TFaxConversionForm.edtTopMarginExit(Sender: TObject);
begin
  ApdFaxConverter1.TopMargin := StrToInt(edtTopMargin.Text);
end;

procedure TFaxConversionForm.edtLinesPerPageExit(Sender: TObject);
begin
  ApdFaxConverter1.LinesPerPage := StrToInt(edtLinesPerPage.Text);
end;

procedure TFaxConversionForm.edtTabStopExit(Sender: TObject);
begin
  ApdFaxConverter1.TabStop := StrToInt(edtTabStop.Text);
end;

procedure TFaxConversionForm.btnBrowseInFileClick(Sender: TObject);
begin
  OpenDialog1.Filter := '提供的类型(*.txt;*.tif;*.pcx;*.dcx;*.bmp;*.fcp;*.jpg;*.jpeg)|' +
    '*.txt;*.tif;*.pcx;*.dcx;*.bmp;*.fcp;*.jpg;*.jpeg|文本文件(*.txt)|*.txt|TIFF 文件(*.tif)|' +
    '*.tif|PCX 文件 (*.pcx)|*.pcx|DCX 文件 (*.dcx)|*.dcx|Bitmap 文件 (*.bmp)|'+
    '*.bmp|(*.jpg)|*.jpg|(*.jpeg)|*.jpg|(*.fcp)|*.fcp|全部文件 (*.*)|*.*';
  OpenDialog1.InitialDir :=ExtractFilePath(Application.ExeName);
  OpenDialog1.Title := '浏览要转换的文件';
  OpenDialog1.FileName := edtFileName.Text;
  if OpenDialog1.Execute then begin
    edtFileName.Text := OpenDialog1.FileName;
    edtOutFileName.Text := ChangeFileExt(edtFileName.Text, '.apf');
    btnConvert.Enabled := FileExists(edtFileName.Text);
    LastInDir := ExtractFilePath(edtFileName.Text);
  end;
end;

procedure TFaxConversionForm.Button2Click(Sender: TObject);
begin
  OpenDialog1.Filter := '传真文件 (*.apf)|*.apf|All files (*.*)|*.*';
  OpenDialog1.InitialDir := LastOutDir;
  OpenDialog1.Title := '输出文件';
  OpenDialog1.FileName := edtOutFileName.Text;
  if OpenDialog1.Execute then begin
    edtOutFileName.Text := OpenDialog1.FileName;
    LastOutDir := ExtractFilePath(edtOutFileName.Text);
  end;
end;

procedure TFaxConversionForm.RadioGroup2Click(Sender: TObject);
begin
   if RadioGroup2.ItemIndex=0 then
     ApdFaxConverter1.Options := ApdFaxConverter1.Options - [coDoubleWidth]-[coHalfHeight]
   else if RadioGroup2.ItemIndex=1 then
     ApdFaxConverter1.Options := ApdFaxConverter1.Options +[coDoubleWidth]
   else if RadioGroup2.ItemIndex=2 then
      ApdFaxConverter1.Options := ApdFaxConverter1.Options+[coHalfHeight]
end;

procedure TFaxConversionForm.edtFileNameExit(Sender: TObject);
begin
    edtOutFileName.Text := ChangeFileExt(edtFileName.Text, '.apf');
    btnConvert.Enabled := FileExists(edtFileName.Text);
    LastInDir := ExtractFilePath(edtFileName.Text);
end;

procedure TFaxConversionForm.btnOKClick(Sender: TObject);
begin
   close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -