2025-07-22 15:51:47 +08:00
unit getpic;
interface
uses
2025-07-29 17:14:41 +08:00
Windows, Messages, SysUtils, strUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, ComCtrls, ToolWin, ExtCtrls, jpeg, IniFiles, ExtDlgs,
2025-07-22 15:51:47 +08:00
DelphiTwain, Buttons, StdCtrls, DB, ADODB, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdFTP;
type
TFormGetPic = class( TForm)
ScrollBox1: TScrollBox;
Image1: TImage;
OpenPictureDialog1: TOpenPictureDialog;
Image2: TImage;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
ADOQuery1: TADOQuery;
SpeedButton4: TSpeedButton;
SaveDialog1: TSavePictureDialog;
adoqueryImage: TADOQuery;
IdFTP1: TIdFTP;
SpeedButton5: TSpeedButton;
2025-07-29 17:14:41 +08:00
procedure TwainTwainAcquire( Sender: TObject; const Index : Integer ; Image: TBitmap; var Cancel: Boolean ) ;
2025-07-22 15:51:47 +08:00
procedure FormShow( Sender: TObject) ;
procedure FormCreate( Sender: TObject) ;
procedure FormDestroy( Sender: TObject) ;
2025-07-29 17:14:41 +08:00
procedure Image1MouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ;
procedure Image1MouseMove( Sender: TObject; Shift: TShiftState; X, Y: Integer ) ;
2025-07-22 15:51:47 +08:00
procedure SpeedButton1Click( Sender: TObject) ;
procedure SpeedButton2Click( Sender: TObject) ;
procedure SpeedButton3Click( Sender: TObject) ;
procedure Button1Click( Sender: TObject) ;
procedure Button2Click( Sender: TObject) ;
procedure SpeedButton4Click( Sender: TObject) ;
procedure Initimage( ) ;
procedure SpeedButton5Click( Sender: TObject) ;
private
2025-07-29 17:14:41 +08:00
hWndC: THandle;
CapturingAVI: bool;
2025-07-22 15:51:47 +08:00
{ Private declarations }
ClickPos: TPoint;
SelectedSource, PicLeft, PicTop, PicWidth, PicHeight: Integer ;
procedure CreThumb( Width, Height: Integer ) ;
2025-07-29 17:14:41 +08:00
function SaveImage( ) : Boolean ;
2025-07-22 15:51:47 +08:00
public
2025-07-29 17:14:41 +08:00
FilePath: string ;
FileName: string ;
FTFType: string ;
pat1: string ;
pic1: string ;
fkeyNo: string ;
fFlileFlag: string ;
2025-07-22 15:51:47 +08:00
{ Public declarations }
MyJpeg: TJPEGImage;
// JPStream: TMemoryStream;
end ;
var
FormGetPic: TFormGetPic;
implementation
2025-07-29 17:14:41 +08:00
uses
U_DataLink, U_Fun10;
const
WM_CAP_START = WM_USER;
const
WM_CAP_STOP = WM_CAP_START + 6 8 ;
const
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 1 0 ;
const
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 1 1 ;
const
WM_CAP_SAVEDIB = WM_CAP_START + 2 5 ;
const
WM_CAP_GRAB_FRAME = WM_CAP_START + 6 0 ;
const
WM_CAP_SEQUENCE = WM_CAP_START + 6 2 ;
const
WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 2 0 ;
const
WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 6 3 ;
const
WM_CAP_SET_OVERLAY = WM_CAP_START + 5 1 ;
const
WM_CAP_SET_PREVIEW = WM_CAP_START + 5 0 ;
const
WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6 ;
const
WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2 ;
const
WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3 ;
const
WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5 ;
const
WM_CAP_SET_SCALE = WM_CAP_START + 5 3 ;
const
WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 5 2 ;
function capCreateCaptureWindowA( lpszWindowName: PCHAR ; dwStyle: longint ; x: integer ; y: integer ; nWidth: integer ; nHeight: integer ; ParentWin: HWND; nId: integer ) : HWND; stdcall external 'AVICAP32.DLL' ;
2025-07-22 15:51:47 +08:00
{$R *.dfm}
procedure TFormGetPic. Initimage( ) ;
var
2025-07-29 17:14:41 +08:00
jpg: TJpegImage;
2025-07-22 15:51:47 +08:00
myStream: TADOBlobStream;
2025-07-29 17:14:41 +08:00
sFieldName: string ;
2025-07-22 15:51:47 +08:00
JPStream: TMemoryStream;
begin
2025-07-29 17:14:41 +08:00
jpg : = TJpegImage. Create( ) ;
2025-07-22 15:51:47 +08:00
JPStream : = TMemoryStream. Create;
try
with adoqueryImage do
begin
close;
sql. Clear;
2025-07-29 17:14:41 +08:00
sql. Add( 'select * from TP_File where WBID=' + quotedstr( trim( fkeyNo) ) ) ;
2025-07-22 15:51:47 +08:00
open;
2025-07-29 17:14:41 +08:00
if not IsEmpty then
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
if not fieldbyname( pic1) . IsNull then
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
myStream : = tadoblobstream. Create( tblobfield( adoqueryImage. fieldbyname( pic1) ) , bmread) ;
2025-07-22 15:51:47 +08:00
jpg. LoadFromStream( myStream) ;
Image2. Picture. Assign( jpg) ;
myStream. Free;
2025-07-29 17:14:41 +08:00
try
IdFTP1. Host : = ReadINIFileStr( 'SYSTEMSET.INI' , 'SERVER' , '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ' , '127.0.0.1' ) ;
IdFTP1. Username : = 'three' ;
IdFTP1. Password : = '641010' ;
IdFTP1. Connect( ) ;
except
;
end ;
JPStream. Clear;
if IdFTP1. Connected then
begin
try
IdFTP1. Get( fFlileFlag + '\' + Trim( fieldbyname( pat1) . AsString) , JPStream) ;
2025-07-22 15:51:47 +08:00
except
2025-07-29 17:14:41 +08:00
Application. MessageBox( '<27> ͻ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , '<27> <> ʾ ' , MB_ICONWARNING) ;
2025-07-22 15:51:47 +08:00
IdFTP1. Quit;
Exit;
end ;
2025-07-29 17:14:41 +08:00
end
else
begin
Application. MessageBox( '<27> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , '<27> <> ʾ ' , MB_ICONWARNING) ;
IdFTP1. Quit;
Exit;
end ;
if IdFTP1. Connected then
IdFTP1. Quit;
JPStream. Position : = 0 ;
jpg. LoadFromStream( JPStream) ;
Image1. Picture. Assign( jpg) ;
2025-07-22 15:51:47 +08:00
end ;
end ;
end ;
finally
jpg. free;
JPStream. Free;
end ;
end ;
2025-07-29 17:14:41 +08:00
function TFormGetPic. SaveImage( ) : Boolean ;
2025-07-22 15:51:47 +08:00
var
2025-07-29 17:14:41 +08:00
myStream: TADOBlobStream;
maxNo: string ;
fNewFileName: string ;
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
fNewFileName : = formatdatetime( 'yyyyMMddhhnnsszzz' , now( ) ) + ExtractFileExt( FilePath) ;
if fkeyNO = '' then
fkeyNO : = fNewFileName;
result : = false ;
2025-07-22 15:51:47 +08:00
try
with adoqueryImage do
begin
close;
sql. Clear;
2025-07-29 17:14:41 +08:00
sql. Add( 'select * from TP_File where WBID=' + quotedstr( trim( fkeyNo) ) ) ;
sql. Add( 'and TFType=' + quotedstr( trim( FTFType) ) ) ;
2025-07-22 15:51:47 +08:00
open;
2025-07-29 17:14:41 +08:00
if RecordCount < = 0 then
2025-07-22 15:51:47 +08:00
begin
Append;
2025-07-29 17:14:41 +08:00
if GetLSNo( ADOQuery1, maxNo, 'FJ' , 'TP_File' , 4 , 1 ) = False then
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
Application. MessageBox( 'ȡ<> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> ' , '<27> <> ʾ ' , 0 ) ;
Exit;
2025-07-22 15:51:47 +08:00
end ;
fieldByName( 'TFID' ) . AsString : = maxNo;
fieldByName( 'WBID' ) . AsString : = fkeyNO;
end
else
begin
edit;
end ;
2025-07-29 17:14:41 +08:00
fieldByName( pat1) . AsString : = trim( fNewFileName) ;
fieldByName( 'Filler' ) . AsString : = trim( dName) ;
fieldByName( 'TFType' ) . AsString : = trim( FTFType) ;
2025-07-22 15:51:47 +08:00
myStream : = TADOBlobStream. Create( TBlobField( FieldByName( pic1) ) , bmWrite) ;
MyJpeg. Assign( Image2. Picture. Graphic) ;
MyJpeg. SaveToStream( myStream) ;
myStream. Free;
Post;
end ;
if FilePath < > '' then
begin
try
2025-07-29 17:14:41 +08:00
IdFTP1. Host : = ReadINIFileStr( 'SYSTEMSET.INI' , 'SERVER' , '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ' , '127.0.0.1' ) ;
IdFTP1. Username : = 'three' ;
IdFTP1. Password : = '641010' ;
IdFTP1. Connect( ) ;
IdFTP1. Put( FilePath, fFlileFlag + '\' + Trim( fNewFileName) ) ;
IdFTP1. Quit;
2025-07-22 15:51:47 +08:00
except
2025-07-29 17:14:41 +08:00
IdFTP1. Quit;
Application. MessageBox( '<27> ϴ<EFBFBD> <CFB4> ͻ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> ļ<EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , '<27> <> ʾ ' , MB_ICONWARNING) ;
2025-07-22 15:51:47 +08:00
end ;
end ;
IdFTP1. Quit;
2025-07-29 17:14:41 +08:00
result : = true ;
2025-07-22 15:51:47 +08:00
except
myStream. Free;
end ;
end ;
2025-07-29 17:14:41 +08:00
procedure TFormGetPic. TwainTwainAcquire( Sender: TObject; const Index : Integer ; Image: TBitmap; var Cancel: Boolean ) ;
2025-07-22 15:51:47 +08:00
begin
Image1. Picture. Assign( Image) ;
Cancel : = TRUE ;
CreThumb( 1 5 0 , 1 5 0 ) ;
SpeedButton2. Enabled : = TRUE ;
end ;
procedure TFormGetPic. FormShow( Sender: TObject) ;
var
Ini: TIniFile;
begin
{ Ini : = TIniFile. Create( ExtractFilePath( ParamStr( 0 ) ) + 'scanner.ini' ) ;
try
SelectedSource : = Ini. ReadInteger( 'SCANNER' , 'Scanner' , 0 ) ;
PicLeft : = Ini. ReadInteger( 'SCANNER' , 'Left' , 0 ) ;
PicTop : = Ini. ReadInteger( 'SCANNER' , 'Top' , 0 ) ;
PicWidth : = Ini. ReadInteger( 'SCANNER' , 'Width' , 1 0 0 ) ;
PicHeight : = Ini. ReadInteger( 'SCANNER' , 'Height' , 1 0 0 ) ;
finally
Ini. Free;
end ; }
Initimage( ) ;
end ;
{
procedure TFormGetPic. ToolButton6Click( Sender: TObject) ;
var
Ini: TIniFile;
begin
FormGetPos : = TFormGetPos. Create( Self) ;
FormGetPos. SpinEdit1. Value : = PicLeft;
FormGetPos. SpinEdit2. Value : = PicTop;
FormGetPos. SpinEdit3. Value : = PicWidth;
FormGetPos. SpinEdit4. Value : = PicHeight;
if FormGetPos. ShowModal = 1 then
begin
PicLeft : = FormGetPos. SpinEdit1. Value;
PicTop : = FormGetPos. SpinEdit2. Value;
PicWidth : = FormGetPos. SpinEdit3. Value;
PicHeight : = FormGetPos. SpinEdit4. Value;
Ini : = TIniFile. Create( ExtractFilePath( ParamStr( 0 ) ) + 'scanner.ini' ) ;
try
Ini. WriteInteger( 'SCANNER' , 'Left' , PicLeft) ;
Ini. WriteInteger( 'SCANNER' , 'Top' , PicTop) ;
Ini. WriteInteger( 'SCANNER' , 'Width' , PicWidth) ;
Ini. WriteInteger( 'SCANNER' , 'Height' , PicHeight) ;
finally
Ini. Free;
end ;
end ;
FormGetPos. Free;
end ;
}
procedure TFormGetPic. CreThumb( Width, Height: Integer ) ;
var
Bitmap: TBitmap;
Ratio: Double ;
ARect: TRect;
AHeight, AHeightOffset: Integer ;
AWidth, AWidthOffset: Integer ;
begin
Bitmap : = TBitmap. Create;
try
2025-07-29 17:14:41 +08:00
Ratio : = Image1. Picture. Graphic. Width / Image1. Picture. Graphic. Height;
2025-07-22 15:51:47 +08:00
if Ratio > 1.333 then
begin
2025-07-29 17:14:41 +08:00
AHeight : = Round( Width / Ratio) ;
AHeightOffset : = ( Height - AHeight) div 2 ;
2025-07-22 15:51:47 +08:00
AWidth : = Width;
AWidthOffset : = 0 ;
end
else
begin
2025-07-29 17:14:41 +08:00
AWidth : = Round( Height * Ratio) ;
AWidthOffset : = ( Width - AWidth) div 2 ;
2025-07-22 15:51:47 +08:00
AHeight : = Height;
AHeightOffset : = 0 ;
end ;
Bitmap. Width : = Width;
Bitmap. Height : = Height;
Bitmap. Canvas. Brush. Color : = clBtnFace;
Bitmap. Canvas. FillRect( Rect( 0 , 0 , Width, Height) ) ;
// StretchDraw original image
2025-07-29 17:14:41 +08:00
ARect : = Rect( AWidthOffset, AHeightOffset, AWidth + AWidthOffset, AHeight + AHeightOffset) ;
2025-07-22 15:51:47 +08:00
Bitmap. Canvas. StretchDraw( ARect, Image1. Picture. Graphic) ;
// Assign back to the Jpeg, and save to the file
2025-07-29 17:14:41 +08:00
Image2. Picture. Assign( Bitmap) ;
2025-07-22 15:51:47 +08:00
// MyJpeg1.Assign(Image2.Picture.Graphic);
finally
Bitmap. Free;
end ;
end ;
procedure TFormGetPic. FormCreate( Sender: TObject) ;
begin
MyJpeg : = TJpegImage. Create;
end ;
procedure TFormGetPic. FormDestroy( Sender: TObject) ;
begin
// MyJpeg1.Free;
MyJpeg. Free;
end ;
2025-07-29 17:14:41 +08:00
procedure TFormGetPic. Image1MouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ;
2025-07-22 15:51:47 +08:00
begin
ClickPos. x : = X;
ClickPos. y : = Y;
end ;
2025-07-29 17:14:41 +08:00
procedure TFormGetPic. Image1MouseMove( Sender: TObject; Shift: TShiftState; X, Y: Integer ) ;
2025-07-22 15:51:47 +08:00
var
NewPos: TPoint;
begin
{The left button was pressed}
if ssLeft in Shift then
begin
{Calculate new position}
2025-07-29 17:14:41 +08:00
NewPos. X : = Image1. Left + X - ClickPos. x;
NewPos. Y : = Image1. Top + Y - ClickPos. y;
2025-07-22 15:51:47 +08:00
if NewPos. x + Image1. Width < ScrollBox1. Width then
NewPos. x : = ScrollBox1. Width - Image1. Width;
if NewPos. y + Image1. Height < ScrollBox1. Height then
NewPos. y : = ScrollBox1. Height - Image1. Height;
2025-07-29 17:14:41 +08:00
if NewPos. X > 0 then
NewPos. X : = 0 ;
if NewPos. Y > 0 then
NewPos. Y : = 0 ;
2025-07-22 15:51:47 +08:00
Image1. Top : = NewPos. Y;
Image1. Left : = NewPos. X;
end {if ssLeft in Shift}
end ;
procedure TFormGetPic. SpeedButton1Click( Sender: TObject) ;
begin
if OpenPictureDialog1. Execute then
begin
Image1. Top : = 0 ;
Image1. Left : = 0 ;
Image1. Picture. LoadFromFile( OpenPictureDialog1. FileName) ;
2025-07-29 17:14:41 +08:00
FilePath : = OpenPictureDialog1. FileName;
FileName : = ExtractFileName( FilePath) ;
2025-07-22 15:51:47 +08:00
// CreThumb(240, 180);
CreThumb( 4 0 0 , 3 0 0 ) ;
SpeedButton2. Enabled : = TRUE ;
end ;
end ;
procedure TFormGetPic. SpeedButton2Click( Sender: TObject) ;
begin
2025-07-29 17:14:41 +08:00
if SaveImage( ) then
2025-07-22 15:51:47 +08:00
begin
ModalResult : = 1 ;
end
else
begin
2025-07-29 17:14:41 +08:00
application. MessageBox( '<27> <> <EFBFBD> ݱ<EFBFBD> <DDB1> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> ' , '<27> <> ʾ <EFBFBD> <CABE> Ϣ' , 0 )
2025-07-22 15:51:47 +08:00
end ;
// JPStream := TMemoryStream.Create;
// MyJPeg.Assign(Image1.Picture.Graphic);
// MyJPeg.SaveToStream(JPStream);
end ;
procedure TFormGetPic. SpeedButton3Click( Sender: TObject) ;
begin
ModalResult : = 2 ;
end ;
procedure TFormGetPic. Button1Click( Sender: TObject) ;
begin
hWndC : = 0 ;
try
2025-07-29 17:14:41 +08:00
hWndC : = capCreateCaptureWindowA( 'My Own Capture Window' , WS_CHILD or WS_VISIBLE, ScrollBox1. Left, ScrollBox1. Top, ScrollBox1. Width, ScrollBox1. Height, FormGetPic. Handle, 0 ) ;
2025-07-22 15:51:47 +08:00
if hWndC < > 0 then
begin
SendMessage( hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0 , 0 ) ;
SendMessage( hWndC, WM_CAP_SET_CALLBACK_ERROR, 0 , 0 ) ;
SendMessage( hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0 , 0 ) ;
SendMessage( hWndC, WM_CAP_DRIVER_CONNECT, 0 , 0 ) ;
SendMessage( hWndC, WM_CAP_SET_SCALE, 1 , 0 ) ;
SendMessage( hWndC, WM_CAP_SET_PREVIEWRATE, 6 6 , 0 ) ;
//SendMessage(hWndC, WM_CAP_SEQUENCE_NOFILE, 1, 0);
SendMessage( hWndC, WM_CAP_SET_OVERLAY, 1 , 0 ) ;
SendMessage( hWndC, WM_CAP_SET_PREVIEW, 1 , 0 ) ;
end
else
begin
2025-07-29 17:14:41 +08:00
application. MessageBox( '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͷʧ<CDB7> ܣ<EFBFBD> ' , '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ' , MB_ICONERROR) ;
2025-07-22 15:51:47 +08:00
end ;
except
end ;
application. ProcessMessages;
end ;
procedure TFormGetPic. Button2Click( Sender: TObject) ;
var
2025-07-29 17:14:41 +08:00
sFieldName: string ;
MBMP: TBitmap;
MJPG: TJpegImage;
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
sFieldName : = 'D:\ץͼ' ;
2025-07-22 15:51:47 +08:00
if not DirectoryExists( pchar( sFieldName) ) then
2025-07-29 17:14:41 +08:00
CreateDirectory( pchar( sFieldName) , nil ) ;
2025-07-22 15:51:47 +08:00
2025-07-29 17:14:41 +08:00
sFieldName : = sFieldName + '\' + formatdateTime( 'yyyyMMddhhnnss' , SGetServerDateTime( ADOQuery1) ) ;
2025-07-22 15:51:47 +08:00
2025-07-29 17:14:41 +08:00
FileName : = ExtractFileName( sFieldName) ;
2025-07-22 15:51:47 +08:00
if hWndC < > 0 then
begin
2025-07-29 17:14:41 +08:00
SendMessage( hWndC, WM_CAP_SAVEDIB, 0 , longint( pchar( sFieldName + '.BMP' ) ) ) ;
2025-07-22 15:51:47 +08:00
SendMessage( hWndC, WM_CAP_DRIVER_DISCONNECT, 0 , 0 ) ;
hWndC : = 0 ;
application. ProcessMessages;
try
2025-07-29 17:14:41 +08:00
MBMP : = TBitmap. Create;
MJPG : = TJpegImage. Create;
MBMP. LoadFromFile( pchar( sFieldName + '.BMP' ) ) ;
2025-07-22 15:51:47 +08:00
MJPG. assign( MBMP) ;
Image1. Picture. Bitmap. Assign( MJPG) ;
application. ProcessMessages;
2025-07-29 17:14:41 +08:00
MJPG. SaveToFile( pchar( sFieldName + '.JPG' ) ) ;
2025-07-22 15:51:47 +08:00
CreThumb( 2 4 0 , 1 8 0 ) ;
finally
MBMP. Free;
MJPG. Free;
2025-07-29 17:14:41 +08:00
if Fileexists( pchar( sFieldName + '.BMP' ) ) then
DeleteFile( pchar( sFieldName + '.BMP' ) ) ;
FilePath : = sFieldName + '.JPG' ;
FileName : = ExtractFileName( FilePath) ;
2025-07-22 15:51:47 +08:00
end ;
2025-07-29 17:14:41 +08:00
SpeedButton2. Enabled : = true ;
2025-07-22 15:51:47 +08:00
end ;
end ;
procedure TFormGetPic. SpeedButton4Click( Sender: TObject) ;
var
2025-07-29 17:14:41 +08:00
MJPG: TJpegImage;
pathFile: string ;
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
if Image1. Picture. Graphic = nil then
exit;
2025-07-22 15:51:47 +08:00
2025-07-29 17:14:41 +08:00
MJPG : = TJpegImage. Create;
2025-07-22 15:51:47 +08:00
try
2025-07-29 17:14:41 +08:00
SaveDialog1. FileName : = FileName;
2025-07-22 15:51:47 +08:00
if SaveDialog1. Execute then
begin
2025-07-29 17:14:41 +08:00
if SaveDialog1. FileName < > '' then
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
pathFile : = trim( SaveDialog1. FileName) ;
2025-07-22 15:51:47 +08:00
2025-07-29 17:14:41 +08:00
if ( RightStr( UPPERCASE( pathFile) , 4 ) < > '.JPG' ) and ( RightStr( UPPERCASE( pathFile) , 5 ) < > '.JPEG' ) then
2025-07-22 15:51:47 +08:00
begin
2025-07-29 17:14:41 +08:00
pathFile : = pathFile + '.JPG' ;
2025-07-22 15:51:47 +08:00
end ;
MJPG. Assign( Image1. Picture. Graphic) ;
if fileexists( pathFile) then
begin
2025-07-29 17:14:41 +08:00
if application. MessageBox( pchar( '<27> ļ<EFBFBD> [' + trim( pathFile) + ']<5D> Ѵ <EFBFBD> <D1B4> ڣ<EFBFBD> <DAA3> Ƿ<EFBFBD> Ҫ<EFBFBD> 滻<EFBFBD> <E6BBBB> <EFBFBD> <EFBFBD> ' ) , '<27> <> ʾ <EFBFBD> <CABE> Ϣ' , MB_YESNO + mb_iconinformation + MB_DEFBUTTON2) = idyes then
MJPG. SaveToFile( pathFile) ;
2025-07-22 15:51:47 +08:00
end
else
2025-07-29 17:14:41 +08:00
MJPG. SaveToFile( pathFile) ;
2025-07-22 15:51:47 +08:00
end ;
end ;
finally
MJPG. Free;
end ;
end ;
procedure TFormGetPic. SpeedButton5Click( Sender: TObject) ;
begin
try
with adoqueryImage do
begin
close;
sql. Clear;
2025-07-29 17:14:41 +08:00
sql. Add( 'select * from TP_File where WBID=' + quotedstr( trim( fkeyNo) ) ) ;
2025-07-22 15:51:47 +08:00
open;
2025-07-29 17:14:41 +08:00
if RecordCount > 0 then
2025-07-22 15:51:47 +08:00
begin
edit;
2025-07-29 17:14:41 +08:00
fieldByName( pat1) . Value : = null;
FieldByName( pic1) . Value : = null;
2025-07-22 15:51:47 +08:00
post;
Image1. Picture. Assign( nil ) ;
Image2. Picture. Assign( nil ) ;
end ;
end ;
except
end ;
end ;
end .
2025-07-29 17:14:41 +08:00