Discussion:
[Lazarus] New Image Lists question
Vojtěch Čihák via Lazarus
2018-05-23 14:07:22 UTC
Permalink
Hi,
 
I have application where user can choose size of toolbars, i.e. I have several image lists named IL16, IL20, IL24, IL32, IL48 and I switch them in property TToolBar.Images. In meanwhile, TImageList was redesigned to work with hi-DPI desktops.
Now, I can load more images to each imagelist, with suffix _150 and _200. But it will cause dupicities, because icon16_150 and icon16_200 will have size 24 and 32 respectively, which are already stored in IL24 and IL32.
 
Question is: how can I do it without duplicities?
 
Thanks, V.
--
Ondrej Pokorny via Lazarus
2018-05-23 15:33:54 UTC
Permalink
On 23.05.2018 16:07, Vojtěch Čihák via Lazarus wrote:
> I have application where user can choose size of toolbars, i.e. I have several image lists named IL16, IL20, IL24, IL32, IL48 and I switch them in property TToolBar.Images. In meanwhile, TImageList was redesigned to work with hi-DPI desktops.
> Now, I can load more images to each imagelist, with suffix _150 and _200. But it will cause dupicities, because icon16_150 and icon16_200 will have size 24 and 32 respectively, which are already stored in IL24 and IL32.
>
> Question is: how can I do it without duplicities?

You don't need several image lists any more. Delete IL20, IL24, IL32 and
IL48 use only IL16 where you load all the images.

Read:
http://wiki.freepascal.org/Lazarus_1.10.0_release_notes#TCustomImageList_.2F_TImageList
http://wiki.freepascal.org/TImageList

Demos:
examples/imagelist_highdpi_designtime
examples/imagelist_highdpi_runtime

Ondrej
--
Ondrej Pokorny via Lazarus
2018-05-23 15:46:09 UTC
Permalink
I forgot: you will probably want to use TImageList.OnGetWidthForPPI so
that the original resolution 32px is used for 20px images on 150%
instead of 30px (20*1.5 = 30). See the
examples/imagelist_highdpi_designtime demo.

Ondrej
--
Mattias Gaertner via Lazarus
2018-05-23 15:59:47 UTC
Permalink
On Wed, 23 May 2018 17:33:54 +0200
Ondrej Pokorny via Lazarus <***@lists.lazarus-ide.org> wrote:

>[...]
> Demos:
> examples/imagelist_highdpi_runtime

Can you add some comments please?

Mattias
--
Vojtěch Čihák via Lazarus
2018-05-23 17:18:59 UTC
Permalink
Thanks, I saw the demos, I see now how it works. But how can I add multiple resolution to ImageList? Is it possible only with suffixes and all images must be in the same directory? I need to push 10 resolution to one ImageList. Default res. is 16x16 and the others are 20, 24, 28, 32, 40, 48, 56, 64 and 80.
How should I do it?
 
V.
 
______________________________________________________________
> Od: Ondrej Pokorny via Lazarus <***@lists.lazarus-ide.org>
> Komu: ***@lists.lazarus-ide.org
> Datum: 23.05.2018 17:33
> Předmět: Re: [Lazarus] New Image Lists question
>
On 23.05.2018 16:07, Vojtěch Čihák via Lazarus wrote:
> I have application where user can choose size of toolbars, i.e. I have several image lists named IL16, IL20, IL24, IL32, IL48 and I switch them in property TToolBar.Images. In meanwhile, TImageList was redesigned to work with hi-DPI desktops.
> Now, I can load more images to each imagelist, with suffix _150 and _200. But it will cause dupicities, because icon16_150 and icon16_200 will have size 24 and 32 respectively, which are already stored in IL24 and IL32.
>  
> Question is: how can I do it without duplicities?

You don't need several image lists any more. Delete IL20, IL24, IL32 and
IL48 use only IL16 where you load all the images.

Read:
http://wiki.freepascal.org/Lazarus_1.10.0_release_notes#TCustomImageList_.2F_TImageList <http://wiki.freepascal.org/Lazarus_1.10.0_release_notes#TCustomImageList_.2F_TImageList>
http://wiki.freepascal.org/TImageList <http://wiki.freepascal.org/TImageList>

Demos:
examples/imagelist_highdpi_designtime
examples/imagelist_highdpi_runtime

Ondrej
--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Ondrej Pokorny via Lazarus
2018-05-23 17:20:22 UTC
Permalink
On 23.05.2018 19:18, Vojtěch Čihák via Lazarus wrote:
>
> Thanks, I saw the demos, I see now how it works. But how can I add
> multiple resolution to ImageList? Is it possible only with suffixes
> and all images must be in the same directory? I need to push 10
> resolution to one ImageList. Default res. is 16x16 and the others are
> 20, 24, 28, 32, 40, 48, 56, 64 and 80.
>
> How should I do it?
>

See the demo examples/imagelist_highdpi_runtime again.

Ondrej
Ondrej Pokorny via Lazarus
2018-05-23 17:23:41 UTC
Permalink
On 23.05.2018 19:18, Vojtěch Čihák via Lazarus wrote:
>
> Thanks, I saw the demos, I see now how it works. But how can I add
> multiple resolution to ImageList? Is it possible only with suffixes
> and all images must be in the same directory? I need to push 10
> resolution to one ImageList. Default res. is 16x16 and the others are
> 20, 24, 28, 32, 40, 48, 56, 64 and 80.
>
> How should I do it?
>

Btw. for so many resolutions, I would just add 16x16 and then e.g.
128x128 or 256x256 and let the other resolutions get scaled
automatically by the LCL.

If 20x20 and 24x24 shouldn't scale nicely from the high resolution, you
may want to add them explicitely as well.

Ondrej
Vojtěch Čihák via Lazarus
2018-05-23 17:29:23 UTC
Permalink
But I need to add images at design-time via Image List Editor. I have my images at *.svg format and I use script for converting (I use rsvg tool). 
 
#!/bin/bash
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 80 -h 80 -a -o ../png80/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 64 -h 64 -a -o ../png64/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 56 -h 56 -a -o ../png56/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 48 -h 48 -a -o ../png48/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 40 -h 40 -a -o ../png40/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 32 -h 32 -a -o ../png32/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 28 -h 28 -a -o ../png28/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 24 -h 24 -a -o ../png24/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 20 -h 20 -a -o ../png20/`echo $i | sed -e 's/svg$/png/'`; done
 
for i in *.[Ss][Vv][Gg]; do rsvg-convert $i -w 16 -h 16 -a -o ../png16/`echo $i | sed -e 's/svg$/png/'`; done
                                                                                                                 
 
So I need to know where to store transfered images (one or more directories) and what names (or suffixes) give them to be able to load them via Image List Editor at once (if possible).
 
Thanks.
______________________________________________________________
> Od: Ondrej Pokorny via Lazarus <***@lists.lazarus-ide.org>
> Komu: ***@lists.lazarus-ide.org
> Datum: 23.05.2018 19:20
> Předmět: Re: [Lazarus] New Image Lists question
>
On 23.05.2018 19:18, Vojtěch Čihák via Lazarus wrote:Thanks, I saw the demos, I see now how it works. But how can I add multiple resolution to ImageList? Is it possible only with suffixes and all images must be in the same directory? I need to push 10 resolution to one ImageList. Default res. is 16x16 and the others are 20, 24, 28, 32, 40, 48, 56, 64 and 80.
How should I do it?

See the demo examples/imagelist_highdpi_runtime again.

Ondrej


----------

--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Ondrej Pokorny via Lazarus
2018-05-23 17:35:01 UTC
Permalink
On 23.05.2018 19:29, Vojtěch Čihák via Lazarus wrote:
>
> But I need to add images at design-time via Image List Editor. I have
> my images at *.svg format and I use script for converting (I use rsvg
> tool).
>
> So I need to know where to store transfered images (one or more
> directories) and what names (or suffixes) give them to be able to load
> them via Image List Editor at once (if possible).
>

I don't understand you. The design-time Image List Editor is a
click-here/click-there WYSIWYG dialog. There are absolutely no rules how
you have to save your images... Just load the images one-by-one. The
resolutions will be detected automatically.

But I really advice you not to store all resolutions in the LFM.
Instead, use one big resolution (typically 256x256). All needed
resolutions will be automatically scaled from it in run-time. Add
smaller resolutions only if they don't look good.

Ondrej
Ondrej Pokorny via Lazarus
2018-05-23 17:43:33 UTC
Permalink
On 23.05.2018 19:35, Ondrej Pokorny via Lazarus wrote:
> On 23.05.2018 19:29, Vojtěch Čihák via Lazarus wrote:
>>
>> But I need to add images at design-time via Image List Editor. I have
>> my images at *.svg format and I use script for converting (I use rsvg
>> tool).
>>
>> So I need to know where to store transfered images (one or more
>> directories) and what names (or suffixes) give them to be able to
>> load them via Image List Editor at once (if possible).
>>
>
> I don't understand you.

Oh, sorry, I missed the "at once". You can only load either several
images in one resolution or one image list in multiple resolutions at
once. For the former use "Add ...", for the latter use "Add more
resolutions ..." (select all resolutions of the image in the open file
dialog).

Ondre
Vojtěch Čihák via Lazarus
2018-05-23 18:11:20 UTC
Permalink
 
______________________________________________________________
> Od: Ondrej Pokorny via Lazarus <***@lists.lazarus-ide.org>
> Komu: ***@lists.lazarus-ide.org
> Datum: 23.05.2018 19:43
> Předmět: Re: [Lazarus] New Image Lists question
>
On 23.05.2018 19:35, Ondrej Pokorny via Lazarus wrote:On 23.05.2018 19:29, Vojtěch Čihák via Lazarus wrote:But I need to add images at design-time via Image List Editor. I have my images at *.svg format and I use script for converting (I use rsvg tool). 
 So I need to know where to store transfered images (one or more directories) and what names (or suffixes) give them to be able to load them via Image List Editor at once (if possible).

I don't understand you.
Oh, sorry, I missed the "at once". You can only load either several images in one resolution or one image list in multiple resolutions at once. For the former use "Add ...", for the latter use "Add more resolutions ..." (select all resolutions of the image in the open file dialog).

Ondre


----------

--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Vojtěch Čihák via Lazarus
2018-05-23 18:16:39 UTC
Permalink
@ Oh, sorry, I missed the "at once". You can only load either several images in one resolution or one image list in multiple resolutions at once. For the former use "Add ...", for the latter use "Add more resolutions ..." (select all resolutions of the image in the open file dialog).
 
It's clear now.
 
@ But I really advice you not to store all resolutions in the LFM. Instead, use one big resolution (typically 256x256). All needed resolutions will be automatically scaled from it in run-time. Add smaller resolutions only if they don't look good.
 
I would prefer to store all resolutions, rsvg creates very good images. If you mean problem with *.lfm size I guess that all images at 256 size will be bigger.
 
I will try.
 
Thanks.
 
PS: Previous message was accidentaly send empty.  
______________________________________________________________
> Od: Ondrej Pokorny via Lazarus <***@lists.lazarus-ide.org>
> Komu: ***@lists.lazarus-ide.org
> Datum: 23.05.2018 19:43
> Předmět: Re: [Lazarus] New Image Lists question
>
On 23.05.2018 19:35, Ondrej Pokorny via Lazarus wrote:On 23.05.2018 19:29, Vojtěch Čihák via Lazarus wrote:But I need to add images at design-time via Image List Editor. I have my images at *.svg format and I use script for converting (I use rsvg tool). 
 So I need to know where to store transfered images (one or more directories) and what names (or suffixes) give them to be able to load them via Image List Editor at once (if possible).

I don't understand you.
Oh, sorry, I missed the "at once". You can only load either several images in one resolution or one image list in multiple resolutions at once. For the former use "Add ...", for the latter use "Add more resolutions ..." (select all resolutions of the image in the open file dialog).

Ondre


----------

--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Vojtěch Čihák via Lazarus
2018-05-23 19:11:30 UTC
Permalink
I have one more question: do I understand well that ImageList stores basic resolution uncompressed in node Bitmap and all other resolutions compressed in node BitmapAdv?
 
Thanks,
 
Vojtěch.
______________________________________________________________
> Od: Ondrej Pokorny via Lazarus <***@lists.lazarus-ide.org>
> Komu: ***@lists.lazarus-ide.org
> Datum: 23.05.2018 19:43
> Předmět: Re: [Lazarus] New Image Lists question
>
On 23.05.2018 19:35, Ondrej Pokorny via Lazarus wrote:
Ondrej


----------

--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Ondrej Pokorny via Lazarus
2018-05-23 19:14:58 UTC
Permalink
On 23.05.2018 21:11, Vojtěch Čihák via Lazarus wrote:
>
> I have one more question: do I understand well that ImageList stores
> basic resolution uncompressed in node Bitmap and all other resolutions
> compressed in node BitmapAdv?
>

Yes, this is due to forward compatibility with 1.8 and starting with
Lazarus 1.11 the basic resolution will be compressed as well (because
1.10 will support compression of basic resolution).

Ondrej
Loading...