我仔细看看
你先load一个JPG文件,再把它存为同名bmp文件
procedure TDBEnhancedImage.Loadjpg(FileName:String);
var
JPG: TJPEGImage;
Stream: TFileStream;
GraphicField : TGraphicField;
begin
GraphicField := TGraphicField(DataSource.DataSet.FieldByName(DataField));
JPG := TJPEGImage.Create;
try
JPG.LoadFromFile(FileName);
with TBitmap.Create do
try
Assign(JPG);
Stream := TFileStream.Create(ChangeFileExt(FileName,'.BMP'),fmCreate);
try
SaveToStream(Stream);
if (DataSource.DataSet.State <> dsInsert) or (DataSource.DataSet.State <> dsEdit) then
DataSource.DataSet.Edit;
GraphicField.LoadFromStream(Stream) ;
finally
Stream.Free
end
finally
Free
end
finally
JPG.Free
end
end;