5,386
社区成员
发帖
与我相关
我的任务
分享
procedure TForm2125.but_ReadPicClick(Sender: TObject);
var
mStream:TMemoryStream;
JpgFile:TjpegImage;
MyBmp: TBitmap;
begin
if cds_Main.ReadOnly then exit;
mstream:=TMemoryStream.Create;
JpgFile:=TjpegImage.Create ;
MyBmp:=TBitmap.Create;
if OpenDialog1.Execute then
begin
try
mstream.LoadFromFile(OpenDialog1.FileName);
mStream.Position :=0;
jpgfile.LoadFromStream(MStream);
cds_main.FieldByName('photo').Assign(JpgFile);
MyBmp.Assign(jpgfile);
MyBmp.Position :=0;{加了这句}
DBImage1.Picture.Bitmap.Assign(mybmp);
cds_main.Post;
finally
mstream.Free;
end;
end;
end;