Advice on moving from Delphi to Lazarus lazarus / 21-General ---------------------------------------------------------------------- daves001 · 2021-05-24 11:05 Hi, Some advice please... I'm looking at moving from Windows OS to Linux, and from Delphi to Lazarus.  I've programmed in Delphi 7 (hobby only) for many years, designing my own components, etc.  Some of my programs use Windows API calls (like SetWorldTransform) to rotate and zoom objects drawn onto a canvas.  Can anybody tell me if I'll find similar routines in Lazarus/Free Pascal for zoom and rotate of graphics?  Would there be any major stumbling blocks in moving from Delphi to Lazarus? Thank you ---------------------------------------------------------------------- marcov · 2021-05-24 12:00 Using winapi functions will mostly not port to Linux.   (and usually Linux nowadays means 64-bit) It can probably be made to work on windows 32-bit. A lot of assembler ridden Delphi 7 code is not even portable to Windows 64-bit. Start with the easiest target (Windows 32-bit) and then gradually clean up and port. Not all stuff will be possible, and exotic GDI functionality will be hard. ---------------------------------------------------------------------- Handoko · 2021-05-24 12:13 Hello daves001, Welcome to the forum. Have you decided which Linux you're going to use? I personally use Ubuntu Mate. The reason to use Ubuntu is it has large user base so if I have problem using Linux, answers can be easier to get. I have Nvidia VGA, installing Nvidia driver seems easier on Ubuntu. I prefer Mate, because it is relatively lightweight than other Ubuntu's distributions. But some years ago, many users reported to have issues installing Lazarus on Ubuntu. Not very sure but it seems the problems have been solved. I haven't tried but many users recommend to use Linux Mint and Manjaro. If you are good in Delphi, you should have no problem using Lazarus. You should read this: https://wiki.freepascal.org/Lazarus_For_Delphi_Users If you want to build cross platform programs, you should not use Windows unit. Alternatively you can use the graphics library that are cross-platform: https://wiki.freepascal.org/Graphics_libraries BGRABitmap is relatively easy to use and should offer all the graphics functions you need. Here is the tutorial of BGRABitmap: https://wiki.lazarus.freepascal.org/BGRABitmap_tutorial But if performance is important and you like something challenging, you can use OpenGL in Lazarus. Installing TOpenGLControl component in Lazarus is easy: Lazarus main menu > Package > Install/Uninstall Packages > right panel, select: LazOpenGLContext 0.0.0 > Install selection > Save and rebuild IDE Here is glSlideshow I made, a cross-platform demo of using OpenGL component: https://forum.lazarus.freepascal.org/index.php/topic,35313.msg256719.h tml#msg256719 And this is CATWW, a demo showing how to do image scaling and rotation using BGRABtimap and also image caching for improving the performance: https://forum.lazarus.freepascal.org/index.php/topic,50989.msg373578.h tml#msg373578 ---------------------------------------------------------------------- wp · 2021-05-24 13:06 You are attempting two steps at once, from Windows to Linux, and from Delphi to Lazarus. I guess you will stumble and fall. Do steps one by one. First convert your project from Delphi to Lazarus, while staying on Windows. Your only task probably is to add the directive {$mode delphi} to your project units. You may have problems with strings: In lazarus a string consists of one-byte entities, in Delphi it consists of two-byte entities; normally this is transparent, but some low-level and system calls can fail. You'll have to convert these strings to WideString, the chars to widechar, and the PChar to PWideChar, plus some issues with UTF8-conversion - all these are solvable. When you succeeded with the migration you can proceed with the Windows to Linux conversion. Here you must replace all usages of the windows unit by LCLIntf and LCLType, and Messages by LMessages (or simply remove Windows and Messages from the uses clause which are deliberately added by Delphi). If you have windows messages in your code, replace the WM_* messages by LM_Messages. If you are lucky this will be enough. If you are not lucky ask the related questions here. In the worst case, the project will not be portable without major rework. ---------------------------------------------------------------------- lucamar · 2021-05-24 13:50 Quote from: wp on May 24, 2021, 03:06:38 pmIn lazarus a string consists of one-byte entities, in Delphi it consists of two-byte entities; normally this is transparent, but some low-level and system calls can fail. You'll have to convert these strings to WideString, the chars to widechar, and the PChar to PWideChar, plus some issues with UTF8-conversion - all these are solvable. He's using Delphi 7; no "unicode-by-default" there! There might be issues with UTF-8 (Lazarus's default, vs. Delphi's Windows codepage) but those can be easily remedied with an appropiate {$codepage xxx} directive. First step I would take, though, would be to read the manuals (after reading the "Lazarus for Delphians" page); at a minimum peruse the "Programmer's Guide" to learn about the supported directives and other coding (and implementation) issues. ---------------------------------------------------------------------- af0815 · 2021-05-24 14:12 Do not convert the programm first. Pick one part of interest, make a simpledemo in Delphi and convert it. After this you can look for this part of interest, how work it in Lazarus on windows and later how work it on Linux. If you have one small part working in the demo you have an overview of the caveeats. If you have windows call for grafik, look for a popular engine, working on all platforms. Convert it first on delphi, after this convert it to Lazarus. See above line :-) ---------------------------------------------------------------------- daves001 · 2021-06-09 17:40 Thanks to all for your wise words...I've started testing graphics with Lazarus under Windows and then moving over to Linux - I've hit some snags already - let's see if we can overcome them! ---------------------------------------------------------------------- marcov · 2021-06-09 20:44 Quote from: daves001 on June 09, 2021, 07:40:08 pmThanks to all for your wise words...I've started testing graphics with Lazarus under Windows and then moving over to Linux - I've hit some snags already - let's see if we can overcome them! Another tip: besides that not all GDI functions will have a direct equivalent, most GUI libraries (GTK, QT etc) only allow drawing in the dedicated (on)draw event, not in any event. ---------------------------------------------------------------------- avra · 2021-06-09 21:33 Maybe you could take a look at cross platform pl_graphics32 which you can install directly from Online Package Manager. QuoteSome of Graphics32 features include: * Fast per-pixel access up to 100 times faster compared to standard TBitmap; * High-performance Bitmap alpha blending (including per-pixel alpha blending); * Pixel, line and polygon antialiasing with sub-pixel accuracy (combined with alpha blending); * Arbitrary polygon transformations and custom fillings; * Bitmap resampling with high quality reconstruction filters (e.g. Lanczos, Cubic, Mitchell); * A unique state-of-the-art rasterization system; * Affine transformations of bitmaps: rotations, scaling, etc with sub-pixel accuracy; * Arbitrary projective transformations of bitmaps; * Arbitrary remapping transformations of bitmaps (e.g. for Warping, Morphing); * Flexible supersampling implementation for maximum sampling quality; * Flicker-free image displaying components with optimized double buffering via advanced MicroTiles? based repaint optimizer; * Multiple customizible easy-to- use overlay layers; * Locking of bitmaps for safe multithreading; * A property editor for RGB and alpha channel loading; * Design-time loading of image formats supported by standard TPicture; https://github.com/graphics32/graphics32 ---------------------------------------------------------------------- trev · 2021-06-12 05:02 * Lazarus for Delphi Users * Delphi language features missing from the Free Pascal Compiler