============================
procedure TForm1.SavePicture(Sender: TObject);
var MS : TMemoryStream;
begin
try
if Image1.Picture.Graphic <> nil then
begin
MS := TMemoryStream.Create;
Image1.Picture.Graphic.SaveToStream(MS);
MS.Seek(0, soFromBeginning);
//-------------------------------
TblobField(ZQuery1.FieldByName('Foto')).LoadFromStream(MS); //Foto adalah
Field dalam database
end;
finally
MS.Free;
end;
end;
2. Menampilkan Ke TImage
================================
procedure TForm1.BitBtn3Click(Sender: TObject);
var
Pic : Tjpegimage;
MS : TMemoryStream;
begin
if not ZQuery2.FieldByName('Foto').IsNull then
begin
try
Pic := TJpegImage.Create;
MS := TMemoryStream.Create;
TBlobField(ZQuery1.FieldByName('Foto')).SaveToStream(MS);
MS.Seek(0, soFromBeginning);
//----------------------------------------
Pic.LoadFromStream(MS);
Image1.Picture.Assign(Pic);
finally
Pic.Free;
MS.Free;
end;
end;
end;
No comments:
Post a Comment