Recent

Author Topic: Differences between Windows and Linux for graphics  (Read 6155 times)

daves001

  • New member
  • *
  • Posts: 5
Differences between Windows and Linux for graphics
« on: June 09, 2021, 08:16:34 pm »
I'm trying to move away from programming with Delphi under Windows to using Lazarus under Linux.  I've started by trying some graphics I used on a 2D CAD program, and here's what I've found so far...

My CAD program uses TCanvas to display simple graphical objects - polygons, ellipses, text, etc.  The program uses SetWorldTransform for scaling (zoom in/out on the canvas) and rotation of objects.  When fully zoomed in, the size of the canvas is over 200000 (width & height).

a) I haven't been able to find an equivalent to 'SetWorldTransform' under Linux that can be used on a TCanvas.  I've found some fast algorithms for lines, ellipse & floodfill, but scaling of text could be tricky (for me).  Any suggestions, please?

b) The size of controls is limited to width & height of 100000 (in the file control.inc - TControl.DoSetBounds).  I don't know why this figure has been used - seems arbitrary.
I've modified these to 400000 under WIndows and saved the changes - seem to work OK.
I tried to make the same changes under Linux, but the source files are read-only.  Anybody know an easy way to save the changes?

c) Using a TCanvas (TPaintBox contained inside a TPanel) - set the width to 40000 and drew some circles, using the ScrollBy method of the Panel to scroll around the PaintBox.  This works fine under Windows but, under Linux, stops working once the PaintBox is scrolled by more than 32767.  This looks like a 'smallint' hasn't been changed to 'integer' somewhere (possibly in the CombineRgn routine), but I haven't found the cause of the problem yet.  Anybody know a fix for this, please?

Thank you

winni

  • Hero Member
  • *****
  • Posts: 2670
Re: Differences between Windows and Linux for graphics
« Reply #1 on: June 09, 2021, 08:55:42 pm »
Hi!


b) Change the rights of your source directory

  chmod 777 -R /path/to/directory/*

c) The size of the canvas is since 25 years (Delphi) MaxSmallInt  x MaxSmallInt
( 32767 x 32767 )
There is no simple way to change that.  But if the size of the monitors will increase furthermore it has to be done.

Winni
« Last Edit: June 09, 2021, 08:57:18 pm by winni »

engkin

  • Hero Member
  • *****
  • Posts: 2934
Re: Differences between Windows and Linux for graphics
« Reply #2 on: June 10, 2021, 02:50:36 am »
Just in case you did not see it. There is an open-source CAD program by a member here: zamtmn.

VTwin

  • Hero Member
  • *****
  • Posts: 1052
  • Former Turbo Pascal 3 user
Re: Differences between Windows and Linux for graphics
« Reply #3 on: June 10, 2021, 05:52:17 am »
Why not use homogeneous coordinates and a 3x3 scaling/translation/rotation matrix for the window/viewport transformation? The world coordinates are floating point.

The window can be transformed to a bitmap (I use TBGRABitmap) of the desired final resolution. A portion of that bitmap can be copied to the canvas, so the canvas does not have to be as large as the bitmap. The scollbars must be programed independently however. Scaling, translation, and rotation of text can be done with the transformation matrix.
« Last Edit: June 10, 2021, 06:48:58 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.0
macOS 10.13.6: Lazarus 2.0.12 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.12 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.12 (64 bit on VBox)

PascalDragon

  • Hero Member
  • *****
  • Posts: 3339
  • Compiler Developer
Re: Differences between Windows and Linux for graphics
« Reply #4 on: June 10, 2021, 09:06:39 am »
c) The size of the canvas is since 25 years (Delphi) MaxSmallInt  x MaxSmallInt
( 32767 x 32767 )
There is no simple way to change that.  But if the size of the monitors will increase furthermore it has to be done.

At least in the LCL there is nothing that restricts the Canvas size to MaxSmallInt or comparable aside from maybe the underlying widgetset itself (there are only some sanity checks for the position in the Win32 widgetset).

daves001

  • New member
  • *
  • Posts: 5
Re: Differences between Windows and Linux for graphics
« Reply #5 on: June 10, 2021, 11:06:24 am »
Thanks for the replies.  As regards the size of TCanvas - I've been using Delphi 7 since about 2003 and the Width & Height properties of, for example, TPaintBox (but I think any control) is type integer so the maximum for each is $7FFFFFFF (2147483647) and the canvas is the same size.  Unlike a bitmap, this doesn't take lots of memory.  This is also the case with Lazarus and it works fine with the Windows version, but not with the Linux version.  Should I report this as a bug somewhere?

Why not use homogeneous coordinates and a 3x3 scaling/translation/rotation matrix for the window/viewport transformation? The world coordinates are floating point.
Can this be applied directly to TCanvas?

loaded

  • Sr. Member
  • ****
  • Posts: 271
Re: Differences between Windows and Linux for graphics
« Reply #6 on: June 10, 2021, 02:44:44 pm »
You can use a different logic for drawing.
For scaling, you should use your drawing area, not the Canvas, Thus, you can view the drawings of the desired width without changing the size of the existing canvas or without any limitations.
Regarding the subject, there is a 2D Cad program that I have written for Windows and Android operating systems and that I am constantly developing.
It can read Dxf, Kml, Hgt and Rsn formats.

Youtube videos;
For Windows https://youtu.be/5yhI1uq-3yM, For Android  https://youtu.be/J58jgWBupzY

You can also download and test it if you want.
« Last Edit: June 10, 2021, 02:49:25 pm by loaded »
Installing the spelling, google translate is used :)

VTwin

  • Hero Member
  • *****
  • Posts: 1052
  • Former Turbo Pascal 3 user
Re: Differences between Windows and Linux for graphics
« Reply #7 on: June 10, 2021, 04:15:54 pm »

Why not use homogeneous coordinates and a 3x3 scaling/translation/rotation matrix for the window/viewport transformation? The world coordinates are floating point.
Can this be applied directly to TCanvas?

No. The world coordinates are within any floating point window. Before drawing you multiply them by the current transformation matrix to get the viewport coordinates, which correspond to pixels on a bitmap (or other output device, such as SVG). The visible portion of the bitmap is displayed by a scaling and translation to the PaintBox. The Canvas is the same size as the PaintBox.

loaded is suggesting something similar.
« Last Edit: June 10, 2021, 04:21:30 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.0
macOS 10.13.6: Lazarus 2.0.12 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.12 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.12 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1052
  • Former Turbo Pascal 3 user
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.0
macOS 10.13.6: Lazarus 2.0.12 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.12 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.12 (64 bit on VBox)

daves001

  • New member
  • *
  • Posts: 5
Re: Differences between Windows and Linux for graphics
« Reply #9 on: June 11, 2021, 11:14:17 am »
Quote
You can also download and test it if you want.

This is brilliant...it's exactly what I'm trying to achieve.  So what do use as a drawing surface?  A bitmap would use too much memory.

loaded

  • Sr. Member
  • ****
  • Posts: 271
Re: Differences between Windows and Linux for graphics
« Reply #10 on: June 11, 2021, 01:22:36 pm »
I am using Timage Object's Canvas for drawing.
Normally Bitmap is not required but bitmap for faster drawing needs to be used. (buffering)
There is no memory problem as the bitmap heights and lengths are not changed during drawing.
Installing the spelling, google translate is used :)

 

TinyPortal © 2005-2018