首先要用Gif得有控件Rx_Lib;Gif89a...
保存到数据库,从数据库读取的方法:
1.将BLOB字段的GIf图显示出来
(1)直接显示当前记录
procedure TForm1.Button1Click(Sender: TObject);
begin
Image1.Picture.Bitmap.Assign(Table1Bitmap);
end;
(2)直接显示
procedure TForm1.Button1Click(Sender: TObject);
begin
Image1.Picture.Bitmap.Assign(TBLOBField(Table1.Fields[1]));
end;
(3)不直接显示
procedure TForm1.Button2Click(Sender: TObject);
var
B: TBitmap;
begin
B := TBitmap.Create;
try
B.Assign(Table1Bitmap);
Image1.Picture.Bitmap.Assign(B);
finally
B.Free;
end;
end;
2.将Gif放入BLOB字段的方法:
(1)使用裁剪板
procedure TForm1.Button1Click(Sender: TObject);
var
C: TClipboard;
begin
C := TClipboard.Create;
try
if Clipboard.HasFormat(CF_BITMAP) then
DBImage1.PasteFromClipboard
else
ShowMessage('Clipboard does not contain a bitmap!');
finally
C.Free;
end;
end;
(2)从文件调入
procedure TForm1.Button2Click(Sender: TObject);
begin
Table1Bitmap.LoadFromFile(
'c:/delphi/images/aaa.gif');
end;
(3)从其他控件的BITMAP类中读入
procedure TForm1.Button3Click(Sender: TObject);
var
B: TBitmap;
begin
B := TBitmap.Create;
try
B.LoadFromFile('c:/delphi/images/aaa.gif');
DBImage1.Picture.Assign(B);
finally
B.Free;
end;
end;