[Lazarus] Component icons howto ?
lazarus at kluug.net
Wed Mar 30 09:16:38 CEST 2022
On 29.03.2022 19:45, Michael Van Canneyt via lazarus wrote:
> On Tue, 29 Mar 2022, Werner Pamler wrote:
>> I don't know the actual procedure names ATM, but imagine that when
>> the message window needs a "warning" icon (which is - say - 12x12 at
>> 96ppi) then the scaling procedure at 192ppi only needs to look for
>> "warning_200.png". If the exact image size would have been included
>> in the file name instead ("warning_24x24.png"), it would have to know
>> the size of the base image at 96ppi in order to select the right
>> image. A little simplification.
> I fail to see the link between 192 and 200. This requires people to know
> that 96dpi and 144 dpi and 192 dpi are 100, 150 and 200 % of a
> standard size.
Forget about the DPI/PPI values. What you need is the %-scaling factor
of the original size.
> For me - and I've been in IT for quite some time now - this is far from
> obvious that this should result in 24x24, 36x36 and 48x48 icon sizes.
100% => 24px - that is the usual and recommended size for component
palette icons at 100% scaling - e.g. Delphi uses the same size for the
component icons. Take it as a starting point.
150% => 24px * 150 / 100 = 36px
200% => 24px * 200 / 100 = 48px
That should be obvious for everybody who knows basic math :)
> In short: I think this is a horribly contorted scheme.
> All other systems I came across simply use icon dimensions in the
> name. Far simpler and hence preferable in my opinion.
I don't think so. Let me explain:
1.) One reason is legacy&compatibility. Before the High-DPI stuff, all
the IDE icons did not have the size in the name. Having the icon size in
px in the name would require a bigger rewrite of Lazarus code than it
was necessary for the scaling-postfixes and without any gain (see 
There are various places where icons with different sizes are used: tool
bars (16px), code editor (11px), component palette (24px). All these
icons did not have the size in the name originally.
2.) The second reason and the main advantage is that Lazarus doesn't
[need to] know what size of the icon is supplied at a specific scaling
(even at 100%). The icon sizes are not strictly defined.
The file naming convention is: the original variants (at 100%) do not
have a postfix, the scaled variants have a postfix with the scaling
factor in % based on the original icon => you open Lazarus on a screen
with 150% scaling, Lazarus automatically picks up the icons with "_150"
postfix. If not found, it scales the original ones automatically. Easy.
Having the size in the file name means that every function that requests
an icon would have to know the resulting px-size it looks for. That is
not wanted due to:
2.a) Rounding problems: do you round 11*150%=16.5 to 16px or 17px? You
would have to consider the same rounding both in the Lazarus code and in
the graphics editor. Currently only the graphics editor decides about
the best size of the scaled icon and Lazarus can cope with the undefined
2.b) unwanted fixed icon size: there can be icons at 100% with 16px and
at 200% with 30px, if the graphics designer decided so. Lazarus will
take the 30px icons without any issues.
Or, if somebody now decides that the 11px code editor icons need a
redesign and the new icons will have a base size of 12px instead of
11px, there is no need to change anything in the code. Lazarus will cope
with the new size of the icons unless the new size is a complete nonsense.
More information about the lazarus