Jump to content

vfbb

Members
  • Content Count

    147
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by vfbb

  1. vfbb

    Skia versus VCL for plotting points

    Hello. I adapted your test with Skia4Delphi to directly access the pixels instead of painting the pixel. The result was 45 ms on win64. procedure TfrmMain.Button3Click(Sender: TObject); procedure DrawMandelbrotPixmap(APixmap: ISkPixmap; X, Y, au, bu: Double; X2, Y2: Integer); var c1, c2, z1, z2, tmp: Double; i, j, Count, rgb: Integer; hue, saturation, value: Double; begin c2 := bu; for i := 10 to X2 - 1 do begin c1 := au; for j := 0 to Y2 - 1 do begin z1 := 0; z2 := 0; Count := 0; // count is deep of iteration of the mandelbrot set // if |z| >=2 then z is not a member of a mandelset while (((z1 * z1 + z2 * z2 < 4) and (Count <= 50))) do begin tmp := z1; z1 := z1 * z1 - z2 * z2 + c1; z2 := 2 * tmp * z2 + c2; Inc(Count); end; // The color depends on the number of iterations hue := count / 50; saturation := 0.6; value := 0.5; PCardinal(APixmap.PixelAddr[i, j])^ := HSLtoRGB(hue, saturation, value); c1 := c1 + X; end; c2 := c2 + Y; end; end; var au, ao: Double; dX, dY, bo, bu: Double; LWidth: Integer; LHeight: Integer; LTimer: TStopwatch; LBitmap: TBitmap; LSurface: ISkSurface; begin LTimer := TStopwatch.StartNew; LWidth := Image1.Width; LHeight := Image1.Height; LSurface := TSkSurface.MakeRaster(LWidth, LHeight); LBitmap := TBitmap.Create(LWidth, LHeight); try ao := 1; au := -2; bo := 1.5; bu := -1.5; // direct scaling cause of speed dX := (ao - au) / (LWidth); dY := (bo - bu) / (LHeight); DrawMandelbrotPixmap(LSurface.PeekPixels, dX, dY, au, bu, LWidth, LHeight); LBitmap.SkiaDraw( procedure (const ACanvas: ISkCanvas) begin ACanvas.DrawImage(LSurface.MakeImageSnapshot, 0, 0); end); Image1.Picture.Assign(LBitmap); finally LBitmap.Free; end; Showmessage(LTimer.Elapsed.TotalMilliseconds.ToString+' ms'); end; However, your benchmark isn't accurate, you're basically changing pixel by pixel, it's not a good way to measure drawing library performance. Also, tasks that change an image pixel by pixel almost always perform better by creating a shader to run on the GPU. This is another advantage of Skia4Delphi, as it allows you to create shaders at runtime through the Skia Shader Language (based on GLSL). Even now I'm preparing a VCL sample of an animated shader, see the performance: 27.11.2021_01.05.45_REC.mp4 27.11.2021_01.05.45_REC.mp4
  2. vfbb

    Component for GIF animation

    Currently skia4delphi closed beta supports gif on all platforms. The next release will be available in 2 weeks.
  3. vfbb

    iOS 15.1

    Eric, what version of your PAServer? Is it 13.0.12.0? I couldn't confirm it, but someone reported in a whatsapp group that the PAServer patch 1 link on my.embarcadero.com is the link of the old version, 13.0.11.9... So if that's your case, install the patch via getit and use the new PAServer which will be in the RADStudio directory.
  4. vfbb

    how to cosume grpc in delphi vcl client?

    I never worked with grpc but, AFAIK, you should use a client thats support http/2, and put in body the generated protocol buffer based on .proto file of the api service. You can make a delphi record based on .proto struct and use the Erik Van Bilsen serialization code https://github.com/grijjy/GrijjyFoundation/blob/master/Grijjy.ProtocolBuffers.pas
  5. @Hans♫ I couldn't simulate your problem. I set up the same scenario you described in a blank project and the scroll worked perfectly. I also mounted on a TVertScrollBox and it worked perfectly. I'm using RAD Studio 11, but it works the same as in previous versions. Try simulating on a blank project to see where the problem is. I don't know what's going on, but maybe some other control is capturing the gesture...
  6. This is strange because the scrollbox does not use mousedown, mouseup, it uses gestures, and with hittest or without hit test in the components above, it should work in the same way.
  7. You can use OnClick normally with this code: uses FMX.Objects, FMX.Math, FMX.Math.Vectors; type TipControl = class(TRectangle) private const DEFAULT_MOVEMENT_TOLERANCE = 4; private FAbsolutePressedPoint: TPointF; FIsMouseDown: Boolean; FIsValidClick: Boolean; FLastMouseActivePoint: TPointF; FMovementTolerance: Single; function IsMovementToleranceStored: Boolean; protected function CheckHasValidClick: Boolean; virtual; procedure Click; override; procedure DoClick; virtual; procedure MouseDown(AButton: TMouseButton; AShift: TShiftState; X, Y: Single); override; procedure MouseMove(AShift: TShiftState; X, Y: Single); override; procedure MouseUp(AButton: TMouseButton; AShift: TShiftState; X, Y: Single); override; public constructor Create(AOwner: TComponent); override; property IsValidClick: Boolean read FIsValidClick; published property MovementTolerance: Single read FMovementTolerance write FMovementTolerance stored IsMovementToleranceStored; end; function TipControl.CheckHasValidClick: Boolean; function CheckIsMouseOver: Boolean; begin Result := FIsMouseOver and TouchTargetExpansion.MarginRect(LocalRect).Contains(FLastMouseActivePoint); end; begin Result := FIsValidClick and FIsMouseDown and CheckIsMouseOver and ((FMovementTolerance = 0) or ((PressedPosition.Distance(FLastMouseActivePoint) <= FMovementTolerance) and (FAbsolutePressedPoint.Distance(LocalToAbsolute(FLastMouseActivePoint)) <= FMovementTolerance))); end; procedure TipControl.Click; begin if Pressed then begin if not CheckHasValidClick then FIsValidClick := False; if IsValidClick then DoClick; end else DoClick; end; constructor TipControl.Create(AOwner: TComponent); begin inherited; FMovementTolerance := DEFAULT_MOVEMENT_TOLERANCE; FLastMouseActivePoint := PointF(-10000,-10000); end; procedure TipControl.DoClick; begin inherited Click; end; function TipControl.IsMovementToleranceStored: Boolean; begin Result := not SameValue(FMovementTolerance, DEFAULT_MOVEMENT_TOLERANCE, TEpsilon.Position); end; procedure TipControl.MouseDown(AButton: TMouseButton; AShift: TShiftState; X, Y: Single); begin FAbsolutePressedPoint := LocalToAbsolute(PointF(X, Y)); FIsValidClick := True; FIsMouseDown := True; FLastMouseActivePoint := PointF(X, Y); inherited; end; procedure TipControl.MouseMove(AShift: TShiftState; X, Y: Single); begin if CheckHasValidClick then begin FLastMouseActivePoint := PointF(X, Y); if not CheckHasValidClick then FIsValidClick := False; end else FLastMouseActivePoint := PointF(X, Y); inherited; end; procedure TipControl.MouseUp(AButton: TMouseButton; AShift: TShiftState; X, Y: Single); var LInvalidPressed: Boolean; begin FLastMouseActivePoint := PointF(X, Y); LInvalidPressed := not CheckHasValidClick; if LInvalidPressed then FIsValidClick := False; FIsMouseDown := False; inherited; end;
  8. vfbb

    Skia4Delphi

    Website: github.com/viniciusfbb/skia4delphi Skia4Delphi is a cross-platform 2D graphics API for Delphi based on Google's Skia Graphics Library (skia.org). Google's Skia Graphics Library serves as the graphics engine for Google Chrome and Chrome OS, Android, Flutter, Xamarin, Mozilla Firefox and Firefox OS, and many other products. Skia provides a more robust Canvas, being very fast and very stable, with hundreds of features for drawing 2D graphics, in addition to a text shaping engine designed to render texts in the most diverse languages with right-to-left support (such as the Persian language), full support for loading SVG files, support for creating PDF files, support for rendering Lottie files (verotized animations created in Adobe After Effects), integration with the GPU, among countless other cool features. Skia's idea is similar to Firemonkey's, the same codebase used in an OS will work the same on other platforms. It is also possible to design using the CPU in independent background threads. Skia also has native codecs, of course if you don't use the SKCodec class, when loading an encoded image it will give priority to using the platform's native codec, but it is possible to use its codec, for example for jpeg files it uses libjpeg-turbo and for png files libpng which maybe in certain environments may perform better than native. See some examples: Advanced shapes Advanced text rendering / shaping Svg Lottie files And much more...
  9. vfbb

    Skia4Delphi

    Made sample here: https://github.com/viniciusfbb/skia4delphi/issues/12#issuecomment-933528854 Result:
  10. According to the Alexandria docwiki, the new OSXARM64 platform is defined for OSX directive but not defined for MACOS directive, which doesn't make sense since MACOS directive has always been defined for OSX and iOS. Unfortunately I don't have any mac arm to confirm. Can anyone confirm this?
  11. @Kazantsev Alexey Truth! It didn't cross my mind to use compile time messages. I took the test and confirmed the suspicion. MACOS is defined in OSXARM64. Docwiki is wrong. Issue reported.
  12. vfbb

    Skia4Delphi

    @Rollo62 Explained Svg limitations in documentation, and see how to avoid in the considerations.
  13. vfbb

    Skia4Delphi

    We are very pleased to announce the 2.0 release of the Skia4Delphi project. The library was almost completely rewritten, bringing many new features such as visual components (VCL/FMX), easy installation, easy configuration, miscellaneous error handling, and much more. Now it also has many more features as well as more examples. See main changes: v2.0.0 Added support for Delphi 11 Added support for OSX ARM 64-bit Added Setup (friendly install) Added IDE plugin to enable the skia in your project: replacing manual changes in project settings, deployment and dlls that were needed before. Now it's automatic, just right click on your project inside the IDE then "Enable Skia" Built-in by default the "icudtl.dat" file in dll Added the controls TSkLottieAnimation, TSkPaintBox and TSkSvg Added SkParagraph (multiple styles in text) Added support for Telegram stickers (using TSkLottieAnimation) Added error handling in sensitive methods Added the source of our website: https://skia4delphi.org Library rewritted Improved the integration with apple's MetalKit Improved library usage, like replacing SkStream to TStream Fixed AccessViolation using TStream Fixed issue with transparent bitmap in Vcl sample Fixed minor issues Explained Svg limitations in documentation We are now using the latest inactive milestone release of Skia (M88), because the others are updated frequently. Deprecated non-windows platforms in Delphi 10.3 Rio or older Homepage: skia4delphi.org GitHub: https://github.com/viniciusfbb/skia4delphi A liittle preview Setup Just download the Skia4Delphi_2.0.0_Setup.exe attached in Releases page. Enabling your project Telegram sticker (tgs files): SkParagraph: WebP: kung_fu_panda.webp Format Size Png (100% quality) 512 KB Jpeg (80% quality) 65.1 KB WebP (80% quality) 51.6 KB Controls And much more...
  14. TDialogService.MessageDialog('You want to ........ ', TMsgDlgType.mtConfirmation, mbYesNo, TMsgDlgBtn.mbNo, nil, procedure(const aResult: TModalResult) …
  15. vfbb

    Open PDF File

    Edge, Firefox and Chrome open any pdf without addon.
  16. vfbb

    Open PDF File

    Try this: uses System.SysUtils, System.IOUtils, Winapi.Windows, Winapi.ShellAPI; procedure OpenPdf(const AFileName: string); var LURL: string; begin LURL := TPath.GetFullPath(AFileName).Replace('\', '/', [rfReplaceAll]); LURL := 'file://' + LURL; ShellExecute(0, 'open', PChar(LURL), nil, nil, SW_SHOWNORMAL); end;
  17. vfbb

    Skia4Delphi

    I didn't really investigate enough, I just noticed that more complex SVGs converted by Adobe programs weren't being read correctly. I reported this issue to skia and sent two examples of .eps files converted to SVG by adobe and another converter, where adobe's SVG is not rendered and other converters' SVG is rendered. Examples are attached. incompatible_svgs.zip
  18. vfbb

    Skia4Delphi

    @Kas Ob. Made! Thanks.
  19. vfbb

    Skia4Delphi

    @Rollo62 @dwrbudr @RDP1974 @Edwin Yip @Kas Ob. @hsauro I finally released version 1.1 which has been extensively tested on all platforms, which includes a complete demo project, demonstrating how to render svg files, lottie files and more, as well as fixing the issues with backwards compatibility, at the moment the library works on version XE6+ VCL or FMX. Skia's SVG module is still in the experimental phase, even though it works extremely well with most SVG files. Some bugs we detected in Skia's SVG module will be reported later today, however, some issues I'll expose here so you can help the community: Apparently, there is a format incompatibility - vectorized files exported as SVG by Adobe programs are not supported by Skia, however, if you use other online converters (like cloudconvert.com) to convert the .eps or the .ai to svg, it will probably works perfectly. In macOS depending on the language, the decimal separator is not dot (.), ie the conversion from string to float happens wrong depending on the macOS default system language Remarks: These errors are only in relation to the SVG module, which is still in the experimental phase, in addition, Skia is a robust and stable library; If the SVG file works on one platform, it will work the same on all. Changelog Added FMX sample (working from delphi XE6 and above, with platforms Win32, Win64, OSX64, iOS64, Android32, Android64); Added VCL sample (working from delphi XE6 and above); Added pre-built binaries of skia to repository, to facilitate implementation and to serve the samples; Updated skia to version 0.29.0; Added icudtl.dat file to windows platform; Fixed text shaping with RTL language; Fixed compilation in iOS; Fixed backwards compatibility with delphi XE6 above; About samples The samples already have the binaries configured. They are ready to Run.
  20. vfbb

    Skia4Delphi

    Just download the .zip file attached to the release tag, it contains the .dlls, .so and .a. Externals has an edited version of Skia, with a flat api exclusive to the library. There are instructions for compiling in BUILD.md 1. I confess that I only tested the first versions on the XE6, but in fact the code has changed a lot since then. I will fix it. 2. SkShaper uses Harfbuzz, but your comment was great, because although the example works without icu data, investigating, I realize that to use Harfbuzz there is still a dependency on ICU. For macOS and iOS SkShaper uses CoreText, dispensing with ICU and Harfbuzz, which is great because in the case of iOS the library is static. Anyway, I'm going to investigate and test it on all platforms, even though it worked without icu data. It seems to me that PDF Subset also uses ICU, I'll investigate anyway. I'll clean up the demo code and create a little more robust example and add it to the repository.
  21. vfbb

    Skia4Delphi

    The result of a simple demo in delphi: ezgif.com-gif-maker.mp4
  22. Yes, the only button combinations that work on Windows are: const mbYesNo = [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo]; mbYesNoCancel = [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo, TMsgDlgBtn.mbCancel]; mbYesAllNoAllCancel = [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbYesToAll, TMsgDlgBtn.mbNo, TMsgDlgBtn.mbNoToAll, TMsgDlgBtn.mbCancel]; mbOKCancel = [TMsgDlgBtn.mbOK, TMsgDlgBtn.mbCancel]; mbAbortRetryIgnore = [TMsgDlgBtn.mbAbort, TMsgDlgBtn.mbRetry, TMsgDlgBtn.mbIgnore]; mbAbortIgnore = [TMsgDlgBtn.mbAbort, TMsgDlgBtn.mbIgnore];
  23. vfbb

    Build a iOS Static library to use in Delphi

    If you just want the device model name, I made a function just for it: uses System.SysUtils, System.Generics.Collections, System.Generics.Defaults, Posix.SysSysctl, Posix.StdDef; function GetDeviceModelString: string; // Pretty names list in https://gist.github.com/adamawolf/3048717 function GetPrettyName(const AMachine: string): string; type TAppleDevice = record Machine: string; Name: string; end; const AppleDevices: array[0..145] of TAppleDevice = ( (Machine: 'arm64'; Name: 'iPhone Simulator'), (Machine: 'i386'; Name: 'iPhone Simulator'), (Machine: 'ipad1,1'; Name: 'iPad'), (Machine: 'ipad1,2'; Name: 'iPad 3G'), (Machine: 'ipad11,1'; Name: 'iPad mini 5th Gen (WiFi)'), (Machine: 'ipad11,2'; Name: 'iPad mini 5th Gen'), (Machine: 'ipad11,3'; Name: 'iPad Air 3rd Gen (WiFi)'), (Machine: 'ipad11,4'; Name: 'iPad Air 3rd Gen'), (Machine: 'ipad11,6'; Name: 'iPad 8th Gen (WiFi)'), (Machine: 'ipad11,7'; Name: 'iPad 8th Gen (WiFi+Cellular)'), (Machine: 'ipad13,1'; Name: 'iPad air 4th Gen (WiFi)'), (Machine: 'ipad13,10'; Name: 'iPad Pro 12.9 inch 5th Gen'), (Machine: 'ipad13,11'; Name: 'iPad Pro 12.9 inch 5th Gen'), (Machine: 'ipad13,2'; Name: 'iPad air 4th Gen (WiFi+Cellular)'), (Machine: 'ipad13,4'; Name: 'iPad Pro 11 inch 3rd Gen'), (Machine: 'ipad13,5'; Name: 'iPad Pro 11 inch 3rd Gen'), (Machine: 'ipad13,6'; Name: 'iPad Pro 11 inch 3rd Gen'), (Machine: 'ipad13,7'; Name: 'iPad Pro 11 inch 3rd Gen'), (Machine: 'ipad13,8'; Name: 'iPad Pro 12.9 inch 5th Gen'), (Machine: 'ipad13,9'; Name: 'iPad Pro 12.9 inch 5th Gen'), (Machine: 'ipad2,1'; Name: '2nd Gen iPad'), (Machine: 'ipad2,2'; Name: '2nd Gen iPad GSM'), (Machine: 'ipad2,3'; Name: '2nd Gen iPad CDMA'), (Machine: 'ipad2,4'; Name: '2nd Gen iPad New Revision'), (Machine: 'ipad2,5'; Name: 'iPad mini'), (Machine: 'ipad2,6'; Name: 'iPad mini GSM+LTE'), (Machine: 'ipad2,7'; Name: 'iPad mini CDMA+LTE'), (Machine: 'ipad3,1'; Name: '3rd Gen iPad'), (Machine: 'ipad3,2'; Name: '3rd Gen iPad CDMA'), (Machine: 'ipad3,3'; Name: '3rd Gen iPad GSM'), (Machine: 'ipad3,4'; Name: '4th Gen iPad'), (Machine: 'ipad3,5'; Name: '4th Gen iPad GSM+LTE'), (Machine: 'ipad3,6'; Name: '4th Gen iPad CDMA+LTE'), (Machine: 'ipad4,1'; Name: 'iPad Air (WiFi)'), (Machine: 'ipad4,2'; Name: 'iPad Air (GSM+CDMA)'), (Machine: 'ipad4,3'; Name: '1st Gen iPad Air (China)'), (Machine: 'ipad4,4'; Name: 'iPad mini Retina (WiFi)'), (Machine: 'ipad4,5'; Name: 'iPad mini Retina (GSM+CDMA)'), (Machine: 'ipad4,6'; Name: 'iPad mini Retina (China)'), (Machine: 'ipad4,7'; Name: 'iPad mini 3 (WiFi)'), (Machine: 'ipad4,8'; Name: 'iPad mini 3 (GSM+CDMA)'), (Machine: 'ipad4,9'; Name: 'iPad Mini 3 (China)'), (Machine: 'ipad5,1'; Name: 'iPad mini 4 (WiFi)'), (Machine: 'ipad5,2'; Name: '4th Gen iPad mini (WiFi+Cellular)'), (Machine: 'ipad5,3'; Name: 'iPad Air 2 (WiFi)'), (Machine: 'ipad5,4'; Name: 'iPad Air 2 (Cellular)'), (Machine: 'ipad6,11'; Name: 'iPad (2017)'), (Machine: 'ipad6,12'; Name: 'iPad (2017)'), (Machine: 'ipad6,3'; Name: 'iPad Pro (9.7 inch, WiFi)'), (Machine: 'ipad6,4'; Name: 'iPad Pro (9.7 inch, WiFi+LTE)'), (Machine: 'ipad6,7'; Name: 'iPad Pro (12.9 inch, WiFi)'), (Machine: 'ipad6,8'; Name: 'iPad Pro (12.9 inch, WiFi+LTE)'), (Machine: 'ipad7,1'; Name: 'iPad Pro 2nd Gen (WiFi)'), (Machine: 'ipad7,11'; Name: 'iPad 7th Gen 10.2-inch (WiFi)'), (Machine: 'ipad7,12'; Name: 'iPad 7th Gen 10.2-inch (WiFi+Cellular)'), (Machine: 'ipad7,2'; Name: 'iPad Pro 2nd Gen (WiFi+Cellular)'), (Machine: 'ipad7,3'; Name: 'iPad Pro 10.5-inch'), (Machine: 'ipad7,4'; Name: 'iPad Pro 10.5-inch'), (Machine: 'ipad7,5'; Name: 'iPad 6th Gen (WiFi)'), (Machine: 'ipad7,6'; Name: 'iPad 6th Gen (WiFi+Cellular)'), (Machine: 'ipad8,1'; Name: 'iPad Pro 11 inch 3rd Gen (WiFi)'), (Machine: 'ipad8,10'; Name: 'iPad Pro 11 inch 4th Gen (WiFi+Cellular)'), (Machine: 'ipad8,11'; Name: 'iPad Pro 12.9 inch 4th Gen (WiFi)'), (Machine: 'ipad8,12'; Name: 'iPad Pro 12.9 inch 4th Gen (WiFi+Cellular)'), (Machine: 'ipad8,2'; Name: 'iPad Pro 11 inch 3rd Gen (1TB, WiFi)'), (Machine: 'ipad8,3'; Name: 'iPad Pro 11 inch 3rd Gen (WiFi+Cellular)'), (Machine: 'ipad8,4'; Name: 'iPad Pro 11 inch 3rd Gen (1TB, WiFi+Cellular)'), (Machine: 'ipad8,5'; Name: 'iPad Pro 12.9 inch 3rd Gen (WiFi)'), (Machine: 'ipad8,6'; Name: 'iPad Pro 12.9 inch 3rd Gen (1TB, WiFi)'), (Machine: 'ipad8,7'; Name: 'iPad Pro 12.9 inch 3rd Gen (WiFi+Cellular)'), (Machine: 'ipad8,8'; Name: 'iPad Pro 12.9 inch 3rd Gen (1TB, WiFi+Cellular)'), (Machine: 'ipad8,9'; Name: 'iPad Pro 11 inch 4th Gen (WiFi)'), (Machine: 'iphone1,1'; Name: 'iPhone'), (Machine: 'iphone1,2'; Name: 'iPhone 3G'), (Machine: 'iphone10,1'; Name: 'iPhone 8'), (Machine: 'iphone10,2'; Name: 'iPhone 8 Plus'), (Machine: 'iphone10,3'; Name: 'iPhone X Global'), (Machine: 'iphone10,4'; Name: 'iPhone 8'), (Machine: 'iphone10,5'; Name: 'iPhone 8 Plus'), (Machine: 'iphone10,6'; Name: 'iPhone X GSM'), (Machine: 'iphone11,2'; Name: 'iPhone XS'), (Machine: 'iphone11,4'; Name: 'iPhone XS Max'), (Machine: 'iphone11,6'; Name: 'iPhone XS Max Global'), (Machine: 'iphone11,8'; Name: 'iPhone XR'), (Machine: 'iphone12,1'; Name: 'iPhone 11'), (Machine: 'iphone12,3'; Name: 'iPhone 11 Pro'), (Machine: 'iphone12,5'; Name: 'iPhone 11 Pro Max'), (Machine: 'iphone12,8'; Name: 'iPhone SE 2nd Gen'), (Machine: 'iphone13,1'; Name: 'iPhone 12 Mini'), (Machine: 'iphone13,2'; Name: 'iPhone 12'), (Machine: 'iphone13,3'; Name: 'iPhone 12 Pro'), (Machine: 'iphone13,4'; Name: 'iPhone 12 Pro Max'), (Machine: 'iphone2,1'; Name: 'iPhone 3GS'), (Machine: 'iphone3,1'; Name: 'iPhone 4'), (Machine: 'iphone3,2'; Name: 'iPhone 4 GSM Rev A'), (Machine: 'iphone3,3'; Name: 'iPhone 4 CDMA'), (Machine: 'iphone4,1'; Name: 'iPhone 4S'), (Machine: 'iphone5,1'; Name: 'iPhone 5 (GSM)'), (Machine: 'iphone5,2'; Name: 'iPhone 5 (GSM+CDMA)'), (Machine: 'iphone5,3'; Name: 'iPhone 5C (GSM)'), (Machine: 'iphone5,4'; Name: 'iPhone 5C (Global)'), (Machine: 'iphone6,1'; Name: 'iPhone 5S (GSM)'), (Machine: 'iphone6,2'; Name: 'iPhone 5S (Global)'), (Machine: 'iphone7,1'; Name: 'iPhone 6 Plus'), (Machine: 'iphone7,2'; Name: 'iPhone 6'), (Machine: 'iphone8,1'; Name: 'iPhone 6s'), (Machine: 'iphone8,2'; Name: 'iPhone 6s Plus'), (Machine: 'iphone8,4'; Name: 'iPhone SE (GSM)'), (Machine: 'iphone9,1'; Name: 'iPhone 7'), (Machine: 'iphone9,2'; Name: 'iPhone 7 Plus'), (Machine: 'iphone9,3'; Name: 'iPhone 7'), (Machine: 'iphone9,4'; Name: 'iPhone 7 Plus'), (Machine: 'ipod1,1'; Name: '1st Gen iPod'), (Machine: 'ipod2,1'; Name: '2nd Gen iPod'), (Machine: 'ipod3,1'; Name: '3rd Gen iPod'), (Machine: 'ipod4,1'; Name: '4th Gen iPod'), (Machine: 'ipod5,1'; Name: '5th Gen iPod'), (Machine: 'ipod7,1'; Name: '6th Gen iPod'), (Machine: 'ipod9,1'; Name: '7th Gen iPod'), (Machine: 'watch1,1'; Name: 'Apple Watch 38mm case'), (Machine: 'watch1,2'; Name: 'Apple Watch 42mm case'), (Machine: 'watch2,3'; Name: 'Apple Watch Series 2 38mm case'), (Machine: 'watch2,4'; Name: 'Apple Watch Series 2 42mm case'), (Machine: 'watch2,6'; Name: 'Apple Watch Series 1 38mm case'), (Machine: 'watch2,7'; Name: 'Apple Watch Series 1 42mm case'), (Machine: 'watch3,1'; Name: 'Apple Watch Series 3 38mm case (GPS+Cellular)'), (Machine: 'watch3,2'; Name: 'Apple Watch Series 3 42mm case (GPS+Cellular)'), (Machine: 'watch3,3'; Name: 'Apple Watch Series 3 38mm case (GPS)'), (Machine: 'watch3,4'; Name: 'Apple Watch Series 3 42mm case (GPS)'), (Machine: 'watch4,1'; Name: 'Apple Watch Series 4 40mm case (GPS)'), (Machine: 'watch4,2'; Name: 'Apple Watch Series 4 44mm case (GPS)'), (Machine: 'watch4,3'; Name: 'Apple Watch Series 4 40mm case (GPS+Cellular)'), (Machine: 'watch4,4'; Name: 'Apple Watch Series 4 44mm case (GPS+Cellular)'), (Machine: 'watch5,1'; Name: 'Apple Watch Series 5 40mm case (GPS)'), (Machine: 'watch5,10'; Name: 'Apple Watch SE 44mm case (GPS)'), (Machine: 'watch5,11'; Name: 'Apple Watch SE 40mm case (GPS+Cellular)'), (Machine: 'watch5,12'; Name: 'Apple Watch SE 44mm case (GPS+Cellular)'), (Machine: 'watch5,2'; Name: 'Apple Watch Series 5 44mm case (GPS)'), (Machine: 'watch5,3'; Name: 'Apple Watch Series 5 40mm case (GPS+Cellular)'), (Machine: 'watch5,4'; Name: 'Apple Watch Series 5 44mm case (GPS+Cellular)'), (Machine: 'watch5,9'; Name: 'Apple Watch SE 40mm case (GPS)'), (Machine: 'watch6,1'; Name: 'Apple Watch Series 6 40mm case (GPS)'), (Machine: 'watch6,2'; Name: 'Apple Watch Series 6 44mm case (GPS)'), (Machine: 'watch6,3'; Name: 'Apple Watch Series 6 40mm case (GPS+Cellular)'), (Machine: 'watch6,4'; Name: 'Apple Watch Series 6 44mm case (GPS+Cellular)'), (Machine: 'x86_64'; Name: 'iPhone Simulator')); var LDevice: TAppleDevice; LIndex: Integer; LStringComparer: IComparer<string>; begin LDevice.Machine := AMachine.ToLower; LDevice.Name := ''; LStringComparer := TComparer<string>.Default; if TArray.BinarySearch<TAppleDevice>(AppleDevices, LDevice, LIndex, TComparer<TAppleDevice>.Construct( function(const ALeft, ARight: TAppleDevice): Integer begin Result := LStringComparer.Compare(ALeft.Machine, ARight.Machine); end)) then begin Result := AppleDevices[LIndex].Name; end else if AMachine.IsEmpty then Result := '' else begin {$IFDEF DEBUG} for LIndex := 0 to Length(AppleDevices)-1 do if (AppleDevices[LIndex].Machine <> AppleDevices[LIndex].Machine.ToLower) then raise Exception.Create('Apple device list is wrong (the "Machine" field don''t allow upper case)'); for LIndex := 1 to Length(AppleDevices)-1 do if LStringComparer.Compare(AppleDevices[LIndex-1].Machine, AppleDevices[LIndex].Machine) <> -1 then raise Exception.Create('Apple device list is wrong (it isn''t ordered or have duplicate item)'); {$ENDIF} Result := '[' + AMachine + ']'; end; end; var LSize: size_t; LDeviceModelBuffer: array of Byte; begin sysctlbyname('hw.machine', nil, @LSize, nil, 0); if LSize > 0 then begin SetLength(LDeviceModelBuffer, LSize); sysctlbyname('hw.machine', @LDeviceModelBuffer[0], @LSize, nil, 0); Result := GetPrettyName(UTF8ToString(MarshaledAString(LDeviceModelBuffer))); end else Result := ''; end;
  24. vfbb

    Build a iOS Static library to use in Delphi

    Try just: const LIB_Name = 'libDName.a'; function deviceName: NSString; cdecl; external LIB_Name; You need to add the .a directory to your project's Search Path. If that doesn't work, try replacing NSString with pointer and converting later manually.
  25. Dave, on iOS it works the same way, and with the increase in privacy controls year after year, I think there will be no regressions. What many apps do is show a form before the permission request saying that it is necessary to grant X permission and if the user clicks on proceed, then requests the permission. This will avoid almost all permissions being denied. And when that happens, there's nothing to do but ask the user to grant permission on the settings (even Telegram does that).
×