Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: [X10-Fmx=Android] Recover the path of picture with Android


This question is answered.


Permlink Replies: 15 - Last Post: Feb 14, 2017 10:43 AM Last Post By: Remy Lebeau (Te...
Mario Gagne

Posts: 93
Registered: 2/17/12
[X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2016 12:36 PM
Hi

How to recover the path of an image photographed with android device for inclusion in a field of a table to retrieve later and display on screen.

Thank you

Mario
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-Fmx=Android] Recover the path of picture with Android
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2016 1:36 PM   in response to: Mario Gagne in response to: Mario Gagne
Mario wrote:

How to recover the path of an image photographed with android
device for inclusion in a field of a table to retrieve later and display
on screen.

Unfortunately, if you use FMX to take the photo (TTakePhotoFromCameraAction,
IFMXCameraService.TakePhoto()), you can't access the path or filename, as
FMX does not expose that information. You would have to resort to accessing
Android's Camera APIs directly, manually capturing pictures and saving them
to whatever file you want.

--
Remy Lebeau (TeamB)
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2016 12:48 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Am 09.01.2016 um 22:36 schrieb Remy Lebeau (TeamB):
Mario wrote:

How to recover the path of an image photographed with android
device for inclusion in a field of a table to retrieve later and display
on screen.

Unfortunately, if you use FMX to take the photo (TTakePhotoFromCameraAction,
IFMXCameraService.TakePhoto()), you can't access the path or filename, as
FMX does not expose that information. You would have to resort to accessing
Android's Camera APIs directly, manually capturing pictures and saving them
to whatever file you want.

Hm, I envision yet annother feature request in QP.... ;-)
...but that would be the task for the OP.

Greetings

Markus
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2016 1:39 PM   in response to: Mario Gagne in response to: Mario Gagne
How to recover the path of an image photographed with android device for inclusion in a field of a table to retrieve later and display on screen.

You'd need to "hack" into TImageManagerAndroid.DidReceiveBitmap in FMX.MediaLibrary.Android and use ImagePath.

This is something that has my interest. I've thought of a solution (a bit "hacky", however it would work) and could post back here if/when I'm ready.

--
Dave Nottage [TeamB]
Delphi Worlds blog: http://delphi.radsoft.com.au/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 11, 2016 9:32 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 10.01.2016 um 22:39 schrieb Dave Nottage:
How to recover the path of an image photographed with android device for inclusion in a field of a table to retrieve later and display on screen.

You'd need to "hack" into TImageManagerAndroid.DidReceiveBitmap in FMX.MediaLibrary.Android and use ImagePath.

This is something that has my interest. I've thought of a solution (a bit "hacky", however it would work) and could post back here if/when I'm ready.

Why not create an official feature request for access to it in an
orderly fashion, now that QP supports feature requests as category as
well? ;-)

Greetings

Markus
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 11, 2016 2:01 PM   in response to: Markus Humm in response to: Markus Humm
Why not create an official feature request for access to it in an
orderly fashion, now that QP supports feature requests as category as
well? ;-)

I'm sure someone could :-)

Meanwhile, it's patch-o-matic time..

--
Dave Nottage [TeamB]
Delphi Worlds blog: http://delphi.radsoft.com.au/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 12, 2016 8:54 AM   in response to: Dave Nottage in response to: Dave Nottage
Am 11.01.2016 um 23:01 schrieb Dave Nottage:
Why not create an official feature request for access to it in an
orderly fashion, now that QP supports feature requests as category as
well? ;-)

I'm sure someone could :-)

The best suited person would be the OP as he needs it and the 2nd best
would be you since you already know where EMBT has the data available,
at least it looks like this.

Greetings

Markus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 8, 2017 11:16 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
You'd need to "hack" into TImageManagerAndroid.DidReceiveBitmap in FMX.MediaLibrary.Android and use ImagePath.

No need to hack anymore. FireMonkey generates a TMessageReceivedImagePath message containing the ImagePath. you can subscribe to that event using TMessageManager.SubscribeToMessage():

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

FMX.Platform.TMessageReceivedImagePath

The Android implementation of FMX.Platform sends messages of this type when it receives a system notification about the user having taken a photo as a result of a call to IFMXCameraService.TakePhoto or IFMXTakenImageService.TakeImageFromLibrary, or executing an action to take a photo in your application.

These messages contain a string with the path to the taken picture.

If you call the method to obtain a picture from the device, and you do not specify an event handler for successfully obtaining a picture, this message is followed by one of the following messages:

TMessageDidFinishTakingImageFromCamera if you called IFMXCameraService.TakePhoto.

TMessageDidFinishTakingImageFromLibrary if you called IFMXTakenImageService.TakeImageFromLibrary.

--
Remy Lebeau (TeamB)
Shanil M

Posts: 62
Registered: 12/24/04
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 4:57 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
No need to hack anymore. FireMonkey generates a TMessageReceivedImagePath message containing the ImagePath. you can subscribe to that event using
http://docwiki.embarcadero.com/RADStudio/en/List_of_FireMonkey_Message_Types

Hi please provide some code how to use TMessageReceivedImagePath.

For example:

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);
begin
  Image1.Bitmap.Assign(Image);
end;


In this case with DoDidFinishTakePic, is it necessary to have this code?
TMessageManager.DefaultManager.SubscribeToMessage(TMessageDidFinishTakingImageFromCamera, DoMessageListener);
 
procedure TForm1.DoMessageListener(const Sender: TObject; const M: TMessage);
begin
  if M is TMessageDidFinishTakingImageFromCamera then
    Image1.Bitmap.Assign(TMessageDidFinishTakingImageFromCamera(M).Value);
end;


How to use TMessageReceivedImagePath? I can't even find it in the help or in any unit.

I also thought of using TImageInfo as it contains the datetime when the image was taken, and the filename structure can be generated from datetime, but I have no idea how to use TImageInfo since TImageInfo.DateTaken is a method (why?) and it puts the DateTaken where??

Also - it seems TMessageReceivedImagePath is not supported in iOS so how are we supposed to write multi-platform??
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 10:57 AM   in response to: Shanil M in response to: Shanil M
Shanil wrote:

In this case with DoDidFinishTakePic, is it necessary to have this code?

No, because you are assigning an OnDidFinishTaking callback when calling
TakePhoto(). If you don't assign a callback, then you can use a mesage handler
instead.

How to use TMessageReceivedImagePath?

You already know how to receive TMessageDidFinishTakingImageFromCamera messages.
Just do the same thing for TMessageReceivedImagePath messages, eg:

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;


I can't even find it in the help or in any unit.

TMessageReceivedImagePath is not fully documented, though it is mentioned
on the page I linked to earlier:

List of FireMonkey Message Types
http://docwiki.embarcadero.com/RADStudio/en/List_of_FireMonkey_Message_Types

It is apparently declared in the FMX.Platform unit.

I also thought of using TImageInfo as it contains the datetime when
the image was taken, and the filename structure can be generated
from datetime, but I have no idea how to use TImageInfo since
TImageInfo.DateTaken is a method (why?) and it puts the DateTaken
where??

TImageInfo provides read-only access to an image's metadata. They could
have done it as read-only properties, or as methods. I guess they simply
chose the latter.

On the other hand, the only way I can see to get a TImageInfo is from IFMXImageManagerService.GetImage(),
which is not very useful. Is there another way I'm missing to get a TImageInfo
for a given TBitmap?

Also - it seems TMessageReceivedImagePath is not supported in iOS

Nope, only on Android (same as TMessageDidFinishTakingImageFromCamera and
TMessageDidFinishTakingImageFromLibrary).

--
Remy Lebeau (TeamB)
Shanil M

Posts: 62
Registered: 12/24/04
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 13, 2017 10:23 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
TMessageReceivedImagePath is not fully documented, though it is mentioned
on the page I linked to earlier:
List of FireMonkey Message Types
http://docwiki.embarcadero.com/RADStudio/en/List_of_FireMonkey_Message_Types
It is apparently declared in the FMX.Platform unit.

Hi Remy

I can't find TMessageReceivedImagePath in FMX.Platform or anywhere else. I am using Berlin. It is listed in that link you posted, but if you click on FMX.Platform it is not there.

Has TMessageReceivedImagePath been replaced, or is there another way of getting the image path? I would think that image information is important.

So once this is done:
procedure TForm1.DoDidFinishTakePic(Image: TBitmap);
begin
  Image1.Bitmap.Assign(Image);
end;

I want a way of getting and storing information about the image, especially path and datetime captured.

thanks
Shanil
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2017 12:24 AM   in response to: Shanil M in response to: Shanil M
Shanil M wrote:
I can't find TMessageReceivedImagePath in FMX.Platform or anywhere else.

Did you check the FMX.Platform.Android unit? Or FMX.MediaLibrary?

Has TMessageReceivedImagePath been replaced

Not that I am aware of.

or is there another way of getting the image path?

No.

--
Remy Lebeau (TeamB)
Shanil M

Posts: 62
Registered: 12/24/04
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2017 12:42 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Did you check the FMX.Platform.Android unit? Or FMX.MediaLibrary?

It's not in FMX.MediaLibrary and the closest item in FMX.Platform.Android is TMessageReceivedNotification.

Do you have Berlin installed? Could you check please?

thanks
Shanil
Shanil M

Posts: 62
Registered: 12/24/04
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2017 3:01 AM   in response to: Shanil M in response to: Shanil M
OK you have declare both fmx.platform and fmx.platform.android in the uses clause and then it finds it. Weird you have to declare both the parent and child unit?

Furthermore it has to be declared like this:
{$IF DEFINED(ANDROID)}
  uses fmx.platform.android;
{$ENDIF}

else Windows compile does not find it.

Edited by: Shanil M on Feb 14, 2017 3:12 AM
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: [X10-Fmx=Android] Recover the path of picture with Android [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2017 4:00 AM   in response to: Shanil M in response to: Shanil M
Shanil M wrote:

OK you have declare both fmx.platform and fmx.platform.android in the uses clause and then it finds it. Weird you
have to declare both the parent and child unit?

Furthermore it has to be declared like this:
{$IF DEFINED(ANDROID)}
  uses fmx.platform.android;
{$ENDIF}

else Windows compile does not find it.

That unit will not compile for Windows, since it is not a Windows unit

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-Fmx=Android] Recover the path of picture with Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2017 10:43 AM   in response to: Shanil M in response to: Shanil M
Shanil wrote:

Do you have Berlin installed?

No, I do not, actually.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02