将JPG格式图片保存到ACCESS数据表中
var
Ind,i:Integer;
FName:string;
AJPeg:TJPEGImage;
temp:TBitmap;
begin
if opd1.Execute then
begin
btnAdd.Enabled:=False;
Ind:=Opd1.Files.Count;
for i:=0 to Ind-1 do
begin
FName:=opd1.Files.Strings;
Application.ProcessMessages;
tbl1.Append;
tblPictureName.AsString:=FName;
if UpperCase(Copy(FName,Length(Fname)-3,4))=’.JPG’ then
begin
AJpeg:=TJPEGImage.Create;
AJpeg.LoadFromFile(FName);
Temp:=TBitmap.Create;
Image1.Height:=Ajpeg.Height;
Image1.Width:=Ajpeg.Width;
Image1.Picture:=nil;
Image1.Canvas.Draw(0,0,Ajpeg);
DBImage1.Picture:=Image1.Picture;
AJpeg.Free;
end
else
tblPicture.LoadFromFile(FName);
tbl1.Post;
end;
end;
说明:
tbl1:TADOQuery;
opd1:TOpenPictureDialog;
tblPicture是tbl1的字段,OLE型。
uses
JPEG;