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

📄 unitdemo.pas

📁 身份证ean128条码生成器,包括15身份证自动升级到18位
💻 PAS
字号:
unit UnitDemo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

const
  BarCodeDll = 'BarCodeLib.Dll';

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    Button2: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    Button3: TButton;
    Button4: TButton;
    SaveDialog1: TSaveDialog;
    Edit3: TEdit;
    Label4: TLabel;
    Label2: TLabel;



    procedure Button1Click(Sender: TObject);

    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
   
  private
    { Private declarations }

  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}
Uses  BarCode ;

procedure TForm1.Button1Click(Sender: TObject);
var
i,i1,a1,a2,a3:byte;
s:Tstream;
en,t,tt,nlstr:string;
a:pchar;
b,c:char;
P,q: Pointer;
ad,n,nl:integer;
begin
  Image1.Picture.Bitmap.PixelFormat:=pf8bit;
  Image1.Picture.Bitmap.Height:=300;
  Image1.Picture.Bitmap.Width:=699;
 // PixelsPerInch:=192;
  ClearCanvas(Image1);

  //************************************


tt:=trim(edit3.Text);
if ((length(tt)<>18) and (length(tt)<>15)) then
 begin
 showmessage('身份证位数错误!');
 exit;
 end;

if length(tt)=18 then
begin

edit1.text:=tt;
end;
if length(tt)=15 then
begin
//nl:=106-strtoint(tt[7]+tt[8]);
//nlstr:=inttostr(nl);
//a3:=strtoint(nlstr[1]);
//a2:=strtoint(nlstr[2]);
nl:=strtoint(tt[1])*7;
nl:=nl+strtoint(tt[2])*9;
nl:=nl+strtoint(tt[3])*10;
nl:=nl+strtoint(tt[4])*5;
nl:=nl+strtoint(tt[5])*8;
nl:=nl+strtoint(tt[6])*4;
nl:=nl+1*2;
nl:=nl+9*1;
nl:=nl+strtoint(tt[7])*6;
nl:=nl+strtoint(tt[8])*3;
nl:=nl+strtoint(tt[9])*7;
nl:=nl+strtoint(tt[10])*9;
nl:=nl+strtoint(tt[11])*10;
nl:=nl+strtoint(tt[12])*5;
nl:=nl+strtoint(tt[13])*8;
nl:=nl+strtoint(tt[14])*4;
nl:=nl+strtoint(tt[15])*2;
a2:=nl mod	 11;

edit1.text:=tt[1]+tt[2]+tt[3]+tt[4]+tt[5]+tt[6]+'19'+tt[7]+tt[8]+tt[9]+tt[10]+tt[11]+tt[12]+tt[13]+tt[14]+tt[15]+aoo(a2);
end;




  ad:=0;
  t:=trim(edit1.Text);
  for n:=1 to 18 do
  ad:=ad+BrCharToInt(t[n])*n;
  ad:=ad+104;
  ad:=ad mod 103;
  en:= BrInttoStr1(ad);
  //*************************************
  PutImgBr128(Pchar(Edit1.Text),en,Image1.Picture.Bitmap.Canvas,Image1.ClientRect,3,clBlack,clWhite) ;
  Button3.Enabled := True ;
  Button4.Enabled := True ;
  Label2.Caption:='乙';
 // Button1.Enabled := False ;

end;

procedure TForm1.Button3Click(Sender: TObject);
var
  BMPStream:TStream;
begin
//**********************************
    //MakBMPHead(TBitmapToTStream(image1.Picture.Bitmap));
  //  image1.Picture.Bitmap.
//    image1.Picture.Bitmap.SaveToStream(BMPStream);
  //  MakBMPHead(BMPStream);
    //image1.Picture.Bitmap.LoadFromStream(BMPStream);
//*******************8
//SetBitmapDimensionEx(image1.Picture.Bitmap,422;50;nil);
//输出图像分辨率改为356。
image1.Picture.SaveToFile(Edit1.Text+Label2.Caption+'.bmp');

end;
procedure TForm1.Button4Click(Sender: TObject);

begin
  SaveDialog1.FileName:=Edit1.Text;
  if SaveDialog1.Execute then

  image1.Picture.SaveToFile(SaveDialog1.FileName+'.bmp');
end;




procedure TForm1.Button2Click(Sender: TObject);

var
i,i1,a1,a2,a3:byte;
s:Tstream;
en,t,tt,nlstr:string;
a:pchar;
b,c:char;
P,q: Pointer;
ad,n,nl:integer;
begin
  Image1.Picture.Bitmap.PixelFormat:=pf8bit;
  Image1.Picture.Bitmap.Height:=200;
  Image1.Picture.Bitmap.Width:=699;
 // PixelsPerInch:=192;
  ClearCanvas(Image1);

  //************************************


tt:=trim(edit3.Text);
if ((length(tt)<>18) and (length(tt)<>15)) then
 begin
 showmessage('身份证位数错误!');
 exit;
 end;

if length(tt)=18 then
begin

edit1.text:=tt;
end;
if length(tt)=15 then
begin
//nl:=106-strtoint(tt[7]+tt[8]);
//nlstr:=inttostr(nl);
//a3:=strtoint(nlstr[1]);
//a2:=strtoint(nlstr[2]);
nl:=strtoint(tt[1])*7;
nl:=nl+strtoint(tt[2])*9;
nl:=nl+strtoint(tt[3])*10;
nl:=nl+strtoint(tt[4])*5;
nl:=nl+strtoint(tt[5])*8;
nl:=nl+strtoint(tt[6])*4;
nl:=nl+1*2;
nl:=nl+9*1;
nl:=nl+strtoint(tt[7])*6;
nl:=nl+strtoint(tt[8])*3;
nl:=nl+strtoint(tt[9])*7;
nl:=nl+strtoint(tt[10])*9;
nl:=nl+strtoint(tt[11])*10;
nl:=nl+strtoint(tt[12])*5;
nl:=nl+strtoint(tt[13])*8;
nl:=nl+strtoint(tt[14])*4;
nl:=nl+strtoint(tt[15])*2;
a2:=nl mod	 11;

edit1.text:=tt[1]+tt[2]+tt[3]+tt[4]+tt[5]+tt[6]+'19'+tt[7]+tt[8]+tt[9]+tt[10]+tt[11]+tt[12]+tt[13]+tt[14]+tt[15]+aoo(a2);
end;




  ad:=0;
  t:=trim(edit1.Text);
  for n:=1 to 18 do
  ad:=ad+BrCharToInt(t[n])*n;
  ad:=ad+104;
  ad:=ad mod 103;
  en:= BrInttoStr1(ad);
  //*************************************
  PutImgBr39(Pchar(Edit1.Text),en,Image1.Picture.Bitmap.Canvas,Image1.ClientRect,3,clBlack,clWhite) ;
  Button3.Enabled := True ;
  Button4.Enabled := True ;
  Label2.Caption:='甲';
 // Button1.Enabled := False ;
end;

end.

⌨️ 快捷键说明

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