Leaderboard
Popular Content
Showing content with the highest reputation on 08/24/22 in Posts
-
hi, I have built the libraries with the latest sources of https://www.intel.com/content/www/us/en/developer/tools/oneapi/ipp.html and https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html I had zero warnings or problems on compile. Here the files https://github.com/RDP1974/Delphi64RTL Look the TBB allocator is very prone to detect memory errors as double free or overruns. In multithreaded apps as web applications you will get a large performance improvement. Btw. Intel license is totally permissive free to distribute and deploy everywhere please let me know if you discover errors Quick test with WebBroker Indy app producing a plain: program Project1; uses RDPMM64, Vcl.Forms, Web.WebReq, ... procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); begin Response.Content := '<html>' + '<head><title>Web Server Application</title></head>' + '<body>Web Server Application '+FormatDateTime('yyyymmdd.hhnnss',Now)+'</body>' + '</html> end; Hyper-V i9 cpu windows 2022 server, 16 cores Host i9 cpu windows 10 pro Apache bench ab -n 1000 -c 100 -k -r http://localhost:8080/ Delphi 11 default Concurrency Level: 100 Time taken for tests: 1.845 seconds Complete requests: 1000 Failed requests: 0 Keep-Alive requests: 0 Total transferred: 250000 bytes HTML transferred: 114000 bytes Requests per second: 542.04 [#/sec] (mean) Time per request: 184.488 [ms] (mean) Time per request: 1.845 [ms] (mean, across all concurrent requests) Transfer rate: 132.33 [Kbytes/sec] received Delphi 11 (with Intel libs): Concurrency Level: 100 Time taken for tests: 0.297 seconds Complete requests: 1000 Failed requests: 0 Keep-Alive requests: 0 Total transferred: 250000 bytes HTML transferred: 114000 bytes Requests per second: 3364.56 [#/sec] (mean) Time per request: 29.722 [ms] (mean) Time per request: 0.297 [ms] (mean, across all concurrent requests) Transfer rate: 821.42 [Kbytes/sec] received
-
Another option is to leave the event handler assigned and use a separate variable instead, eg: private IgnoreExit: Boolean; ... procedure TMyForm.DoSomething; begin IgnoreExit := True; try ... finally IgnoreExit := False; end; end; ... procedure TMyForm.Edit1Exit(Sender: TObject); begin if IgnoreExit then Exit; ... end; I like using the component's Tag property for this task, if it is not being used for something else, eg: procedure TMyForm.DoSomething; begin Edit1.Tag := 1; try ... finally Edit1.Tag := 0; end; end; ... procedure TMyForm.Edit1Exit(Sender: TObject); begin if Edit1.Tag <> 0 then Exit; ... end;
-
Rounded polygon
xstrider replied to A.M. Hoornweg's topic in Algorithms, Data Structures and Class Design
Hi Angus, based on your advice and of course on your excellent library I'm now able to easily create interestig shapes (see example) for use in my artwork . If you want to see what I do: https://www.embarcadero.com/case-study/artgen-case-study?aldSet=en-GB https://www.embarcadero.com/case-study/artgen-case-study/image-gallery?aldSet=en-GB Thanks a lot and keep up the good work! -
Strange behavior with "is" operator
Remy Lebeau replied to Sonjli's topic in Algorithms, Data Structures and Class Design
This happens when the module that declares MyAttributeOne is different than the module that is using MyAttributeOne, and the two modules have been compiled separately to have different RTTIs for the same type. In this case, you would need to move MyAttributeOne into a separate Package that both modules can share with Runtime Packages enabled, so that only 1 RTTI exists for MyAttributeOne between the modules. -
In C/C++, the '->' operator is primarily just a combination of the '*' dereference and '.' member-access operators (but can be overloaded in C++ for other purposes), eg the above can be written as follows instead and the functionality would be exactly the same: p = (*p).next; In Delphi, those same operations are expressed individually, there is no combination operator, eg: p := p^.next; However, in this case, the '^' is optional when accessing a member via a pointer, eg: p := p.next; There is no such thing as inline type declarations in Delphi, so you must use the traditional 'type' section to define the local record type, eg: procedure TElements.Button1Click(Sender: TObject); type AllElements = record Number: integer; // Atomic number Symbol: string; // Element symbol Name: string; // Element name AlphaSeq: integer; // Name alphabetical sequence number Mass: double; // Atomic number Oxidation: string; // Oxidation states end; begin ... end; Or, move the declaration outside of the procedure, eg: type AllElements = record Number: integer; // Atomic number Symbol: string; // Element symbol Name: string; // Element name AlphaSeq: integer; // Name alphabetical sequence number Mass: double; // Atomic number Oxidation: string; // Oxidation states end; procedure TElements.Button1Click(Sender: TObject); begin ... end; That being said, I also notice is that you are using inline const/variable declarations when you don't actually need to. You are not using inline declarations the way they were intended to be used, so you may as well just use the more traditional 'const' and 'var' sections instead, eg: procedure TElements.Button1Click(Sender: TObject); type ... const // No element has more than 10 oxidation states MAX_OXIDATION_STATES: integer = 10; TOTAL_ELEMENTS: integer = 118; var AtomicNumber1: integer; AtomicNumber2: integer; leastCommonMultiple: integer; ratio1: integer; ratio2: integer; Combinations: integer; valence1: integer; valence2: integer; v1: integer; v2: integer; errorMessage: string; begin AtomicNumber1 := 0; AtomicNumber2 := 0; ... end;
-
Strange behavior with "is" operator
Uwe Raabe replied to Sonjli's topic in Algorithms, Data Structures and Class Design
Check if you have more than one declaration of MyAttributeOne. -
I would like to have a Delphi version to work with ARM/Linux overall on Raspberry PI and clones. In industry, a lot of embedded ARM-based SOMs are developed with C++ or Python (QT on under the hood), overall for UI parts, but Delphi power could change the trends. I've tried FreePascal + Lazarus but is very messy...
-
Hi there, I happen to be the original author of TSpkToolbar (Spk = Spook). The fun fact is that it actually was designed for Delphi in the first place (now-ancient Delphi 2006). It is absolutely amazing, that my control still lives for all those years after I decided to opensource it and donate to the Lazarus community. Also, thanks for contributing 🙂 I'm long past my Delphi days, but I always think about Delphi community warmly and I'm happy it is still thriving 🙂 Best regards -- Wojciech "Spook" Sura.
-
Rounded polygon
angusj replied to A.M. Hoornweg's topic in Algorithms, Data Structures and Class Design
Hi xstrider. I've actually modified this function again since posting the link above, but I didn't want to abuse this thread since it's not specifically about my routine. Anyhow, here's the link to the up to date documentation on this function that's been renamed SmoothToCubicBezier (which I think better describes what the function does). This can be found in the Img32.Extra unit that part of my Image32 Library on GitHub. Both MakePath and FlattenCBezier are found in Img32.Vector. I'm not sure what you're referring to here. The MakePath function parameter is array of double, and the entire Image32 library uses double coordinate values. It appears you're using GDIPlus and I'm not familiar with it. However, while GraphicsPath does accept cubic bezier input (and will flatten these), these beziers appear to be cubic bezier splines, which are very different to cubic bezier arrays. Nevertheless you could copy FlattenCBezier from my library and simply add the flattened path using GraphicsPath's AddPolygon method. I hope that helps. ps: Here's a link to a short video that demonstrates this smoothing (together with vectorizing monochrome raster images, and path simplification). -
hi, comment this line in Model.Types.pas // Get Screen orientation. function TScreenOrientationMonitor.GetScreenOrientation: TScreenOrientation; begin Result := TScreenOrientation.Portrait; // TMessageManager.DefaultManager.SubscribeToMessage(TOrientationChangedMessage, DoOrientationChanged); var screenService: IFMXScreenService; if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, screenService) then Result := screenService.GetScreenOrientation; end;
-
Try this // Load JPG or PNG image from stream to picture. Format is auto detected. // Raise exception if something's wrong procedure LoadImageFromStream(Image: TImage; Stream: TStream); const JPGHeader: array[0..1] of Byte = ($FF, $D8); PNGHeader: array[0..3] of Byte = ($89, Byte('P'), Byte('N'), Byte('G')); var graphic: TGraphic; Header: array of Byte; begin graphic := nil; SetLength(Header, Max(Length(JPGHeader), Length(PNGHeader))); if Stream.Size > Length(Header) then try // Determine format by header Stream.Read(Pointer(Header)^, Length(Header)); if CompareMem(Header, @JPGHeader, Length(JPGHeader)) then graphic := TJPEGImage.Create else if CompareMem(Header, @PNGHeader, Length(PNGHeader)) then graphic := TPNGObject.Create else raise Exception.Create('Unsupported image format'); // Read the picture Stream.Position := 0; graphic.LoadFromStream(Stream); Image.Picture.Assign(graphic); finally FreeAndNil(graphic); end; end; ... if not Q.Query.FieldByName('Photo').IsNull then begin StmPhoto := TADOBlobStream.Create(Q.Query.FieldByName('Photo') as TBlobField, bmRead); try LoadImageFromStream(imgPhoto, StmPhoto); except on E: Exception do MessageDlg('Error loading photo:' + sLineBreak + E.Message, mtError, [mbOK], 0); end; StmPhoto.Free; end;