Перейти к содержанию
Fire Monkey от А до Я

Kitty

Пользователи
  • Постов

    792
  • Зарегистрирован

  • Посещение

  • Победитель дней

    16

Сообщения, опубликованные Kitty

  1. Как-то оф.пример не до конца выписан:

    IFMXPhotoLibrary Service;
     if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXPhotoLibrary), &Service))
    	{
    	   Service->AddImageToSavedPhotosAlbum(Image1->Bitmap);
    	}

    [bcciosarm Error] UnitCamera.cpp(42): variable type 'Fmx::Medialibrary::IFMXPhotoLibrary' is an abstract class

    Сейчас покопаюсь в папке Sample...
     

     

     

  2. Тогда беру код из документации:

    http://docwiki.embarcadero.com/Libraries/Berlin/en/FMX.MediaLibrary.IFMXPhotoLibrary.AddImageToSavedPhotosAlbum

    #include <FMX.MediaLibrary.hpp>
    
    //***
    if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXPhotoLibrary), &Service))//<-- ошибка
    	{
    	   Service->AddImageToSavedPhotosAlbum(Image1->Bitmap);
    	}

    А он выдает почему то ошибки компиляции:

    [bcciosarm Error] UnitCamera.cpp(42): cannot take the address of an rvalue of type 'System::Beacon::TKindofScanFilter'

    [bcciosarm Error] UnitCamera.cpp(44): member reference type 'System::Beacon::TKindofScanFilter' is not a pointer

    Комментирую код и ошибка пропадает...

  3. (iOS)

    Интересная особенность. У акшина TakePhotoFromCameraAction1 стоит NeedSaveToAlbum=true. Т.е. снимок автоматически сохраняется на телефоне. Так вот на телефоне снимок сохраняется без логотипа. Не критично, но не понятно. :)

  4. В VCL проекте код ниже накладывает логотип на фотографию в правый верхний угол:

    //В Image1 загружена основная фотография
    //В Image2 загружен png логотип
    
    //щелчок по кнопке
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    
    	TRectF SrcRect(0,0,Image2->Width, Image2->Height);
    	// Ищем коэффициенты мастаба картинки по ширине и высоте
    	double kWidth = Image1->MultiResBitmap[0].Width / Image1->Width;
    	double kHeight = Image1->MultiResBitmap[0].Height / Image1->Height;
    	double Koef = Max(kWidth,kHeight) / 2; // выбираем максимальный коеффициент и делим на 2
    	double TopLeft = Image1->MultiResBitmap[0].Width - Image2->Width * Koef;
    	TRectF DstRect(TopLeft,20,TopLeft + Image2->Width * Koef - 20, Image2->Height * Koef);
    
    	Image1->Bitmap->Canvas->BeginScene();
    	Image1->Bitmap->Canvas->DrawBitmap(Image2->Bitmap, SrcRect, DstRect, 1);
    	Image1->Bitmap->Canvas->EndScene();
    
    }

    Я хочу наложить логотип в мобильном приложении на фотографию сразу после снимка:

    void __fastcall TFormCamera::TakePhotoFromCameraAction1DidFinishTaking(TBitmap *Image)
    {
     Image1->Bitmap->Assign(Image);
    
     if(Image1->Bitmap->IsEmpty())
    	return;
    
      ShowMessage(L"Мы здесь");
    
    	//логотип на фото
    	TRectF SrcRect(0,0,Form1->Image2->Width, Form1->Image2->Height);
    	// Ищем коэффициенты мастаба картинки по ширине и высоте
    	double kWidth = Image1->MultiResBitmap[0].Width / Image1->Width;
    	double kHeight = Image1->MultiResBitmap[0].Height / Image1->Height;
    	double Koef = Max(kWidth,kHeight) / 2; // выбираем максимальный коеффициент и делим на 2
    	double TopLeft = Image1->MultiResBitmap[0].Width - Form1->Image2->Width * Koef;
    	TRectF DstRect(TopLeft,20,TopLeft + Form1->Image2->Width * Koef - 20,
    										Form1->Image2->Height * Koef);
    
    	Image1->Bitmap->Canvas->BeginScene();
    	Image1->Bitmap->Canvas->DrawBitmap(Form1->Image2->Bitmap, SrcRect, DstRect, 1);
    	Image1->Bitmap->Canvas->EndScene();
    
    }

    Однако логотипа на фото не получаю.

    Как наложить логотип на фото сразу после сделанного снимка в мобильном приложении?

    Спасибо.

  5. Согласно документации из PDF собиралась реализовать звонок по клику по метке.

    Первое, что надо сделать это добавить:

    #include <FMX.Platform.hpp>
    #include <FMX.PhoneDialer.hpp>

    После этого приложение перестает запускаться, падает на заставке.

    Если  закомментировать строку #include <FMX.PhoneDialer.hpp> то приложение снова нормально запускается.

    Как исправить?

    Может важен порядок файлов? Сейчас так:
     

    #include <System.Classes.hpp>
    #include <FMX.Controls.hpp>
    #include <FMX.Forms.hpp>
    #include <FMX.ExtCtrls.hpp>
    #include <FMX.Layouts.hpp>
    #include <FMX.Types.hpp>
    #include <FMX.Controls.Presentation.hpp>
    #include <FMX.Memo.hpp>
    #include <FMX.ScrollBox.hpp>
    #include <FMX.StdCtrls.hpp>
    #include <FMX.Objects.hpp>
    #include <System.Beacon.Components.hpp>
    #include <System.Beacon.hpp>
    #include <System.Bluetooth.hpp>
    #include <System.Notification.hpp>
    
    #include <FMX.Platform.hpp>
    //#include <FMX.PhoneDialer.hpp> //если убрать комментарий приложение сразу падает
    
    //---------------------------------------------------------------------------
    class TForm1 : public TForm
    {
      //***

    С++ Builder 10.1 Update 1.

  6. Приложение делает фотографию и эта фотография попадает в TImage. Потом этой фотографией можно поделиться в соц.сетях.

    Можно ли сразу после получения снимка, на фотографию наложить изображение  (маленький логотип) чтобы фотография получилась с наложенным на нее изображением в углу?

    Спасибо.

  7. Попробовала этот код вставив в него работу TBeacon:

    unit Unit1;
    
    interface
    
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.Platform,
      BackgroundTaskManager, System.Beacon, System.Bluetooth,
      System.Beacon.Components;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Timer1: TTimer;
        Beacon1: TBeacon;
        procedure Timer1Timer(Sender: TObject);
        procedure Beacon1BeaconEnter(const Sender: TObject; const ABeacon: IBeacon;
          const CurrentBeaconList: TBeaconList);
        procedure Beacon1BeaconExit(const Sender: TObject; const ABeacon: IBeacon;
          const CurrentBeaconList: TBeaconList);
      private
        FManager: TBackgroundTaskManager;
        function ApplicationEventHandler(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
        procedure SetApplicationEventHandler;
        procedure Start;
        procedure Stop;
        procedure TaskExpiryHandler(Sender: TObject);
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.fmx}
    
    uses
      FMX.Helpers.iOS;
    
    { TForm1 }
    
    procedure TForm1.Beacon1BeaconEnter(const Sender: TObject;
      const ABeacon: IBeacon; const CurrentBeaconList: TBeaconList);
    begin
      Memo1.Lines.Add('Вход');
    end;
    
    procedure TForm1.Beacon1BeaconExit(const Sender: TObject;
      const ABeacon: IBeacon; const CurrentBeaconList: TBeaconList);
    begin
     Memo1.Lines.Add('Выход');
    end;
    
    constructor TForm1.Create(AOwner: TComponent);
    begin
      inherited;
      SetApplicationEventHandler;
      FManager := TBackgroundTaskManager.Create;
      FManager.OnExpiry := TaskExpiryHandler;
      Beacon1.Enabled := True;
    end;
    
    destructor TForm1.Destroy;
    begin
      FManager.Free;
      inherited;
    end;
    
    procedure TForm1.SetApplicationEventHandler;
    var
      LService: IFMXApplicationEventService;
    begin
      if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, LService) then
        LService.SetApplicationEventHandler(ApplicationEventHandler);
    end;
    
    procedure TForm1.Start;
    begin
      FManager.Start;
      Memo1.Lines.Add(Format('Time left: %.2f', [SharedApplication.backgroundTimeRemaining]));
      Beacon1.Enabled := True;
      Timer1.Tag := 0;
      Timer1.Enabled := True;
    end;
    
    procedure TForm1.Stop;
    begin
      Timer1.Enabled := False;
      FManager.Stop;
    end;
    
    procedure TForm1.TaskExpiryHandler(Sender: TObject);
    begin
      Memo1.Lines.Add('Oops! Expired');
    end;
    
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      Timer1.TagFloat := Timer1.TagFloat + Timer1.Interval / 1000;
      Memo1.Lines.Add(Format('Hopefully still running - %.0f', [Timer1.TagFloat]));
      if Timer1.TagFloat > 200 then
      begin
        Memo1.Lines.Add('Been running long enough..');
        Stop;
      end;
    end;
    
    function TForm1.ApplicationEventHandler(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
    begin
      case AAppEvent of
        TApplicationEvent.EnteredBackground:
        begin
          Memo1.Lines.Add('Entered Background');
          Start;
          Result := True;
        end;
        TApplicationEvent.WillBecomeForeground:
        begin
          Stop;
          Memo1.Lines.Add('Becoming foreground, so I told iOS that I am not running a background task any more');
          Result := True;
        end;
      else
        Result := False;
      end;
    end;
    
    end.

    Тестирование показало, что при переводе приложения в фон, сразу происходит выход из зоны т.е. TBeacon перестает работать в фоне.

    А тут в документации говориться, что TBeacon работает в фоне:

    https://developer.apple.com/ibeacon/Getting-Started-with-iBeacon.pdf

    Q:   If my app starts monitoring beacon
     regions, how will that affect battery performance?
    A
    :   iOS devices that support iBeacon can efficiently monitor iBeacon regions in the background
    with marginal power drain. Monitoring iBeacon regions is significantly less power
    demanding than running normal location updates constantly in the background. 

    Не понятно почему не работает...

     

  8. Удалось получить вибрацию на С++ Builder. Вот такие настройки путей оказались правильными. Просто перебором вариантов нашла такое решение.

    При этом возникло диалоговое окно, что есть более новая версия файла AudioToolbox. Я согласилась с заменой. Компиляция проекта прошла успешно. Вибро сработало.

    #include <fmx.h>
    #pragma hdrstop
    
    #include "UVibrate.hpp" <-- на основании *.pas в этой теме
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.fmx"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
    	: TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      Vibrate();
    }

    pic.jpg

  9. Цитата

    Проверить, что либы, которые скачены па сервером на ваш компьютер актуальны и соответствуют требуемой архитектуре.

    Подскажите, пожалуйста, поподробнее какова последовательность действий такой проверки. Где и как смотреть либы и архитектуру? Спасибо.

  10. Еще такой вариант попробовала как на картинке, но теперь уже с другой ошибкой:

    [ld Error] ld: file was built for i386 which is not the architecture being linked (armv7): C:\Users\Lena\Documents\Embarcadero\Studio\SDKs\iPhoneOS10.0.sdk\System\Library\Frameworks/AudioToolbox.framework/AudioToolbox for architecture armv7

     

    123.jpg

  11. Не правильно добавляла путь. Надо так:

    Tools->Options->SDK Manager->click Add the new path item

    path on remote machine : /System/Library/Frameworks/AudioToolbox.framework
    File masks: *
    path type: Other path
    include subdirectories: unchecked
    Источник: https://forums.embarcadero.com/thread.jspa?threadID=88902

    Однако избавиться от ошибки при компиляции так и не удалось:

    [ld Error]   Error: "_AudioServicesPlaySystemSound", referenced from:      __ZN8Uvibrate28AudioServicesPlaySystemSoundEi in .\\iOSDevice32\\Debug\\UVibrate.o;

    [ld Warning] ld: symbol(s) not found for architecture armv7

     

     

  12. Вот, что в том файле:

    uses
      Macapi.CoreFoundation,
      Macapi.CoreServices,
      Macapi.Dispatch,
      Macapi.Foundation,
      Macapi.Mach,
      Macapi.ObjCRuntime,
      Macapi.ObjectiveC,
      Macapi.QuartzCore,
      iOSapi.AudioUnit,
      iOSapi.CocoaTypes,
      iOSapi.CoreAudio,
      iOSapi.CoreMIDI,
      iOSapi.Foundation;

     

    Дополнительно к файлу iOSapi.AudioToolbox.pas  скопировала в папку с проектом еще два файла:

    iOSapi.CoreFoundation.pas

    iOSapi.Foundation.pas

     

    [DCC Fatal Error] iOSapi.AudioToolbox.pas(22): F2613 Unit 'Macapi.Foundation' not found.

  13. А вот еще попробовал рекомендацию ZuBy и взяла файл iOSapi.AudioToolbox.pas по его ссылке:

    https://github.com/FMXExpress/ios-object-pascal-wrapper

    Добавила в проект и пробовала получить hpp, но ошибка:

    [DCC Fatal Error] iOSapi.AudioToolbox.pas(22): F2613 Unit 'Macapi.Foundation' not found.

     

  14. Если взять отсюда два файла:

    https://github.com/EmbarcaderoPublic/CppArcadeGames/blob/master/Classic/AlienInvasionClassic/AudioManager.cpp

    Добавить срр в проект:

    #include <fmx.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    #include "AudioManager.h"
    
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.fmx"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
    	: TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
     //C++ Builder не понимает константу kSystemSoundID_Vibrate
      AudioServicesPlaySystemSound(1);
    }
    //---------------------------------------------------------------------------

    И результат:

    [ld Error]   Error: "_AudioServicesPlaySystemSound", referenced from:      __ZN6TForm112Button1ClickEPN6System7TObjectE in .\\iOSDevice32\\Debug\\Unit1.o;

    [ld Warning] ld: symbol(s) not found for architecture armv7

    :(

  15. На основании сылки *.pas файл подключаю к проекту:

    http://community.embarcadero.com/blogs/entry/how-to-vibrate-ios-and-android-phones-using-firemonkey-and-xe8

    unit UVibrate;
     
    interface
     
    procedure Vibrate;
     
    implementation
     
    {$IFDEF ANDROID}
    uses
      Androidapi.JNI.Os,
      Androidapi.JNI.GraphicsContentViewText,
      Androidapi.Helpers,
      Androidapi.JNIBridge;
    {$ENDIF}
    {$IFDEF IOS}
    uses
      IOSapi.MediaPlayer,
      IOSapi.CoreGraphics,
      FMX.Platform,
      FMX.Platform.IOS,
      IOSapi.UIKit,
      Macapi.ObjCRuntime,
      Macapi.ObjectiveC,
      iOSapi.Cocoatypes,
      Macapi.CoreFoundation,
      iOSapi.Foundation,
      iOSapi.CoreImage,
      iOSapi.QuartzCore,
      iOSapi.CoreData;
    {$ENDIF}
     
    {$IFDEF IOS}
    const
      libAudioToolbox = '/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox';
      kSystemSoundID_vibrate = $FFF;
     
    procedure AudioServicesPlaySystemSound( inSystemSoundID: integer ); cdecl; 
    External libAudioToolbox Name _PU + 'AudioServicesPlaySystemSound';
    {$ENDIF}
     
    procedure Vibrate;
    {$IFDEF ANDROID}
    var
      Vibrator: JVibrator;
    {$ENDIF}
    begin
    {$IFDEF ANDROID}
      Vibrator := TJVibrator.Wrap((SharedActivityContext.getSystemService(TJContext.JavaClass.VIBRATOR_SERVICE) 
    as ILocalObject).GetObjectID);
      // Vibrate for 500 milliseconds
      Vibrator.vibrate(500);
    {$ENDIF}
    {$IFDEF IOS}
      AudioServicesPlaySystemSound( kSystemSoundID_vibrate );
    {$ENDIF}
    end;
     
    end.

    Подключаю этот *.pas к проекту C++ и компилирую. Полученный hpp файл включаю в проект:

    #include "UVibrate.hpp"
    #include "Unit1.h"
     
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      Vibrate();
    }

    Теперь ошибка, которую не знаю как исправить. Может кто знает?

    [ld Error] Error: "_AudioServicesPlaySystemSound", referenced from: __ZN8Uvibrate28AudioServicesPlaySystemSoundEi in .\ \iOSDevice32\ \Debug\ \UVibrate.o;
    [ld Warning] ld: symbol(s) not found for architecture armv7

  16. Цитата

    The project cannot be loaded because the required Personality Delphi.Personality is not available

    Это древняя не исправимая ошибка. Чтобы она не происходила надо открывать проект в студии, а не в C++ Builder.

  17. Какие настройки в проекте IOS надо сделать чтобы при переводе приложения на задний фон, работоспособность компонента TBeacon сохранялась.

    Т.е. чтобы гарантировано происходили события компонента TBeacon - вход/выход из зоны (OnBeaconBeaconEnter и др.).

    В андроиде эти события происходят и тогда, когда приложение переведено в фон.

     

×
×
  • Создать...