参考下面程序:
procedure Tform1.UpdatePicToBlob();
var
JPEGImage: TJPEGImage;
BlobStream: TBlobStream;
bmp:TBitmap;
bmMode : TBlobStreamMode;
begin
try
if clipboard.HasFormat(CF_BITMAP) then
begin
bmp:=TBitmap.Create ;
JPEGImage:=TJPEGImage.Create ;
bmp.Assign(clipboard);
JPEGImage.Assign(bmp);
JPEGImage.Compress;
if table1.state=dsInsert then
bmmode:=bmWrite
else
begin
bmmode:=bmReadWrite;
Table1.edit;
end;
BlobStream := TBlobStream.Create(Table1zp, bmMode);
try
JPEGImage.SaveToStream(BlobStream);
Image1.Picture.Assign(JPEGImage);
finally
BlobStream.Free;
JPEGImage.Free ;
end;
table1.Post ;
end
else
Application.MessageBox('错误','Open Error',MB_OK + MB_DEFBUTTON1)
except
;
end;
end;