xnview wrote:Jou wrote:If you read my suggestion in
http://newsgroup.xnview.com/viewtopic.p ... 92#p103154 -
Can it work to scale only for viewing? When I move the slider (even if xnview is still reading the pictures to create thumbs) the scaling routine seems to be lighting fast, and shows smaller-than-cached thumbs in good quality.
So scaling thumbnail? But which size to use?
I hope you don't mind my syntax here, my coding times are 15+ years away (except for things which are not worth mentioning in freebasic).
int used to cut of everything behind the comma "in my times", i.e. always round down.
All vars are int.
ThumbnailWidth is the Width of the Thumbnail as defined via the zoom bar or the option menu.
WindowsWidth is the width of the viewable area (not whole xnview).
NumberOfPicturesPerRow = (WindowWidth+ThumbnailWidth-1) / ThumbnailWidth
ThumbnailWidthViewOnly = WindowWidth / NumberOfPicturesPerRow
You _could_ use float for ThumbnailWidthViewOnly if your scaling routine can handle it, makes it smoother.
If you need the ScalingFactor instead of ThumbnailWidthViewOnly:
ScalingFactor = (WindowWidth / NumberOfPicturesPerRow) / ThumbnailWidth
The complex part: I completely ignored the the border around the thumbnail, my example only works for BorderWidth=0.
My try with Border looks like this (if I didn't miss something obvious):
NumberOfPicturesPerRow = (WindowWidth+ThumbnailWidth+BorderWidth*2-1) / (ThumbnailWidth+BorderWidth*2)
ThumbnailWidthWithBorderViewOnly = WindowWidth / NumberOfPicturesPerRow
ThumbnailWidthViewOnly = ThumbnailWidthWithBorderViewOnly - BorderWidth*2