Is there a way to fast load images to a much better speed than what LoadImage() currently does? I have a bunch of image names in a ListIconGadget, and when I click an item in the list, it loads the image to show in an ImageGadget. But if I scroll through the ListIconGadget (holding the down arrow key), each image is loaded but it's not very fast, and the scrolling is slow. My images are all PNG format and around 800 KB in size. I'd love to be able to just hold down the arrow key and scroll the ListIconGadget with the images flicking through the ImageGadget a lot faster.
Or maybe it's SetGadgetState() to the ImageGadget() that's slow? I don't know. Any tips?
Faster image loading?
Re: Faster image loading?
Hi Dude,
make a try with the Image Plugin from Wilbert
http://www.purebasic.fr/english/viewtop ... 12&t=66497
make a try with the Image Plugin from Wilbert
http://www.purebasic.fr/english/viewtop ... 12&t=66497
Re: Faster image loading?
for the scrolling issue, you could load the images in separate background threads.
c ya,
nco2k
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: Faster image loading?
I'll check out Wilbert's loader, as I can see some assembly code in there which may be the speed increase I need.
nco2k, what do you mean by threads? I can only load one image at a time, to show when it's selected by the user. Loading them all first is not an option (there's over 2000 of them, at 800 KB each).
nco2k, what do you mean by threads? I can only load one image at a time, to show when it's selected by the user. Loading them all first is not an option (there's over 2000 of them, at 800 KB each).
Re: Faster image loading?
who said anything about loading them all? currently you use the same thread for the event loop and the loading of the image. you click on a gadget item, and the event loop blocks until the image is loaded and displayed. if you put the loading of the image in a separate thread, your event loop wont block. like the windows explorer does it. you can scroll through them all without blocking, and the image itself will be displayed when its ready.
c ya,
nco2k
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: Faster image loading?
I suggest to look at :
1- Create an ImageList with icons for all your images and when the user pick one it will be loaded at once
2- Try GDI+ it should be faster than PB
3- Try OLE solution to load the images
Search the forum
1- Create an ImageList with icons for all your images and when the user pick one it will be loaded at once
2- Try GDI+ it should be faster than PB
3- Try OLE solution to load the images
Search the forum
Egypt my love
Re: Faster image loading?
I thought that's what you meant when you said "load the images" as opposed to "image" singular.nco2k wrote:who said anything about loading them all?
But loading in a background thread won't work, because I won't see the images as I scroll (just like Windows Explorer doesn't show until you stop scrolling). I need to see what I'm scrolling through because I'm looking for a specific image, so background threads won't do the job.
Currently it all works the way I like, but the image loading could be faster.
[Edit] Actually, I ended up doing Rashad's icon idea: when building the ListIconGadget, I loaded the image and resized it to 16x16 and used that as each item's listicon image. So I get to see a (tiny) thumbnail which makes it easier to preview what I want without loading the full image first. I can still scroll through the list and load each full image while scrolling, but the speed is of no concern now that I have a backup smaller thumbnail for reference.
As I always seem to say: thanks Rashad!
Re: Faster image loading?
Hi Dude
thumbnail 16x16 is tiny as you mentioned but this is a limit of the ListIcon()
Try bigger size with ImageList() and do not use column 0
Search the forum
thumbnail 16x16 is tiny as you mentioned but this is a limit of the ListIcon()
Try bigger size with ImageList() and do not use column 0
Search the forum
Egypt my love
Re: Faster image loading?
Loading PNG just is slow compared to JPEG (especially with a library like libjpeg-turbo).
Using a thumbnail might indeed be the best option.
Using a thumbnail might indeed be the best option.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)