procedure TDbJPEGImage.DoUpdateData;
var Fld: TBlobField;
Strm: TMemoryStream;
Jpeg: TJPEGImage;
begin
if not Assigned(FDataLink.DataSet) then
Exit;
if not (FDataLink.Field is TBlobField) then
Exit;
Fld := FDataLink.Field as TBlobField;
Strm := TMemoryStream.Create();
Jpeg := TJPEGImage.Create();
try
if (Picture = nil) or
(Picture.Graphic = nil) then
begin
Fld.Clear();
end
else
begin
Jpeg.Assign(Picture.Graphic);
Jpeg.SaveToStream(Strm);
Strm.Position := 0;
Fld.LoadFromStream(Strm);
end;
finally
Strm.Free();
Jpeg.Free();
end;
end;
procedure TDbJPEGImage.DoDataChange(Sender: TObject);
var Fld: TBlobField;
Strm: TMemoryStream;
Jpeg: TJPEGImage;
begin
if not (FDataLink.Field is TBlobField) then
Exit;
Fld := FDataLink.Field as TBlobField;
if Fld.IsNull then
begin
Picture := nil;
Exit;
end;