In my Firebird database I have a Blob field that contain a Bitmap. I'll have to load and display in a TImage located on my Form. Subsequently I'll have to save in the same field the image selected by a OpenDialog.
Procedure LoadBitmapFromBlob(Bitmap: TBitmap; Blob: TBlobField);
var
ms, ms2: TMemoryStream;
begin
ms := TMemoryStream.Create;
try
Blob.SaveToStream(ms);
ms.Position := 0;
Bitmap.LoadFromStream(ms);
finally
ms.Free;
end;
end;
example usage
procedure TForm4.Button1Click(Sender: TObject);
var
bmp: TBitmap;
begin
bmp := TBitmap.Create;
try
LoadBitmapFromBlob(bmp, TBlobField(Dataset.FieldByName('Image')));
Image1.Picture.Assign(bmp);
bmp.SaveToFile(OpenDialog.FileName);
finally
bmp.Free;
end;
end;