Recent

Author Topic: [SOLVED] Problem changing thumbnail size in ThumbViewer component  (Read 1542 times)

madepabloh

  • Full Member
  • ***
  • Posts: 160
Hi there,
I have an issue with Thumbviwer component. I habe a thumbcontrol where i load images form a directory. The layout is set to LsGrid and Autosizeoption = true. Thumbs heights and widths are set to 100 by default.
I added a trackbar with max and min set to 1 and 5 respectively. The idea is to allow the user to change the thumbnails size on runtime.

To do it. i use this code:
Code: Pascal  [Select][+][-]
  1. Thumbcontrol1.ThumbWidth := 100*Trackbar1.position;
  2. Thumbcontrol1.ThumbWidth := 100*Trackbar1.position;
  3.  

It works partially. The image frame changes properly, adjusting the imageframe and its caption, but the image itself does not change at all, keeping the original size.
I tried adding different commands to the procedure:
Code: Pascal  [Select][+][-]
  1. Thumbcontrol1.Repaint;
  2. Thumbcontrol1.Update;
  3. Thumbcontrol1.Refresh;
  4.  

But nothings results on the correct resizing of the picture, as it works when changing the thumbcontrol size. In fact, i also tried to change the control size, to see if it works as it should be, by this code:
Code: Pascal  [Select][+][-]
  1. Thumbcontrol1.Width := Thumbcontrol1.Width +1;
  2. Thumbcontrol1.Width := Thumbcontrol1.Width - 1;
  3.  
Again without results.

Do you have idea how could i solve this issue?
Thanks!
« Last Edit: May 19, 2021, 04:46:02 pm by madepabloh »

wp

  • Hero Member
  • *****
  • Posts: 8548
Re: Problem changing thumbnail size in ThumbViewer component
« Reply #1 on: May 19, 2021, 03:06:38 pm »
Which ThumbViewer is this? Theo's Thumbviewer (https://github.com/theo222/lazarus-thumbviewer)? In this case you must first set the new thumbnail size, then erase the cached thumbnail images (ThumbControl1.ImageLoaderManager.FreeImages) and finally reload the images which creates new thumbnails (ThumbControl.ImageLoaderManager.LoadAll). This works in my test.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

madepabloh

  • Full Member
  • ***
  • Posts: 160
Re: Problem changing thumbnail size in ThumbViewer component
« Reply #2 on: May 19, 2021, 04:45:33 pm »
Thanks @wp.
Yes, it is. The Theo's Thumbviewer (https://github.com/theo222/lazarus-thumbviewer).

I changed my code to fit your recomendation and it works perfectly!!
Code: Pascal  [Select][+][-]
  1. Thumbcontrol1.ThumbHeight := 100 * Trackbar1.Position;
  2. Thumbcontrol1.ThumbWidth := 100 * Trackbar1.Position; ThumbControl1.ImageLoaderManager.FreeImages;
  3.  ThumbControl1.ImageLoaderManager.LoadAll;
  4.  

So, SOLVED.
Thanks so much @wp

 

TinyPortal © 2005-2018