Recent

Author Topic: Drawing difference between linux widgetsets and windows  (Read 531 times)

Jonny

  • Full Member
  • ***
  • Posts: 144
Drawing difference between linux widgetsets and windows
« on: January 20, 2025, 05:05:54 pm »
There seems to be a drawing issue somewhere. Below is a simple program to illustrate the problem.

This code should draw a 10x10px black square with a white outline square having a 1px border around it.

The linux qt5 and qt6 versions are fine, gtk2 has a black pixel at top left, and the windows version has top-left always off by one.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, InterfaceBase, LCLPlatformDef;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     procedure FormCreate(Sender: TObject);
  16.   private
  17.   public
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.lfm}
  26.  
  27. procedure TForm1.FormCreate(Sender: TObject);
  28. var
  29.   bmpGrid: TBitmap;
  30. begin
  31.   bmpGrid := TBitmap.Create;
  32.   try
  33.     bmpGrid.Width := 10;
  34.     bmpGrid.Height := 10;
  35.     bmpGrid.Canvas.Brush.Color := clBlack;
  36.     bmpGrid.Canvas.Clear;
  37.     bmpGrid.Canvas.Pen.Color := clWhite;
  38.     bmpGrid.Canvas.Pen.Style := psInsideframe;
  39.     bmpGrid.Canvas.Pen.Width := 2;
  40.     bmpGrid.Canvas.Brush.Style := bsClear;
  41.     // Draw a rectangle with a 1px border all around
  42.     bmpGrid.Canvas.Rectangle(2,2,9,9);
  43.     bmpGrid.SaveToFile(LCLPlatformDirNames[GetDefaultLCLWidgetType]+'-canvas.bmp');
  44.   finally
  45.     bmpGrid.Free;
  46.     Halt;
  47.   end;
  48. end;
  49.  
  50. end.
  51.  

Please see attached bitmap images.

Running latest trunk on Debian 12 and Windows 10:

Code: [Select]
Lazarus 4.99 (rev main_4_99-920-g0d73603378) FPC 3.3.1 x86_64-linux-gtk2
Free Pascal Compiler version 3.3.1-17333-g08f44aff2c-dirty [2025/01/20] for x86_64

 

TinyPortal © 2005-2018