Recent

Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Linux / Re: System.Now gives timestamp which is eight hours back
« Last post by Thaddy on Today at 07:59:53 pm »
now relies on the system clock, so check the system clock.
it does not rely on a time sever, only indirect if the system clock is syncronized,
12
Lazarus Extra Components / Installing and using VampyreImaging
« Last post by Odacir on Today at 07:58:22 pm »
Hello,

I'm trying to use the Vampyreimaging. I installed byt the online package manager, all ok, but on try to put some of the units on the a form, the unit can't be located.

What i need to-do to use?
13
General / Re: Multidimensional arrays as parameters
« Last post by Kays on Today at 07:36:57 pm »
Dynamic arrays are reference counted. After invocation of setLength it is guaranteed that the reference count (of the variable you passed to setLength) is 1. That means using setLength you yourself always create an independent copy inside your routines.

In P3 you cannot invoke setLength directly on M because setLength decreases the reference count in the other previous version of M, i. e. an implicit write operation which is forbidden by const.

A var parameter can be implemented as a value parameter entailing an implicit writeback operation once the routine finishes. This writeback is essentially A_in_main := M_in_P2, i. e. simply copying pointer values (including implicit reference count adjustments). There is no “deep copy” involved.
14
Graphics / Re: Demo Scene Picture sinwave
« Last post by circular on Today at 07:27:02 pm »
Nice effect with PutImagePart.  :)

About optimization, there is mistake in the rectangular area provided to PutImagePart, it would rather be:
Code: Pascal  [Select][+][-]
  1. Bitmap.PutImagePart(0, i*5-4 , Plasma,  Rect(w,  i*5-4,  600*w ,(i+1)*5-4), dmSet);

Also you don't need to call Bitmap.Fill because it is already cleared by the component.

Another way to do the effect is to define a scanner:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes, BGRATransform;
  10.  
  11. type
  12.   TWaveScanner = class(TBGRABitmapScanner)
  13.     Time: integer;
  14.     function GetOffset({%H-}X, Y: Single): Single;
  15.     { fast integer scanning (used by PutImage) }
  16.     procedure ScanMoveTo(X, Y: Integer); override;
  17.     { slow floating point scanning }
  18.     function ScanAt(X, Y: Single): TBGRAPixel; override;
  19.     constructor Create(ASource: TBGRACustomBitmap;
  20.       ARepeatX,ARepeatY: boolean; AOrigin: TPoint);
  21.   end;
  22.  
  23.   { TForm1 }
  24.  
  25.   TForm1 = class(TForm)
  26.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  27.     Timer1: TTimer;
  28.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  29.     procedure FormCreate(Sender: TObject);
  30.     procedure Timer1Timer(Sender: TObject);
  31.   private
  32.     Image: TBGRABitmap;
  33.     WaveScanner: TWaveScanner;
  34.   public
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.lfm}
  43.  
  44. { TForm1 }
  45.  
  46. procedure TForm1.FormCreate(Sender: TObject);
  47. begin
  48.   Image := TBGRABitmap.Create('warrior1.png');
  49.   WaveScanner := TWaveScanner.Create(Image,
  50.               true, true, Point(0, 0));
  51. end;
  52.  
  53. // wobble or sinwave !!
  54. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  55. begin
  56.   WaveScanner.Time := WaveScanner.Time + 1;
  57.   Bitmap.Fill(WaveScanner);
  58. end;
  59.  
  60. procedure TForm1.Timer1Timer(Sender: TObject);
  61. begin
  62.   BGRAVirtualScreen1.RedrawBitmap;
  63. end;
  64.  
  65. { TWaveScanner }
  66.  
  67. function TWaveScanner.GetOffset(X, Y: Single): Single;
  68. begin
  69.   result := 50 + (10 * sin((Y + Time*5) * 8/5 * PI / 180));
  70. end;
  71.  
  72. procedure TWaveScanner.ScanMoveTo(X, Y: Integer);
  73. begin
  74.   inherited ScanMoveTo(X + round(GetOffset(X, Y)), Y);
  75. end;
  76.  
  77. function TWaveScanner.ScanAt(X, Y: Single): TBGRAPixel;
  78. begin
  79.   Result:=inherited ScanAt(X + GetOffset(X, Y), Y);
  80. end;
  81.  
  82. constructor TWaveScanner.Create(ASource: TBGRACustomBitmap;
  83.   ARepeatX,ARepeatY: boolean; AOrigin: TPoint);
  84. begin
  85.   inherited Create(ASource, ARepeatX, ARepeatY, AOrigin);
  86.   Time := 0;
  87. end;
  88.  
  89. end.

This way you can combine transforms, for example with a rotation:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes, BGRATransform;
  10.  
  11. type
  12.   TWaveScanner = class(TBGRAAffineBitmapTransform)
  13.     Time: integer;
  14.     function GetOffset({%H-}X, Y: Single): Single;
  15.     { fast integer scanning (used by PutImage) }
  16.     procedure ScanMoveTo(X, Y: Integer); override;
  17.     { slow floating point scanning }
  18.     function ScanAt(X, Y: Single): TBGRAPixel; override;
  19.     constructor Create(ASource: TBGRACustomBitmap;
  20.       ARepeatX,ARepeatY: boolean);
  21.   end;
  22.  
  23.   { TForm1 }
  24.  
  25.   TForm1 = class(TForm)
  26.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  27.     Timer1: TTimer;
  28.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  29.     procedure FormCreate(Sender: TObject);
  30.     procedure Timer1Timer(Sender: TObject);
  31.   private
  32.     Image: TBGRABitmap;
  33.     WaveScanner: TWaveScanner;
  34.   public
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.lfm}
  43.  
  44. { TForm1 }
  45.  
  46. procedure TForm1.FormCreate(Sender: TObject);
  47. begin
  48.   Image := TBGRABitmap.Create('warrior1.png');
  49.   WaveScanner := TWaveScanner.Create(Image, true, true);
  50. end;
  51.  
  52. // wobble or sinwave !!
  53. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  54. begin
  55.   WaveScanner.Time := WaveScanner.Time + 1;
  56.   WaveScanner.Translate(-ClientWidth/2, -ClientWidth/2);
  57.   WaveScanner.RotateDeg(1);
  58.   WaveScanner.Translate(ClientWidth/2, ClientWidth/2);
  59.   Bitmap.Fill(WaveScanner);
  60. end;
  61.  
  62. procedure TForm1.Timer1Timer(Sender: TObject);
  63. begin
  64.   BGRAVirtualScreen1.RedrawBitmap;
  65. end;
  66.  
  67. { TWaveScanner }
  68.  
  69. function TWaveScanner.GetOffset(X, Y: Single): Single;
  70. begin
  71.   result := 50 + (10 * sin((Y + Time*5) * 8/5 * PI / 180));
  72. end;
  73.  
  74. procedure TWaveScanner.ScanMoveTo(X, Y: Integer);
  75. begin
  76.   inherited ScanMoveTo(X + round(GetOffset(X, Y)), Y);
  77. end;
  78.  
  79. function TWaveScanner.ScanAt(X, Y: Single): TBGRAPixel;
  80. begin
  81.   Result:=inherited ScanAt(X + GetOffset(X, Y), Y);
  82. end;
  83.  
  84. constructor TWaveScanner.Create(ASource: TBGRACustomBitmap;
  85.   ARepeatX,ARepeatY: boolean);
  86. begin
  87.   inherited Create(ASource, ARepeatX, ARepeatY);
  88.   Time := 0;
  89. end;
  90.  
  91. end.
15
Graphics / Re: Demo Scene Bitmap Font Scroller
« Last post by KodeZwerg on Today at 07:21:14 pm »
That's clever to use the font as mask, so you can do any gradient in it.  :)
I also was looking twice if I misread there something.
Last time I played with BitmapFontScrollers the Bitmap was colored to save some cycles of CPU.
Okay, it was back when I had my first 386 and every little cache and cycle needed to be used clever :D
So a new way of doing such is pretty welcomed  O:-)
(while I become never a fan of pre-initialized values for such, if colored in realtime, color can also be calculated in realtime)
(same with many variable that G uses, it works on his display/setting, but some code snippets are missing the initial values shown, like size for screen/image etc ^_^)
16
General / Re: what's difference between Variant and TVarRec?
« Last post by ASerge on Today at 07:09:52 pm »
They seem very similar. Well, TVarRec is variant record. But isn't variant variant record?
Do not confuse TVarRec with TVarData, which is the internal representation of Variant.
TVarRec is an element of the array of const.
17
General / Re: splitting an image
« Last post by KodeZwerg on Today at 07:07:21 pm »
Image2 will contain the left half and Image3 the right half from the original imagelist picture.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   LBMP: TBitmap;
  4.   HalfBMP: TBitmap;
  5.   X: Integer;
  6. begin
  7.   LBMP := TBitmap.Create;
  8.   try
  9.     HalfBMP := TBitmap.Create;
  10.     try
  11.       ImageList1.GetBitmap(0, LBMP); // here i do put the image from imagelist index 0 into LBMP
  12.       X := LBMP.Width div 2; // at that position I do split the image
  13.       HalfBMP.Width := X;
  14.       HalfBMP.Height := LBMP.Height;
  15.       // left half:
  16.       HalfBMP.Canvas.CopyRect(Rect(0, 0, X, LBMP.Height), LBMP.Canvas, Rect(0, 0, X, LBMP.Height));
  17.       Image2.Picture.Bitmap.Assign(HalfBMP);
  18.       // right half:
  19.       HalfBMP.Canvas.CopyRect(Rect(0, 0, X, LBMP.Height), LBMP.Canvas, Rect(X, 0, LBMP.Width, LBMP.Height));
  20.       Image3.Picture.Bitmap.Assign(HalfBMP);
  21.     finally
  22.       HalfBMP.Free;
  23.     end;
  24.   finally
  25.     LBMP.Free;
  26.   end;
  27. end;
18
General / Re: Debugger error
« Last post by bobonwhidbey on Today at 07:03:07 pm »
Turning off Windows Virus and threat security eliminated the 'Debugger error' and also, of course, the Windows Security message. At least I can now get further into the process of tracking down this bug.

Both the exe and the dbg files exist in the expected folder with the expected time and size.

Thank you Martin for telling me about the ability to exclude just one folder from virus scanning. I feel a lot better about just one folder than the entire PC being "unprotected". When I excluded just the folder with the "offending" files - no error message - although my bug is of course still there.
19
General / Re: How to: create DLL file for Windows 10 64-Bit Pro
« Last post by paule32 on Today at 07:02:31 pm »
Hello,

Quote
As mentioned very early by me, if file size is your only concern, Pascal is the wrong horse to ride with.

That is my problem, and concerns - the size of the code.
Nobody make itself headache about, how application's can run faster, and consume lesser memory, and space on storage devices.
All of all would always more and more - more bigger, to better.

I came from the MS-DOS time (okay, I am over 40 years old, now. But I came in contact with computer very early - thanks to my parents, and teachers, and friends aka copy and play pirated Amiga 500 games *prrr... :-) )
So, in this time, each byte and bit was counted.

And the slogan was from a very important person:
2.048 MegaBytes (2 MB) was enough - you know the story ?  :o

And as such, I was growing with this slogan.
Because a night of a file full with PSET commands, after this frustrating moment as I came to the 64k limit ...
This tend me to use Turbo Pascal overlays ...

And the story begun ...
C/C++ EMS Windows 3.11 32-Bit programming with a DPMI proxy application make me lazy.

Years ago after this, I end-up with the same problem again.
The data information's goes bigger, and bigger - all of us know the BORLAND Delphi, and C++Builder ...
where no one was splitting data from the binary executable...

This concept came later: with HTML and CSS.
Before, all data was compiled into EXE - which makes resource memory leaks very sneaky.

Nobody have to know why I do this all.
Nobody have to use the software that I provide.

But I hope that all of them can be informal, and useful.
This is my vision: Provide Informal, and useful services.
20
Linux / [SOLVED] System.Now gives timestamp which is eight hours back
« Last post by alpine on Today at 06:58:15 pm »
Today I have installed a program written in FPC on a Debian 12 bookworm (32-bit) and to my surprise it logs all of its events with a timestamp which is 8 hours back in the past. Those stamps are result from calling the System.Now function.
The program runs properly on a several other Linux machines. I don't have a clue where the problem lies with that particular Debian machine.

Here is the output from timedatectl:
Code: [Select]
# timedatectl
               Local time: Wed 2024-04-24 19:47:15 EEST
           Universal time: Wed 2024-04-24 16:47:15 UTC
                 RTC time: Wed 2024-04-24 16:47:15
                Time zone: Europe/Sofia (EEST, +0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
and it is quite correct.

The printout from the program:
Code: [Select]
TimeLogNow: 135843986499, TimeLogToDateTime(TimeLogNow): 2024.04.24 11:49
Now: 2024.04.24 11:49, TimeLogFromDateTime(Now): 135843986499
The difference is exactly -8 hrs, (+2 min not relevant, execution difference)

Traced back the Now function until found an external:
Now -> GetLocalTime -> DoGetLocalDateTime -> fpgettimeofday -> external name 'FPC_SYSC_GETTIMEOFDAY'

Anybody have a clue?



Pages: 1 [2] 3 4 ... 10

TinyPortal © 2005-2018