Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 03/18/22 in all areas

  1. Uwe Raabe

    Delphi 11.1 is available

    At least they can add four items to the bugs fixed list while actually only fixing one
  2. Uwe Raabe

    Detect if compiler is Delphi 11.1 (and not 11.0) ?

    {$IF RTLVersion111}
  3. Let's hope it wasn't "soon" from a geological perspective...
  4. Anders Melander

    Any example bitmap to grayscale?

    Nooooooooo! No. No. No. NO. Change the pixelformat to pf32bit Desaturate the RGB: (* Rec. 709 (also used by Gimp) *) // Y = 0.21 × R + 0.72 × G + 0.07 × B const LuminanceMultR = 54; LuminanceMultG = 184; LuminanceMultB = 18; function Desaturate(Color: TColor): TColor; var Luminance: byte; begin Luminance := (((Color and $00FF0000) shr 16 * LuminanceMultR) + ((Color and $0000FF00) shr 8 * LuminanceMultG) + ((Color and $000000FF) * LuminanceMultB)) shr 8; Result := (Color and $FF000000) or (Luminance shl 16) or (Luminance shl 8) or Luminance; end; procedure Desaturate(Bitmap: TBitmap); begin ASSERT(Bitmap.PixelFormat = pf32bit); for var Row := 0 to Bitmap.Height-1 do begin var p := PDword(Bitmap.ScanLine[Row]); var Col := Bitmap.Width; while (Col > 0) do begin p^ := Desaturate(p^); inc(p); dec(Col); end; end; end;
  5. XML used to be considered the universal data format. Now is a bit passé with JSON, YAML etc being "in". I got involved in XML parsing, since SVG files are in XML format. XML Delphi support At the surface the XML support in Delphi is very good: You have TXMLDocument/IXMLDocument offering high-level support (Xml.xmldoc) Support for the standard DOM interfaces (Xml.XmlDom) Multiple implementations including (MSXML, OmniXML, OpenXML and more) Ability to plug in your own implementation Multiple platform support. The most common way of accessing XML is through TXMLDocument/IXMLDocument. However there is a big catch: PERFORMANCE. Say you want to use MSXML and you specify 'MSXML' as your DefaultDomVendor. (or you simply include the implementation unit Xml.Win.msxmldom in your uses clause). Your create an XML document and you access the top node: var Doc: IXMLDocument = TXMLDocument.Create(nil); var Node: IXMLNode := Doc.DocumentElement; Node is an IXMLInterface implemented by TXMLNode (TInterfacedObject defined in Xml.XmlDoc). TXMLNode wraps an IDOMNode stored in a private field FDOMNode. IDOMNode is defined in Xml.Xmldom. The IDOMNode is implemented by the used vendor in this case Xml.Win.msxmldom by a class TMSDOMNode TMSDOMNode (also a TInterfacedObject) wraps IXMLDOMNode stored in a private field FMSNode. IXMLDOMNode is defined in Winapi.msxml. As a result when you create any IXMLNode, a TXMLNode is created and this creates a TMSDOMNode which points to an IXMLDOMNode. Any call/property access to IXMLNode translates in a call of IDOMNode which then calls IXMLDOMNode. The created TInterfaced objects also need to be destroyed when you release your XML Node. The same two-level indirection applies to all XML objects (attributes, Children) and cause a huge degradation of performance. Conclusion If you care about speed forget about TXMLDocument. You can access the Vendor implementation or even better in the case of MSXML the Microsoft ActiveX objects directly: uses WinAPI.msxml var XML: IXMLDOMDocument3 := CoDOMDocument60.Create; XML.loadXML(XMLString); var DocNode: IXMLDOMNode := XML.documentElement; In SVG parsing and processing accessing directly the ActiveX objects reduced processing time by more than 50%. Additional tip A common performance pitfall with MSXML is explained in http://www.gerixsoft.com/blog/delphi/msxml. The fastest way to iterate through ChildNodes is via getFirstChild/nextSibling and Attributes via nextNode.
  6. Lajos Juhász

    Lockbox missing in 11.1

    Most probably they're still uploading/updating the component list for 11.1. Usually get it is last in the update cycle for a new release.
  7. Lajos Juhász

    Lockbox missing in 11.1

    I can see it in Categories - Components. Lockbox 3 2021.11 and LockBox VCL and FMX 201.09 by Turbopack.
  8. Remy Lebeau

    Attachments to iPhones

    But, can you send a PDF from Outlook to iPhone and open it OK? If not, then this is an iPhone issue, otherwise this is an Indy issue. Just a few comments: You are (potentially) leaking the Indy objects (other than the MessageBuilder). You did not say which version of Delphi you are using, but I'm assuming it is an older version where FMX still relied on ARC memory management for objects on mobile platforms. That ARC system was removed in Delphi 10.4, so if you are (or ever will be) using 10.4 or later, you need to Free() unowned objects manually to avoid leaks. You are setting the TIdMessage.ContentType property 3 times, which is (obviously) redundant. Let the TIdMessageBuilderHtml populate the TIdMessage with the bulk of its settings as needed (including the ContentType), then you can provide the rest (Sender, Recipients, Subject, etc). The TIdMessageBuilderHtml.HtmlFiles property is meant for attachments that are referenced by the HTML (images, etc). So, unless you are displaying the PDF embedded in the HTML, non-HTML attachments that the user can download and save should be in the TIdMessageBuilderHtml.Attachments property instead. You don't need to set the SSLIOHandler's Destination, Host, or Port properties manually, Connnect() will handle that for you. I would suggest using the SSLIOHandler's SSLVersions property instead of its Method property. Not all servers require TLS 1.2 yet, so you should also enable TLS 1.1 at least. Connect() should be outside of the try/finally that calls Disconnect() Try this: procedure CreateIndyEmail( const xMsg: string; const xFirstName: string; xNameid: integer; const xEmail: string; const xSubject: string ); var DATA: TIdMessage; SMTP: TIdSMTP; SSL: TIdSSLIOHandlerSocketOpenSSL; begin DATA := TIdMessage.Create(nil); try with TIdMessageBuilderHtml.Create do try Html.Text := xMsg; //if gvbAttached then HtmlFiles.Add( gvAttachedFile ); if gvbAttached then Attachments.Add( gvAttachedFile ); FillMessage( DATA ); finally Free; end; DATA.Subject := xSubject; DATA.From.Address := 'Seniors@xyz.com'; DATA.Sender.Address := 'Seniors@xyz.com'; DATA.ReplyTo.EMailAddresses:= 'Seniors@xyz.com'; DATA.Recipients.EMailAddresses := xEmail; SMTP := TIdSMTP.Create(nil); try with SMTP do begin UseTLS := utUseExplicitTLS; Host := 'smtp.livemail.co.uk'; Port := 587; AuthType := satDefault; Username := 'Seniors@xyz.com'; Password := 'xyz'; end; IdOpenSSLSetLibPath( cLoc ); SSL := TIdSSLIOHandlerSocketOpenSSL.Create(SMTP); with SSL do begin SSLOptions.Mode := sslmClient; SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]; SSLOptions.VerifyMode := []; SSLOptions.VerifyDepth := 0; end; SMTP.IOHandler := SSL; SMTP.Connect; try SMTP.Send( DATA ); finally SMTP.Disconnect; end; finally SMTP.Free; end; finally DATA.Free; end; end;
  9. Uwe Raabe

    Detect if compiler is Delphi 11.1 (and not 11.0) ?

    No, in System.pas. That's why you cant' use IFDEF here.
  10. Uwe Raabe

    INI problem

    Does it help when you add the complete path to the file instead only the file name?
  11. sjordi

    Cannot build for linux on Windows 11

    if you are in a VM and you share the Documents folder from the host, it's seen as a remote folder (network) and it doesn't work. As you say, either you can copy the entire Linux SDKs into your local disk and make the IDE point on them or you can use aliases. I have 3 SDKs: CentOS7, Rocky8, Ubuntu20.04. Copying everything into the VM would gobble a lot of valuable disk space. Instead I keep my SDKs on my Mac Documents folder. The VM sees the Document sfolder mounted as Y: (so adapt to your situation in the example below). Here is what I did in the Windows VM mklink /d "c:\Documents\SDKs\Ubuntu20" "y:\Documents\Embarcadero\Studio\SDKs\ubuntu20.04.sdk" That way, in your Windows Documents folder, you'll have a link to the outside (host) real SDK and they won't appear as remote network mounts, and thus work correctly. In RadStudio IDE, make sure to set the Linux platform "Local root directory" to C:\Documents\SDKs\ubuntu20 Same for CentOS, Rocky, and other flavors... Hope this helps.
  12. Source attached. I use this code in most of my open source/freeware tools. Features: Fades image in/out on show/hide. Can be moved with the mouse. Automatically hidden when deactivated. A text can be displayed on top of the image. Text can be scrolled to create vertical banner. Can play a audio resource while visible. Can also be used as an "About box". Things to note: Splash does not "stay on top" when running in the debugger. This is by design. Doesn't handle HighDPI scaling well (image isn't scaled). SplashDemo.zip
  13. Lars Fosdal

    Delphi 11.1 is available

    At least people seem to actually use QP now - even if not all of us bothers checking for existing issues 😛
  14. Delphi-Rakka

    Delphi 11.1 is available

    You don't need to. There are already plenty of reports for this issue: RSP-37666 RSP-37656 RSP-37600
  15. Mark-

    CPas - C for Delphi

    Thank you.
  16. tinyBigGAMES

    CPas - C for Delphi

    CPas v1.3.stable released. Big update, code refactor, win32 support and much more. Reworked all examples to support 32/64-bits and more. • Reworked all examples to support 32/64-bits • Update cpLoadLibFromResource to include an instance (THandle) parameter • Added a runtime check to make sure CPas and CPas.Static are not used simultaneously • FPC can now build static releases also • Add CPas.Static unit now for static builds • Reformated CHM help format • Added cpCompile with project directives support • Replaced cpLoadLibFromStream with cpLoadLibFromMemory • Refactored codebase and added 32-bit support 😎 • Updated cpAddLibrary to support (.LIB) files • Updated cpSetVerionInfo to validate FileVersion as SemVer format (major.minor.patch) • Miscellaneous fixes and enhancements
  17. qubits

    Delphi 11.1 is available

    don't be sad.. Help file for Indy
  18. Stefan Glienke

    Cannot build for linux on Windows 11

    Does this help you? https://stackoverflow.com/questions/43023217/delphi-linux-ld-linux-exe-error-cannot-find-lgcc-s
  19. Little explanation of how the RTL dictionary works: - as Capacity, it always uses n^2 - that enables a fast calculation from the hashcode to the bucket index by simply bitmasking it (which makes it important to have a good hash function that also has good distribution in the lower bits of the hashcode - since 11 the RTL uses FNV1a which is quite good). - now how to deal with collisions (and I mean those in the buckets, not the hashcode itself because for 300 entries there would be a capacity of 512). When distributing 300 items across 512 slots it is very likely that you get a few collisions. The RTL uses a very simple so-called linear probing for that - it keeps looking at the next bucket until it finds a free one. While this provides good locality it naturally leads to primary clustering which you can see by the Collision count. This number tells the number of items that don't sit in the slot where their hashcode would have put them. As of 2.0 Spring uses a different hashtable implementation which is using a clever algorithm from the Python dictionary which mitigates this quite nicely. FWIW especially if you have a fixed amount of strings such a keywords it might be better to not use a hashtable because of the hash function overhead but rather some handcrafted lookup table. Since keywords most likely always start with a letter you can do something like DWS does: see https://github.com/EricGrange/DWScript/blob/master/Source/dwsTokenizer.pas#L798 just with the first letter you get the very tiny array of the keywords starting with that letter and then you do a linear search - which beats a hashtable any time.
  20. Anders Melander

    Can someone provide inbound and outbound ports used by IDE?

    Better now?
  21. Lars Fosdal

    Delphi on Windows 11 on MacBook Pro 16 (2021)

    It is already torn. The 32-bit emulation under W11 for ARM running in a VM is way FASTER than running native on my Lenovo i7 P52.
  22. pyscripter

    SynEdit just got a major uplift

    A new Word-like spell checking has been added to SynEdit.
×