使用IFMXCameraService.TakePhoto,有没有办法获取图像路径?

Using IFMXCameraService.TakePhoto, is there a way of getting the image path?

这是我正在使用的代码。

procedure TForm1.getpic;
var
  Service: IFMXCameraService;
  Params: TParamsPhotoQuery;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService,
    Service) then
  begin
    Params.Editable := false;
    Params.NeedSaveToAlbum := True;
    Params.RequiredResolution := TSize.Create(640,640);
    Params.OnDidFinishTaking := DoDidFinishTakePic;
    Service.TakePhoto(nil, Params);
  end
  else
    xShowMessage('This device does not support the camera service');
end;

procedure TForm1.DoDidFinishTakePic(Image: TBitmap);
var
  Imagepath:string;
begin
  Image1.Bitmap.Assign(Image);
  Imagepath := fmx.platform.TMessageReceivedImagePath;
end;

显然来自:

http://docwiki.embarcadero.com/RADStudio/en/List_of_FireMonkey_Message_Types

在 fmx.platform 中找到了 TMessageReceivedImagePath。 但是我无法在任何地方找到它。我正在使用 10.1 Berlin update 2。我在 Embarcadero 论坛上发布了这个(谢谢 Remy 的回答),但我希望这里有人能给出答案。

PS/我也想把拍的照片的DateTime存起来

与此同时,我有一个解决方法,但它很难看,而且由于拍照的秒级精度,我肯定不会总是有效。

procedure TForm1.DoDidFinishTakePic(Image: TBitmap);
var
  Imagepath:string;
begin
  Image1.Bitmap.Assign(Image);
  st := datetimetostr(System.SysUtils.Now,xfs);
  Imagepath := 'IMG_'+copy(st,1,4)+copy(st,6,2)+copy(st,9,2)+'_'+copy(st,12,2)+copy(st,15,2)+copy(st,18,2)+'.jpg';
end;

正如我在 Embarcadero forum 中所述,您只需订阅 TMessageReceivedImagePath 消息,例如:

TMessageManager.DefaultManager.SubscribeToMessage(TMessageReceivedImagePath, DoMessageListener);

...

procedure TForm1.DoMessageListener(const Sender: TObject; const M: TMessage);
var
  ImagePath: string;
begin
  if M is TMessageReceivedImagePath then
  begin
    ImagePath := TMessageReceivedImagePath(M).Value;
    ...
  end;
end;

Embarcadero 记录消息在 FMX.Platform 单元中。如果在那里找不到它,请检查它是否在 FMX.Platform.Android 单元(因为它是 Android-specific 消息)或 FMX.MediaLibrary 单元(它定义了另一个 photo/video 捕获消息)。