temporary test: loading small thumbs only

This commit is contained in:
Colin McMillen 2023-08-24 21:25:06 -04:00
parent 44752c5567
commit cbea050334
2 changed files with 10 additions and 4 deletions

View File

@ -2,6 +2,7 @@ using OpenTK.Mathematics;
using Image = SixLabors.ImageSharp.Image; using Image = SixLabors.ImageSharp.Image;
using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.Metadata.Profiles.Xmp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
@ -48,7 +49,10 @@ public class Photo {
// edit the image due to rotation (etc) and don't want to try generating // edit the image due to rotation (etc) and don't want to try generating
// a texture for it until that's already happened. // a texture for it until that's already happened.
LastTouch = touchCounter++; LastTouch = touchCounter++;
Image<Rgba32> tmp = await Image.LoadAsync<Rgba32>(Filename); DecoderOptions options = new DecoderOptions {
TargetSize = new Size(256, 256)
};
Image<Rgba32> tmp = await Image.LoadAsync<Rgba32>(options, Filename);
Util.RotateImageFromExif(tmp, Orientation); Util.RotateImageFromExif(tmp, Orientation);
image = tmp; image = tmp;
} }

View File

@ -639,8 +639,8 @@ public class Game : GameWindow {
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\07\31"); // string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\07\31");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import"); // string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000"); string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
for (int i = 0; i < files.Count(); i++) { for (int i = 0; i < files.Count(); i++) {
string file = files[i]; string file = files[i];
@ -669,6 +669,7 @@ public class Game : GameWindow {
} }
private void UnloadImages() { private void UnloadImages() {
return;
// Unload images that haven't been touched in a while. // Unload images that haven't been touched in a while.
// FIXME: keep around thumbnail-sized textures? // FIXME: keep around thumbnail-sized textures?
lock (loadedImagesLock) { lock (loadedImagesLock) {
@ -704,7 +705,8 @@ public class Game : GameWindow {
} }
// Start loading any images that are in our window but not yet loaded. // Start loading any images that are in our window but not yet loaded.
int minLoadedImage = Math.Max(0, photoIndex - 30); int minLoadedImage = Math.Max(0, photoIndex - 30);
int maxLoadedImage = Math.Min(photoIndex + 30, photos.Count - 1); // int maxLoadedImage = Math.Min(photoIndex + 30, photos.Count - 1);
int maxLoadedImage = photos.Count - 1;
List<Photo> toLoad = new(); List<Photo> toLoad = new();
for (int i = minLoadedImage; i <= maxLoadedImage; i++) { for (int i = minLoadedImage; i <= maxLoadedImage; i++) {
lock (loadedImagesLock) { lock (loadedImagesLock) {