I just did more work on one of my home projects: the image-displaying screen saver I mentioned in this thread's 1st post. It now randomly loads an image from a list, displays it for x seconds, blanks the screen for y seconds, and repeats. These options x and y (and others) are controlled by a configuration file which is just assumed to be in the same directory as the screen saver executable (i.e. the file with .scr extension, typically located in C:\Windows\System32).
The image layout is as follows:
1. I use a general-purpose fitRect() function to fit the image within the screen saver window rect, maintaining the image's aspect ratio. This will result in the image's top and bottom fitting the top and bottom of the screen, or its left and right fitting the left and right of the screen (or perhaps both).
2. Apply a scaling factor (set in config file) from 0.0 to 1.0 to scale the image down from its "fit" size. This then allows me to:
3. Randomly position the image in the x and y dimension, by applying 2 randomly-generated scaling factors between 0.0 and 1.0. For x (horizontal), 0.0 is fully left and 1.0 is fully right, while for y (vertical), 0.0 is fully top and 1.0 is fully bottom. Of course, if the above size scaling factor is 1.0, then no repositioning may occur in the x and/or y dimension.
The config file will allow the user to specify image positioning as:
1. keep aspect ratio (or not).
2. stretch image to fit screen (can be used with aspect ratio=on, but the image will only stretch as far as its aspect ratio allows).
3. centre the image on the screen.
I've also put a lot of the general rectangle-handling and OpenGL code into reusable libraries, so now my main application and SCREENSAVERPROC function look nice and tidy.
So far, it's looking good.
As I mentioned previously, I'll be adding image size-filtering to the screen saver, so it doesn't display ridiculously small images (e.g. thumbnails) as they don't look that good when displayed on a large, black screen. I'm just trying to find a way to check the size of an image file (some of them a few MB in size) without having to read the whole file, as this is inefficient for large image lists.
Displaying the full path to the image file somewhere on the screen saver window (an option for the existing Windows image display screen saver) would also be nice, so I'll add that at some point. Also, transition effects when switching between the image display and the blank screen periods. So many ideas to implement!
Regards,
--- Victor.