Jump to content

JGMS

Members
  • Content Count

    43
  • Joined

  • Last visited

Everything 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. 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.
  3. I changed the parameter TNavigateButton to TBindNavigateBtn in both events, and I added FireDac.Stan.Intf to the unit clause to have TFDCommandKind constants like "skInsert" recognised. Problems solved. Thanks for your help.
  4. 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?
  5. 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!
  6. 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
  7. 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.
  8. You are a genious! Great! It worked for me too. Thank you very much indeed.
  9. I took PDFFonts from two different installations. But, bad luck indeed: the error remains after rebuilding and restarting D12. I hope @lajos can help me out, once he finds time to do so. Thanks again.
  10. Meanwhile I compared the file PDFFonts.pas in Delphi12 and Delphi11 and found a single difference: "sysutils"was missing in the D12 version. I will check whether or not this is causing the problem using your building tips?
  11. I added PDFfonts to the units clause, but the error remains. I understand that there seems to a bug, which is what confirms my findings. Thanks for answering.
  12. 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...
  13. 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.
  14. JGMS

    Installing Spring4D in Delphi 12 fails

    Thank you for your answer. There was no drive letter assigned, indeed. Good to remember next time.
  15. JGMS

    Installing Spring4D in Delphi 12 fails

    I found out what the problem was: installing from a network disk (NAS) appears not to be possible. I copied the repository to the C:\-drive and everything went smoothly.
  16. 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
  17. 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.
  18. The error reads: Project .... raised exception class EPyAttributeError with message 'AttributeError: 'Image' object has no attribute '__class__''. Attached the promised miniproject. Thank you @pyscripter for your time. Project_MiniDemo29.dpr Project_MiniDemo29.dproj MiniDemo29_Unit1.dfm MiniDemo29_Unit1.pas MiniDemo29_Unit2.dfm MiniDemo29_Unit2.pas
  19. 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.
  20. Thanks @Atilla, I will add the unit to my repository. It may be of future use.
  21. Problem solved: There is one more action required when switching to Win64, i.e. "Enable SKIA" in the Projects window of the IDE. Good to know for all. SKIA is fantastic!
  22. 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?
  23. A menuitem in Delphi (11.3 Enterprise) FMX has no "hint" property by default. How can I add the Hint and Showhint properties to the menuitem class to show them in the Object Inspector?
  24. JGMS

    How to enable hint property in a MenuItem

    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?
×