Delphi realizes camera photo

xiaoxiao2021-03-06  64

procedure Tfrm1.Button2Click (Sender: TObject); Var jpeg: TJPEGImage; bmp: TBitmap; MyStm: TMemoryStream; strfilename, strcard: String; begin inherited; strfilename: = extractfilepath (Application.ExeName); with DBEdit12.DataSource.DataSet do begin if not VideoCap1.SaveAsDIB then begin ShowMessage ( 'failure to take pictures'); Abort; end; // bmp: = TBitmap.Create; try bmp.LoadFromFile (strfilename 'Capture.bmp'); MyStm: = TMemoryStream.Create; jpeg : = TJPEGImage.Create; try jpeg.Assign (bmp); jpeg.compress; jpeg.SaveTofile (strfilename 'Capture.jpg'); strfilename: = strfilename 'Capture.jpg'; jpeg.LoadFromFile (strfilename); jpeg.SaveToStream (MySTM); MySTM.Position: = 0; OpenQry (Query1, 'Select Count (1) AS CNT from TB_photo where card_no =' '' strcard '' '); // Find no this card number OpenQry (Pubqry) , 'SELECT * from TB_Photo where card_no =' '' strcard '' '' ); // Open the card number data sheet {OpenQRY is a function of custom open data table OpenQry (Qry1: TQuery, SSQL: String); begin with qry1 do beigniff1; close; sql.clear; sql.add (ssql); Try Open Catch ON E: Exception Do ErrorDialog (E.MESSAGE, E.helpContext); end; // try end; end;} with query1 do begin if publicqry.fields [0] .asinteger> 0 Then // first judgment Whether the image of the card number exists, if there is, replace; otherwise, insert.

转载请注明原文地址:https://www.9cbs.com/read-86593.html

New Post(0)