procedure TForm1.LoadPictureClick(Sender: TObject); // 上传图片begin OpenPictureDialog1.Title := '打开图片'; if OpenPictureDialog1.Execute then begin Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName); end;end;
procedure TForm1.ReadClick(Sender: TObject); // 读取图片var Stream:TMemoryStream; Jpg:TjpegImage;begin ADOQuery1.Close; ADOQuery1.SQL.Text:='SELECT * FROM test3 where id =' + editId.Text; // 查询图片 ADOQuery1.Open; if not ADOQuery1.FieldByName('photo').IsNull then begin Stream:=TMemoryStream.Create ; Jpg:=TjpegImage.Create ; TBlobField(ADOQuery1.FieldByName('photo')).SaveToStream(Stream); // 显示的转换为BlobField并保存到内存流 Stream.Position :=0; jpg.LoadFromStream(Stream); // 加载图片 image2.Picture.Assign(Jpg); end else begin image2.Picture :=nil; end;
请发表评论