From cbea0503341208e6799ed5aa39dcb690ea2ce91c Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Thu, 24 Aug 2023 21:25:06 -0400 Subject: [PATCH] temporary test: loading small thumbs only --- Photo.cs | 6 +++++- Program.cs | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Photo.cs b/Photo.cs index f6a9c0b..8941f9c 100644 --- a/Photo.cs +++ b/Photo.cs @@ -2,6 +2,7 @@ using OpenTK.Mathematics; using Image = SixLabors.ImageSharp.Image; using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Xmp; +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Jpeg; using System.Text; 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 // a texture for it until that's already happened. LastTouch = touchCounter++; - Image tmp = await Image.LoadAsync(Filename); + DecoderOptions options = new DecoderOptions { + TargetSize = new Size(256, 256) + }; + Image tmp = await Image.LoadAsync(options, Filename); Util.RotateImageFromExif(tmp, Orientation); image = tmp; } diff --git a/Program.cs b/Program.cs index b9ebbda..4169425 100644 --- a/Program.cs +++ b/Program.cs @@ -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\import"); // 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\many-birds\"); + string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000"); + // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\"); for (int i = 0; i < files.Count(); i++) { string file = files[i]; @@ -669,6 +669,7 @@ public class Game : GameWindow { } private void UnloadImages() { + return; // Unload images that haven't been touched in a while. // FIXME: keep around thumbnail-sized textures? lock (loadedImagesLock) { @@ -704,7 +705,8 @@ public class Game : GameWindow { } // Start loading any images that are in our window but not yet loaded. 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 toLoad = new(); for (int i = minLoadedImage; i <= maxLoadedImage; i++) { lock (loadedImagesLock) {