To:wyly
我原来在武汉,现在不在
你的方法我试过了,但总是不能显示图形,不知你做过指纹设备的程序没有,帮我看看下面
的代码,谢谢
procedure TForm1.Button4Click(Sender: TObject);
Var
Row,Col:Integer;
Ret_Val,Tries,Image_size:Integer;
mStream,mReshape:TMemoryStream;
pImage,pReshape
ointer;
BMP:TBitMap;
Image_Size_X,Image_Size_Y,Dest_Size_X:Integer;
BMPInfoHead:TBITMAPINFO;
begin
mStream:=TMemoryStream.Create;
mReshape:=TMemoryStream.Create;
Image_Size_X:=Image1.Width;
Image_Size_Y:=Image1.Height;
Dest_Size_X:=Image_Size_X;
Try
Ret_Val:=pbInitialize();
if ret_Val<>PBOK then
Begin
Print_Error(Ret_Val);
Exit;
End;
Ret_Val:=pbGetRawImageSize(Row,Col);//得到指纹数据大小(按字节算)
Image_Size:=Row*Col;
if ret_Val<>PBOK then
Begin
Print_Error(Ret_Val);
pbClose();
Exit;
End;
mStream.SetSize(Image_Size);
mStream.Position:=0;
pImage:=mStream.Memory;
Tries:=1;
Repeat
Ret_Val:=pbGetRawImage(pImage);//得到指纹数据
if ret_Val<>PBOK then
Begin
Print_Error(Ret_Val);
pbClose();
Exit;
End;
mReshape.SetSize(Image_Size_X*Image_Size_Y);
mReshape.Position:=0;
pReshape:=mReshape.Memory;
//改变图形尺寸
Ret_Val:=pbReshapeImage(pImage,Image_Size_X,Image_Size_Y,Dest_Size_X,pReshape);
if ret_Val<>PBOK then
Begin
Print_Error(Ret_Val);
pbClose();
Exit;
End;
//设置头信息
BMPInfoHead.bmiHeader.biSize:=SizeOf(TBITMAPINFO);
BMPInfoHead.bmiHeader.biWidth:=Image_Size_X;
BMPInfoHead.bmiHeader.biHeight:=Image_Size_Y;
BMPInfoHead.bmiHeader.biBitCount:=24;
BMPInfoHead.bmiHeader.biPlanes:=1;
BMPInfoHead.bmiHeader.biCompression:=BI_RGB;
BMPInfoHead.bmiHeader.biSizeImage:=Image_Size_X*Image_Size_Y*3;
BMPInfoHead.bmiHeader.biXPelsPerMeter:=0;
BMPInfoHead.bmiHeader.biYPelsPerMeter:=0;
BMPInfoHead.bmiHeader.biClrUsed:=0;
BMPInfoHead.bmiHeader.biClrImportant:=0;
StretchDIBits(Image1.Canvas.Handle,
0, 0, 352, 288,
0, 0, 352, 288,
pReshape,BMPInfoHead, 0, SRCCOPY);
inc(tries);
Until (tries>23);
Finally
mStream.Free;
mReshape.Free;
End;
end;