'Quickly loading, resizing, and displaying images from disk

I'm learning my way around windows forms by making a little app to help clean up a folder on my PC with thousands of images. I'm currently storing the images as a List<FileInfo>. It works fine using

PicBox.Load(ImageFileList[count++].imgFile.FullName);

but that's a bit slow when I only need a second to look at each image.

So the problems are:

  1. How to load the images quickly
  2. How to do so in a folder where one image might be a 25kb png and the next might be a 1GB TIFF

If I open an image from the folder in Windows Photo Viewer and hold the right arrow key, it zips along with blurry images I assume are resized thumbnails and a loading message over them. In Win 10 Photos, it loads non-blurry images faster but hiccups when it hits larger files. Either of those behaviors would be fine for me.



Solution 1:[1]

Try to do your things using background tasks :

https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/walkthrough-implementing-a-form-that-uses-a-background-operation?view=netframeworkdesktop-4.8

Maybe this can help too :

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.application.doevents?view=windowsdesktop-6.0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rivo R.