Jump to content

JGMS

Members
  • Content Count

    43
  • Joined

  • Last visited

Posts posted by JGMS


  1. Thank you @Serge_G and @sjordi for taking time to answer.
     

    Initially I had FMX installed by using the installer V1.77 that comes with the updates that I got from the original developer (I bought a lifetime version a couple of years ago). It always ran perfect, except for this time.

    Because of the error I subsequently installed it via GetIT (V1.76), but this yielded the same error.
    I quess things will get better after a fresh installation of the latest update to Delphi version 12.1.

    I will keep you informed.

     


    I


  2. Quote

    I have installed FmxLinux, got the PaServer up and running (D12 in Windows11, WSL2, Ubuntu22.04) and added and selected the LinuxPlatform in a new, multi-device, blank application: a form with a single button.

    In the project file (shown below) the problem is already hinted, showing:  'E2212: Package unit "FMX.Forms" cannot appear in contains or uses clauses'.

    FireMonkey applications for Windows run fine, so FMX package units cannot be missing.

    What can be wrong?

     

    
    program Project1;
    
    uses
      System.StartUpCopy,
      FMX.Forms, <<== design-time error hint 'E2212: Package unit "FMX.Forms" cannot appear in contains or uses clauses'
      Unit1 in 'Unit1.pas' {Form1};
    
    {$R *.res}
    
    begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.fmx}
    
    end.

     

     


  3. When I create an FMX application with a StringGrid and a BindNavigator with an Onclick event, the latter sets TBindNavigatebutton as parameter rather than TNavigateButton.
    The former comes from the unit Fmx.Bind.Navigator and the latter from Data.Bind.Controls.

    This leaves the question: is there a way to let the compiler accept both parameters?


  4. image.thumb.png.db926739f827a6c155a3d09d90414f7c.png

    image.thumb.png.150c8a5e57408f83143f7ea8d1d47cfc.png

    These are the error messages I got. In common: '...has an incompatible parameter list....

    There are a number of TBindnavigators on the form connected to TStringGrids in an FMX 32 bits Windows application.

     

    The events that are connected to the BindNavigators from within the Object Inspector are defined by

      procedure TForm1.BindNavigatorBeforeAction(Sender: TObject;  Button: TNavigateButton);

    and

      procedure TForm1.BindNavigatorClick(Sender: TObject;  Button: TNavigateButton);


    If I'd click 'Yes' I will loose the LiveBindings connections. I don't even want to think of that!


  5. Thank you @Uwe Raabe 

    I preceded the respective constants in the code with 'TFDCommandKind." to overcome this problem.
    I am surprised that the Delphi 12 requires the user to make code adjustments due to changes in the compiler. This is so unlike Delphi!
    Another surpise that I face a problem due to changes in the BindNavigatorBeforeAction and BindNavigatorClick events: they fail because their parameters (Sender asTobject;  Button: TNavigateButton)  are no longer accepted!

    In Delphi 11.3 my code runs flawless!

    Might I ask whether you know what to do about this?

    May thanks, Jan


  6. Integer constants as defined in "TFDPhysCommandKind" in unit 'FireDAC.Phys.Intf' in Delphi 11.3 and below, appear to be missing in Delphi 12.

     

    TFDPhysCommandKind = (skUnknown, skSelect, skSelectForLock, skSelectForUnLock,
        skDelete, skInsert, skMerge, skUpdate, skCreate, skAlter, skDrop, skStoredProc,
        skStoredProcWithCrs, skStoredProcNoCrs, skExecute, skStartTransaction,
        skCommit, skRollback, skSet, skSetSchema, skOther, skNotResolved);

    Does anybody know what has happened to them? Any idea where to find them?
    Thanks ahead.


  7. The very day after my first post PowerPDF was available via GetIt.
    I removed the GitHub version and re-installed it through GetIt.

    However, the same "Class Arial not found" message pops up when trying to drop a TPrPage component on a form.

    Arial is a standard font and cannot be removed nor reinstalled. Moreover, it is not missing.

    Hence it does not seem te be a Windows 11 issue, but rather something wrong in PowerPDF.

    Can anyone help me with some hints? Please...


  8. I have installed PowerPDF in Delphi 12 via GitHub. The master package in Git seems to be made ready for Delphi12 (there is an 11AndAbove subdir).

    In previous Delphi versions I used to install PowerPDF via GetIt, but the package still is not available. After about 3 months I can no longer wait.

     

    Anyway, it looks like the installation was a success: all controls are in place, and I can drop a TPrReport component on a form.

    However, the next step, i.e. to drop a TPrPage, fails, showing the "Class Arial not found" message.

    Since a TPrPage is the container for all other PowerPDF controls, the package is unusable.

     

    I have no idea how to get it to work. Do you?
    I very much appreciate your help or hints.

     


  9. L.S.,
    I have downloaded the String4D repository, and tried to install it in Delphi 12, using the tool "Build.exe".

    It failed, showing the message "Failed to build the task: Packages\Delphi12\Spring4D.groupproj".

     

    What can I do? Please help.




     


  10. I have found the solution to get the original posted code to work just fine, by adding 1 line right before the return in ProcessImage:

     

    Add('  new_im.format = "JPEG"');

    Very simple, in hindsight. Any way, I learned a lot.
    However, I did not find a way to delete or update the 'miniproject' files, as yet.


  11. Thank you @pyscripter
    .
    The  code line "if PyBytes_AsStringAndSize(presult, P, Len) < 0 then" results the Delphi error "Project ... raised exception class $C0000005 with message 'c0000005 ACCESS_VIOLATION'.", since "presult" is an empty Pansichar.

    GetPythonEngine.CheckError results "Runtime error 201 at ...".

     

    I will prepare a minimal project later today, and will study demo 35 as well.


  12. I try to use P4D Demo 29 as the basis for image handling functions.
    The demo code works like a charm for PIL-based functions, but I can't get it to deal with CV2 (OpenCV) functions. I added the conversions of the PIL- to a CV2-image (OpenCV) and the reverse after processing, but apparently, I missed a clue.

     

    In the mainform there is a Timage (image1) that is passed as a Var parameter to the gamma correction function:
      PyForm.PyGammaCorrection( Image1, gammasetting ); {e.g. range between 0.05 and 2}
     

    I have prepared and successfully tested all Python code in PyScripter.👌

     Hence the problem is in the Delphi part of the routine.

    Here is my code:

    
    function TPyForm.ImageToPyBytes(AGraphic : TGraphic) : Variant;
    var
      _stream : TMemoryStream;
      _bytes : PPyObject;
    begin
      _stream := TMemoryStream.Create();
      try
        AGraphic.SaveToStream(_stream);
        _bytes := GetPythonEngine.PyBytes_FromStringAndSize( _stream.Memory, _stream.Size );
        Result := VarPythonCreate(_bytes);
        GetPythonEngine.Py_DECREF(_bytes);
      finally
        _stream.Free;
      end;
    end;
    /////////////////////////////////////////////////////////////////////////
    
    
    procedure TPyForm.PyGammaCorrection(VAR Image1 : Timage; Setting: double );
    var
      _im : Variant;
      _stream : TMemoryStream;
      pargs: PPyObject;
      presult :PPyObject;
      P : PAnsiChar;
      Len : NativeInt;
      PythonCode : TstringList;
    
    begin
    
     TRY
      PythonCode := TstringList.Create;
    	 With PythonCode DO
    	 begin
    	   Add('from PIL import Image' );
    	   Add('import cv2 ');
    	   Add('import numpy as np ');
    	   Add('from io import BytesIO' );
    
    	   Add('def adjust_gamma(image, gamma=1.0): ');
    	   Add('  invGamma = 1.0 / gamma ');
    	   Add('  table = np.array([((i / 255.0) ** invGamma) * 255 for i in np.arange(0, 256)]).astype("uint8")  ');
    	   Add('  return cv2.LUT(image, table) ');
    
    	   Add('def ImageToBytes(image):' );
    	   Add('  stream = BytesIO()' );
    	   Add('  image.save(stream, image.format)' );
    	   Add('  return stream.getvalue()');
    
    	   Add('def get_opencv_img_from_buffer(buffer, flags): ');
    	   Add('  bytes_as_np_array = np.frombuffer(buffer.read(), dtype=np.uint8) ');
    	   Add('  return cv2.imdecode(bytes_as_np_array, flags) ');
    
    	   Add('def ProcessImage(data):');
    	   Add('  img = get_opencv_img_from_buffer(BytesIO(data), cv2.COLOR_RGB2BGR) ');
    	   Add('  gamma =  ' + Setting.ToString );
    	   Add('  new_im = Image.fromarray( cv2.cvtColor( adjust_gamma(img, gamma), cv2.COLOR_BGR2RGB ) )' );
    	   Add('  return new_im');
    	 end;
    
      GetPythonEngine.ExecStrings(PythonCode);
      _im := MainModule.ProcessImage(ImageToPyBytes(Image1.Picture.Graphic));
    
        // We have to call PyString_AsStringAndSize because the image may contain zeros  (P4D Demo 29)
        with GetPythonEngine do
        begin
          pargs := MakePyTuple( [ExtractPythonObjectFrom(_im)] );
          try
            presult := PyObject_Call( ExtractPythonObjectFrom(MainModule.ImageToBytes), pargs, nil); //  <<=====================  problem causing code line. What about "MainModule.ImageToBytes"?
            try
              if PyBytes_AsStringAndSize(presult, P, Len) < 0 then
              begin
              //  ShowMessage('This does not work and needs fixing');
                Abort;
              end;
              _stream := TMemoryStream.Create();
              try
                _stream.Write(P^, Len);
                _stream.Position := 0;
                Image1.Picture.Graphic.LoadFromStream(_stream);
              finally
                _stream.Free;
              end;
            finally
              Py_XDECREF(pResult);
            end;
          finally
            Py_DECREF(pargs);
          end;
        end;
    
     Finally
       PythonCode.Free;
     END;
    end;


    The error occurs in the line with "PyEval_CallObjectWithKeywords" (or like in the code with the equivalent "PyObject_Call" instead)
    the resulting image ("_im: in the code) shows '<PIL.Image.Image image mode=RGB size=4928x3264 at 0x19B16B45BB0>' when inspected, which is OK.
    "pargs" shows $19B0845BD00, which to me looks at least better than "nil", but "presult" does show "nil", thus what causes the program to Abort.

     

    Can anybody please tell me what causes the problem and how to get it to work?

    Many thanks,

      Jan

     

     

     


  13. I traced back that the problem is caused by the use of the SKIA library.

    When I create and run a new Win64 multidevice application with SKIA enabled as shown here below the error occurs. Win32 runs OK.

    program Project1;
    
    uses
      System.StartUpCopy,
      FMX.Forms,
      SKIA, SKIA.FMX,
      Unit1 in 'Unit1.pas' {Form1};
    
    {$R *.res}
    
    begin
      GlobalUseSkia := TRUE;
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.

    I have updated SKIA to the version 5.0, but this did not solve the problem.

    Any ideas about the cause of this? 

     


  14. Thank you @Sherlock. I followed the links you posted, but it did not help me any further.

    In Delphi 11.3 FMX the common Windows components have hints, except for the menuitems.
    MenuItems do have the Hint, ShowHint and the HitTest property too, but these are not visible in the Object Inspector.

    I just tried the following to assign the names of the menuitems to the text of their hints:

     

    For var I : Integer := 0 to Form1.ComponentCount -1 DO
        if Form1.components[I] is TMenuItem then
        begin
          (Form1.components[I] as TMenuItem).Hittest := True;
          (Form1.components[I] as TMenuItem).ShowHint := True;
          (Form1.components[I] as TMenuItem).Hint    := (Form1.components[I] as TMenuItem).name;
        end;

    This seems to work, though not in the right way: only the topline mainmenu items invoke hints.

    Having a mainmenu with items, like "File", "Options", an so on, hoving over them with the mouse shows the names of the sub-menuitems in "Files". Rather weird, isn't it?

     

    Has anybody idea's how to get correct hints for (sub-)menuitems?


  15. Hi @Eric,

    Did you manage to solve the issue altogether?
     

    I face the same problem in Delphi 11.3. At least: the same "call stack" listing appears as above in your initial post.

    In Win32 mode my FMX application (single unit, simple form, a menu and some speedbuttons) runs normally, but when switched to Win64 it fails.

    In ...source/rtl/system.pas the debug break is in: 

    function _IsClass(const Child: TObject; Parent: TClass): Boolean;
    begin
      Result := (Child <> nil) and Child.InheritsFrom(Parent);
    end;

    The error is in "Parent". Thereafter the error "...c0000005 ACCES_VIOLATION..." appears. Any ideas how to solve this?

×