Forum > LCL

Component writing adding an icon.


andrew Bubble:
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

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 on how to create a Lazarus component.

andrew Bubble:
Hi wp

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

Regards Andrew


[0] Message Index

Go to full version