As far as I know, TDbf does not support the ftGraphic field type correctly. If you create the field as ftBLOB and use the following code for loading/saving intoa standard TImage, it works:
// Extracts an image from the database field with the name APictureFieldName and displays it in the given picture (e.g. Image1.Picture)
procedure TMainDatamodule.LoadPicture(APictureFieldName: String; APicture: TPicture);
var
stream: TStream;
begin
stream := Dbf1.CreateBlobStream(Dbf1.FieldByName(APictureFieldName), bmRead);
try
if stream.Size = 0 then
begin
APicture.Clear;
exit;
end;
stream.Position := 0;
APicture.LoadFromStream(stream);
finally
stream.Free;
end;
end;
// Stores the provided picture (e.g. Image1.Picture) in the database field FIconField.
procedure TMainDatamodule.StorePicture(PictureFieldName: String; APicture: TPicture);
var
stream: TStream;
begin
stream := TMemoryStream.Create;
try
APicture.SaveToStream(stream);
stream.Position := 0;
TBlobField(Dbf1.FieldByName(PictureFieldName)).LoadFromStream(stream);
finally
stream.Free;
end;
end;
If you have a TDBImage on the form you must replace it by a TImage. And you must provide handlers for database events, at least for AfterScroll and AfterOpen, to update the TImage when needed with the current record's picture by calling LoadPicture(Image1.Picture)
See the attachment for a simple worked-out example (Note that you must adjust the constant LAZARUS_DIR to the location of your lazarus installation; if your Laz version is too old you must also replace the "general_purpose" by another directory in the images folder of the installation).