Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   Delphi Fotopfad + GPS ermitteln unter Android (https://www.delphipraxis.net/200093-fotopfad-gps-ermitteln-unter-android.html)

Colin S 19. Mär 2019 10:56

Fotopfad + GPS ermitteln unter Android
 
Hallo zusammen,

ich versuche in meiner Android-App (unter D10.3) ein Bild aus der Galerie auszuwählen und die GPS-Daten (Lat und Long) abzufragen.

Mein Problem ist, dass ich als Pfad eine Cache-Datei zurück bekomme ohne EXIF-Daten!
z.B. '/data/user/0/com.embarcadero.Project1/cache/IMG_20190319_[...].jpg'

Das Bild liegt aber eigentlich unter /DCIM/Camera/ und heißt auch anders.

Hat jemand eine Idee?

Hier der Quellcode:

Delphi-Quellcode:
procedure TForm2.FormCreate(Sender: TObject);
begin
  TMessageManager.DefaultManager.SubscribeToMessage(TMessageReceivedImagePath, DidReceiveBitmap);
end;

procedure TForm2.TakePhotoFromLibraryAction1DidCancelTaking;
begin
  //
end;

procedure TForm2.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
begin
  Image1.Bitmap := Image;
end;

procedure TForm2.DidReceiveBitmap(const Sender: TObject; const M: TMessage);
var
  LMessage: TMessageResultNotification;
  LImagePath: String;
begin
  if M is TMessageReceivedImagePath then
  begin
    LMessage := TMessageResultNotification(M);
    LImagePath := (M as TMessageReceivedImagePath).Value; // <--- '/data/user/0/com.embarcadero.Project1/cache/IMG_20190319_[...].jpg'
    if LMessage.RequestCode = TJFMXMediaLibrary.JavaClass.ACTION_TAKE_IMAGE_FROM_LIBRARY then
    begin
      GetEXIF(LImagePath);
      Image2.Bitmap.LoadFromFile(LImagePath);
    end;
  end;
end;

procedure TForm2.GetEXIF(const AFileName: String);
var
  LEXIF: JExifInterface;
  LLatLong: TJavaArray<Single>;
begin
  LEXIF := TJExifInterface.JavaClass.init(StringToJString(AFileName));
  Memo1.Lines.Add('File: ' + AFileName);
  LLatLong := TJavaArray<Single>.Create(2);
  if LEXIF.getLatLong(LLatLong) then
  begin
    Memo1.Lines.Add('Latitude: ' +  LLatLong.Items[0].ToString);
    Memo1.Lines.Add('Longitude: ' +  LLatLong.Items[1].ToString);
  end;
  LLatLong.Free;
end;

Colin S 21. Mär 2019 09:42

AW: Fotopfad + GPS ermitteln unter Android
 
Crosspost: https://en.delphipraxis.net/topic/87...e-for-android/


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:16 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz