Recent

Author Topic: Component writing adding an icon.  (Read 487 times)

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Component writing adding an icon.
« on: December 05, 2023, 09:58:44 pm »
Hi All

I have written several components which I have added to the Lazarus component palette bar.

When I used Delphi there was an application for making simple icons of varying bitmap sizes.

I have tried to read on Lazarus about making icons but the information seems out of date.

There is  reference to lazres in /tools but it I cannot where to get this.

Is there an article that explains how to do this, I understand that lazarus used to use .lrs files but know use .res files for icons.

Any pointers would be helpfull.

Regards Andrew

wp

  • Hero Member
  • *****
  • Posts: 11771
Re: Component writing adding an icon.
« Reply #1 on: December 05, 2023, 11:39:34 pm »
For the component palette you should provide images at the sizes 24x24, 36x36 and 48x48; they must be named like the component they are assigned to, and the medium and large images must have a name appendix "_150" and "_200" (for 150% and 200% size). Example: A component "tmybutton" requires icons named "tmybutton.png", "tmybutton_150.png" and "tmybutton_200.png". I am recommending the png format here because it has built-in and well-supported alpha-channel transparency.

You are asking about an application to draw these icons. Roland Hahn, the author of the icons recently used by Lazarus, recommends Inkscape. This is a vector-graphics application rather than a pixel-graphics application. But since images drawn by Inkcape can be exported as png in any size. Of course, you can also use a pixel-graphics application, such as LazPaint or GreenfishIconEditor.

lazres has nothing to do with image generation. What it does is to create a .res file out of the individual icons. It is delivered along with Lazarus, but you must compile it yourself; its Pascal sources are contained in the folder "tools" of the Lazarus installation. Have a look at the various batch files and shell scripts in folder "images" of the Lazarus installation to learn how to use it. Basically: "lazres buttonimages.res tmybutton.png tmybutton_150.png tmybutton_200.png" in  order to create a res file "buttonimages.res" containing the png images following in the parameter list. Or "lazres buttonimages.res @filelist.txt" where "filelist.txt" is a text file with the filenames of the images to be included in each line, created by "dir /b *.png > filelist.txt".

BTW, when you use the extension .lrs in the resource file argument of lazres you will create an old lrs resource file. But since Lazarus nowadays supports the Delphi-compatible res files this is not recommended any more.

Read https://wiki.lazarus.freepascal.org/How_To_Write_Lazarus_Component on how to create a Lazarus component.
« Last Edit: December 06, 2023, 11:10:35 am by wp »

andrew Bubble

  • Jr. Member
  • **
  • Posts: 57
Re: Component writing adding an icon.
« Reply #2 on: December 06, 2023, 12:01:02 am »
Hi wp

Thanks for the reply, this is exactly what I needed to know.

Regards Andrew

 

TinyPortal © 2005-2018