Recent

Author Topic: TimageList - Lazarus 4 with 256 x 256 - does not work  (Read 947 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1219
TimageList - Lazarus 4 with 256 x 256 - does not work
« on: June 12, 2025, 10:50:14 pm »
I am new to Lazarus 4 and Linux.
However, I am not able to fill 5 images of 256 x 256 into a TImage list. And not even I can do that wrong.

It just does not work! I think, I tried 10 times, in various ways. Setting the size before, after, adding 2 sizes...

You ask me, what I am doing? - I look at my frozen IDE and wait. Sometimes I click away message windows, which should contain error messages, but do not show anything. Sometimes I see "access violation". But most of the time I sit in front of my screen and watch the IDE, which does plainly nothing any more. And yes, I saw a 'division by zero'-message one time. For an emty form at design-time a rather strange thing.

One glance I could grab and saw, the images had slipped one digit. May be they shall be at 0, 1, 2, 3, 4 and slipped to 1,2,3,4,5. This would explain the strange things.

So my question: Can you load images at the size of 256 x 256 into a TImageList in Lazarus 4?
Fhe format is png und jpg.

And to add: As I could not load any image into my software, I tried it by a TSpeedbutton, which works by direct loading as alternative. This loads, but damages my image. It looks scratched. No transparency, I saved them to jpg to make sure. It stayed scratched after direct loading to a TSpeedbutton as Glyph.

wp

  • Hero Member
  • *****
  • Posts: 12926
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #1 on: June 12, 2025, 11:17:32 pm »
Can you load images at the size of 256 x 256 into a TImageList in Lazarus 4?
Yes - see attachment (tested on Windows and Linux). Do not forget to set the imagelist's Width and Height to 256 before loading any images to it.

Nicole

  • Hero Member
  • *****
  • Posts: 1219
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #2 on: June 13, 2025, 03:10:55 pm »
For me it does not work.
Today, after a restart, at least the TImageList was in my project.  (Hint: It is about Images_Main. The other one 16 x 16 are copied from Lazarus 3 and works fine since long.)

"setting the size before loading it", - I tried this for hours.
My problem is, that it insists on 16 x 16 as default.
The 256 x 256 are only the "second choice".
Trying to change this, gave me an error message "you cannot delete the default".
I really tried all functions of the ImageEditor. And if I missed the crucial ones, the menu shall be changed for DAUS to use as well.

I tried "registring a new size" and failed with 256 px.
In Lazarus 3 und der Win 7 - I ended up with odd formats alike 16 x 128.
Now idea how this can be or how it was done.
I only can key in one value (I thing width), what seems to be squared.

And last not least: The destruction of the pixels.
The image-editor preview shows me the images ok and in my form at design time and a runtime, the images are destroyed in terms of quality.

I cannot upload all my attempts of hours. But as I start new from scratch, I can upload my whole project for the first time.

to all: Pls do not share the images, they have copyrights.

and to add:
The object inspector does not show me previews any more.

PS: I cannot upload, because it is too huge.
There is nothing in the form?
This is an interesting point. I make you a link:
https://www.mediafire.com/file/ueofhzkqqp273oa/Bilderraetsel.rar/file

wp

  • Hero Member
  • *****
  • Posts: 12926
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #3 on: June 13, 2025, 08:03:46 pm »
"setting the size before loading it", - I tried this for hours.
My problem is, that it insists on 16 x 16 as default.
The 256 x 256 are only the "second choice".
Trying to change this, gave me an error message "you cannot delete the default".
I really tried all functions of the ImageEditor. And if I missed the crucial ones, the menu shall be changed for DAUS to use as well.
The "default" size of the images in the ImageList (i.e. the size at 96ppi) is determined by the ImageList.Width and .Height properties. When you you need 256x256 images as default, at first set these properties accordingly. Then double-click on the ImageList, select "Add" > "Add Image...", select the first 256x256 image in the file manager windows > "OK". Or you load several images at once by selecting several images by selecting them with CTRL+click. Note that you can also add images at different sizes, but they will always be rescaled to 256x256.

While these steps were for handling a single image size in the ImageList you can also load several sizes of the same motif - this is needed when your monitor resolution changes at runtime from the design resolution, say 192 ppi (200%). The effect depends on how the images are displayed. If you, for example, show the images in a TImage control, LCL scaling will blow up the control to double size. If the TImage has Stretch = false, your image will fill the control only partially. Or conversely, when Stretch is true, the image will be scaled up by duplicating each pixel which results in poor quality. If you want to display high-quality images also at 200% resolution, you must first set the Scaled property of the ImageList to true so that it can react on changes in screen resolution. Next, you must tell the Imagelist, which image sizes it should provide in high quality. Usually it is recommended to provide images as 150% and 200% resolutions. In the ImageList editor of Laz 4.0, go to "Resolutions" > "Register new resolution (image size)..." > enter an image width of 384 (150% of the base size 256) > "OK". then repeat with an image width of 512 for 200% of the base size. To simplify adding all these images it is recommended to have all image sizes in the same folder. Select "Add image with multiple resolutions", in the file manager window select the three sizes of the first motiv by CTLR-clicking. After "OK" you'll have all three images in the ImageListeditor (well maybe only partially because your size is so large...). Then repeat with the next image, etc.

And last not least: The destruction of the pixels.
The image-editor preview shows me the images ok and in my form at design time and a runtime, the images are destroyed in terms of quality.
What do you mean with "destroyed in terms of quality"? Can you upload a screenshot and maybe an image which is "destroyed" this way? (Or upload it to some cloud and send me the link by PM if you are not allowed to share the image). I assume that you are on gtk2, and gtk2 has some issue in drawing images in Laz 4.0.

Nicole

  • Hero Member
  • *****
  • Posts: 1219
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #4 on: June 13, 2025, 09:30:11 pm »
I will report step by step as I saw it. At the end you will suspect, the problem is everything else but the image editor.

Let me start:
What I changed: I was not aware, that I can use the object inspector to change the size. So I just added a new TImageList and it looked fine at first sight. However the object inspector does not show me the preview and the images are damaged. I tried to delete one of the TImageList as the hold the same images.

Then the fireworks start again. I watched it going bad and worse and the last one was that bad, that I could not even save the screenshot until Lazarus "was over". Then I could do it.

See the screeshots.

Then I wanted to show you the "damage" as screenshot and re-tried. I deleted the TImageEditor (see screenshot, what you see is a different one). See at the screenshot how this looks at design-time. Gone, no 256 images.

Then look at runtime: The images are still there although they do not exist in my form and more in any image-editor. The tiny pixels are the 16 bit fractals of the Tmages, which I had deleted completely.

So the troubel must come from a pointer to nil anywhere. A TImageEditor ghoast. However it should not happen and it should not crash the IDE.

I never was a professional programmer. Now I am new to Lazarus and new to Linux and not able to run debug version. However Lazarus 4 shall not do such things. I try to zipp all and upload it here:

https://www.mediafire.com/file/vj1x2923a06gx1n/lame_tiger.rar/file

Hoefully it is useful to any developer.

https://www.mediafire.com/file/vj1x2923a06gx1n/lame_tiger.rar/file
The screenshots are uploaded here.



wp

  • Hero Member
  • *****
  • Posts: 12926
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #5 on: June 13, 2025, 11:54:04 pm »
I'm a bit lost with these uploads because i don't find anything related to 256x256 images in them.

In an earlier commit of yours I found the "Bilderraetsel" project, which does contain such large images, but in an incorrectly set up image list. As I told you, first set ImageList_Main.Width and .Heigth to 256 and then load the images. But you first loaded the images (when ImageList_Main.Width and .Height still are at their default of 16), and then you added 256 as another resolution.

I modified this project so that it works. Unfortunately it exceeded the upload limit and I had to resave the images as jpeg in lower quality to reduce the file size and to remove the ImageList_16 which is not needed in the current version of the project.

Hoping it helps you a bit...

Nicole

  • Hero Member
  • *****
  • Posts: 1219
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #6 on: June 14, 2025, 03:03:32 pm »
Hi Werner,

thank you so much for your attempts. To my mind, there is nothing wrong with my TImageList as such. This is exactly the point as you put it: You CANNOT see it at design time, but the software displays it at runtime! Please read the sentence again.

This means, that internally there is a file, which holds this TImageList and does not "confess" this. The moment, I try to add my TImageList at design time the conflict and the trouble starts. The file blows up and there are probably a lot of ghosted TImageLists internally. This is that evil, that my whole Linux VM freezes.

The first thing, which made me suspicious was, as I tried to forum-upload my file was "too large". What?! Some lines of text too large? How can it be?

I wonder, if the "bad quality" of images I found, is nothing but a mass of images of the same kind, which results from internal masses of TImageLists, I cannot see at design time.

This is really important for the developers of Lazarus 4. You see the "terrible" error messages coming from quite an empty form at the screenshots (last upload here). There is an internal conflict in the basic system of the function of Lazarus 4. Unfortunately I am not able to run debug versions at this time. I am overwhelmed by all the new things I started.  Therefore, I uploaded all of it, including all the files in my directory for somebody of the developers to have a look at it (second posted link to mediafire). Because the bug inside is somthing which must be a crucial thing. Therefore, I said the TImagList seems not the problem. But the "invisible ghosts" of TImageLists are.

If you know anybody who can care about the issue, this would be great. If not, the chance is lost. To my mind, it is worthwhile to follow. Because the project is very basic with nothing inside than several nested PageControls and the  half-baked TImageList which is invisible at design-time and visible at runtime.

(what I will do: Deleting everything and start with my project again from scratch)

wp

  • Hero Member
  • *****
  • Posts: 12926
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #7 on: June 14, 2025, 07:38:42 pm »
The project that I uploaded in reply #5 has no issues at runtime at all. Are you sure that your system is set up correctly?  Can you compile other Lazarus projects in your Linux? Try the examples coming with Lazarus - no guarantee, but they should compile and run fine (but load them via the Examples window in the Tools menu to copy them into user space where you have write premissions).
« Last Edit: June 14, 2025, 08:05:55 pm by wp »

Nicole

  • Hero Member
  • *****
  • Posts: 1219
Re: TimageList - Lazarus 4 with 256 x 256 - does not work
« Reply #8 on: June 16, 2025, 11:15:08 am »
There is and was nothing wrong with TImageList.
The problem is Lazarus 4, at least under Linux.

I took my code (written exclusively in Lazarus 4), copied it and opened it in my old Win 7 VM under Lazarus 3.0. It works fine. I suspended my work with Linux and Lazarus 4 because the system keeps freezing and showing me error messages without text. I try to serve the community, but here I am stuck and returned to my old things to work on my project again.

Thank you for your help and attempts!

 

TinyPortal © 2005-2018