Recent

Author Topic: How to install image library for freepascal on linux?  (Read 12358 times)

barracuda

  • Full Member
  • ***
  • Posts: 133
How to install image library for freepascal on linux?
« on: August 01, 2023, 01:36:00 pm »
Hello,
First time I try freepascal, just installed it on linux Mint 20. I want to work with image library is there some library with fuctions that can direct read rows or cols from image? I did not find out libfcl-image in my repository and did not find out how to install it.

Also I see I cannot post to Freepascal section why?

Handoko

  • Hero Member
  • *****
  • Posts: 5530
  • My goal: build my own game engine using Lazarus
Re: How to install image library for freepascal on linux?
« Reply #1 on: August 01, 2023, 02:05:38 pm »
Hello barracuda,
Welcome to the forum.

Have you tried Lazarus? In short, Lazarus is Free Pascal plus something extra. If you want to build GUI programs or working with images, using Lazarus is easier.

For example, in the link below has a demo showing how to load and read image data:
https://forum.lazarus.freepascal.org/index.php/topic,37242.msg252828.html#msg252828

If you want to see more demos what can do using Lazarus:
https://wiki.freepascal.org/Portal:HowTo_Demos

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to install image library for freepascal on linux?
« Reply #2 on: August 01, 2023, 02:16:15 pm »
First time I try freepascal, just installed it on linux Mint 20. I want to work with image library is there some library with fuctions that can direct read rows or cols from image? I did not find out libfcl-image in my repository and did not find out how to install it.
In the tradition of Ubuntu packaging, I believe the units are scattered in whatever they name the packages. Try searching with the keyword "fcl", at least Ubuntu's package search web tells me there's fp-units-fcl.

barracuda

  • Full Member
  • ***
  • Posts: 133
Re: How to install image library for freepascal on linux?
« Reply #3 on: August 01, 2023, 02:33:03 pm »
Please, how to quote? I don't see quote button (lots of buttons here have no description they are white buttons and white text color).

So I found the packages, but chatGPT recommended to look for libfcl-image2.6.4 and the packages you mention did not include description of the graphical library.

Now I don't know if to install FP or Lazarus. Of sure I want something extra, but in this moment i want to do something really fast in terminal. I have tried a simple bash file using convert (ImageMagick) and I have found that the IM is not able to export pixel information for complete row or column. So I need to write this program to get better performence. The AI recommendation was this function:

Code: Pascal  [Select][+][-]
  1. function himage() {
  2.     values=() # Jednorozměrné pole pro ukládání hodnot
  3.     for x in {1..32}; do
  4.         value=$(convert w.png -format "%[pixel:p{$x,0}]" info:-)
  5.         value=${value//gray(/}
  6.         values+=("${value//)/}") # Přidání hodnoty do pole
  7.     done
  8.     echo "${values[@]}"
  9. }

Which is very slow because this calls the convert 32 times. I think this would be really problem with higher resolution.

Yet my question to Lazarus. Is it possible to use it to write program for terminal only, not the graphical interface? I would like to try graphical interface later. I was used to use Delphi 7, but having Windows XP, it's impossible to have run both the Delphi7 and linux with chatGPT  :) . I like to use AI in my first steps of programming, even it makes so many stupid mistakes. I learn this way  :)

Handoko

  • Hero Member
  • *****
  • Posts: 5530
  • My goal: build my own game engine using Lazarus
Re: How to install image library for freepascal on linux?
« Reply #4 on: August 01, 2023, 02:50:52 pm »
Yet my question to Lazarus. Is it possible to use it to write program for terminal only, not the graphical interface?

Yes, you can use Lazarus to write Simple Program, Program and Console application. They all are console programs (terminal only). See img1 below, it is a screenshot captured when I did Lazarus main menu > File > New.

Please, how to quote?

You have 2 ways to do it. When replying someone post, there will be an "Insert Quote" button, see img2. Or you can use the Insert Quote Icon, see img3.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to install image library for freepascal on linux?
« Reply #5 on: August 01, 2023, 03:36:20 pm »
So I found the packages, but chatGPT recommended to look for libfcl-image2.6.4
Another reason to ditch that smart ass app. Forget whatever ChatGPT says, it knows too little. 2.6.4 is way to old and there's never a name libfcl-image, only fcl-image as a package.
and the packages you mention did not include description of the graphical library.
Look at the filelist. It contains everything fcl-image.
I like to use AI in my first steps of programming, even it makes so many stupid mistakes. I learn this way  :)
Don't. Be a real programmer by learning on your own. AI can help you later, not earlier, because you will need to feed it with a bunch of correct knowledge to fix its mistakes, which you don't have as a beginner.

barracuda

  • Full Member
  • ***
  • Posts: 133
Re: How to install image library for freepascal on linux?
« Reply #6 on: August 01, 2023, 03:47:25 pm »
I see
fcl-unit
fcl-unit-3.0.4

Both to install?

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: How to install image library for freepascal on linux?
« Reply #7 on: August 01, 2023, 03:57:22 pm »
I see
fcl-unit
fcl-unit-3.0.4

Both to install?
???

ChatGPT gives answers which are impressive at first sight, but I can say: When it comes to the ultimate test to run its proposed code through the compiler there is ALWAYS something which is wrong.

Forget AI, go the classical way and begin reading: An introductory article for fcl-image is https://wiki.freepascal.org/fcl-image. It contains several code examples which you can copy and paste into a Lazarus editor window. This way you slowly can build up knowledge in this topic. Note the word "slowly"? Yes, everything needs its time.

barracuda

  • Full Member
  • ***
  • Posts: 133
Re: How to install image library for freepascal on linux?
« Reply #8 on: August 01, 2023, 04:07:10 pm »
Forget AI, go the classical way and begin reading: An introductory article for fcl-image is https://wiki.freepascal.org/fcl-image. It contains several code examples which you can copy and paste into a Lazarus editor window. This way you slowly can build up knowledge in this topic. Note the word "slowly"? Yes, everything needs its time.

I have experience many years of programming, learning PHP,JS,Jquery,C/C++,ahk,delphi. I always, always forget what I have learned during a year and a half. This would be waste of time. Getting older. My memory is not good to go this way. I can keep just small stuff which I really use for every day or once a month. My experience is to reach the goal not to learn without reaching the goal.

barracuda

  • Full Member
  • ***
  • Posts: 133
Re: How to install image library for freepascal on linux?
« Reply #9 on: August 01, 2023, 06:48:41 pm »
Yet my question to Lazarus. Is it possible to use it to write program for terminal only, not the graphical interface?

Yes, you can use Lazarus to write Simple Program, Program and Console application. They all are console programs (terminal only). See img1 below, it is a screenshot captured when I did Lazarus main menu > File > New.

Please, how to quote?

You have 2 ways to do it. When replying someone post, there will be an "Insert Quote" button, see img2. Or you can use the Insert Quote Icon, see img3.

Thank you for the screenshot. I finally installed all three packages. The Lazarus took 1 GB of disk space. I see another project called FPCUnit for testing purposes. Is it better to use when I want to measure time of execution?

Handoko

  • Hero Member
  • *****
  • Posts: 5530
  • My goal: build my own game engine using Lazarus
Re: How to install image library for freepascal on linux?
« Reply #10 on: August 01, 2023, 07:33:03 pm »
I usually use something like this to test the performance of my programs:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.lfm}
  25.  
  26. { TForm1 }
  27.  
  28. procedure DoSomething;
  29. var
  30.   i, j: Integer;
  31. begin
  32.   for i := 1 to MaxInt div 1000 do
  33.   begin
  34.     j := i;
  35.     Application.ProcessMessages;
  36.   end;
  37. end;
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. var
  41.   Start, Delta:   TDateTime;
  42.   Hr, Mn, Sc, Ms: Word; // hour, minute, second, millisecond
  43. begin
  44.  
  45.   Start := Now;
  46.  
  47.   DoSomething;
  48.  
  49.   Delta := Now - Start;
  50.   DecodeTime(Delta, Hr, Mn, Sc, Ms);
  51.   ShowMessage(
  52.     (Hr*60+Mn).ToString +':'+
  53.     Sc.ToString         +':'+
  54.     Ms.ToString
  55.     );
  56.  
  57. end;
  58.  
  59. end.

The source code is provided in the link below:

barracuda

  • Full Member
  • ***
  • Posts: 133
Re: How to install image library for freepascal on linux?
« Reply #11 on: August 01, 2023, 08:04:26 pm »
Thank you for your code. I am almost configurated but I have stucked one problem. There was Courier or Courier New font and I changed it to Tahoma but the spaces stayed extremly huge. For this reason I don't  see much of any code...

Here is an example of code what I see:

Code: Pascal  [Select][+][-]
  1. begin
  2.   Img := TFPMemoryImage.Cr

No more space left on my screen I mean the width.

Usually I would see like
Code: Pascal  [Select][+][-]
  1. begin
  2.   Img := TFPMemoryImage.Create(32, 32);
  3.   try
  4.     // Načtení obrázku
  5.     try
  6.       ReadPNG(Img, 'w.png');
  7.     except
  8.       on E: Exception do
  9.       begin
  10.         Writeln('Chyba při načítání obrázku: ', E.Message);

I mean the maximum width of the working area where the code is diplayed.

The left strip with line numbers takes like 1/7,5 of my screen width.

Is there something in the Lazarus what makes everything bigger? I don't mind the big size of text, but the spaces. It consumes like 200% of the character width. And that's crazy.

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: How to install image library for freepascal on linux?
« Reply #12 on: August 01, 2023, 10:19:06 pm »
You cannot use Tahoma in the Lazarus editor because it assumes that every character has the same width - and Tahoma is a proportional font in which every character has its own width. It you don't like the "Courier" font select one with "Mono" in its name (Mono = mono-spaced = all characters have the same width).

All the editor settings can be made when you right-click on the editor and select "Options". Select "Display" in the navigation tree to get to the font settings. I am using font size 9, and I don't use any extra character and line spacing.

barracuda

  • Full Member
  • ***
  • Posts: 133
Re: How to install image library for freepascal on linux?
« Reply #13 on: August 02, 2023, 04:07:59 am »
I really cannot use Lazarus. Sorry. Do you have any other IDE for FreePascal which can use fonts like Tahoma or Arial Black? I think I can use FreePascal for designing but not for programming. Regarding use of text and fonts settings even xed is much better and user friendly. I see no reason for missing this type of fonts.

Handoko

  • Hero Member
  • *****
  • Posts: 5530
  • My goal: build my own game engine using Lazarus
Re: How to install image library for freepascal on linux?
« Reply #14 on: August 02, 2023, 06:21:13 am »
Interesting. I never know Xed Editor can use Tahoma or Arial Black fonts.

 

TinyPortal © 2005-2018