Browse Source

temporary test: loading small thumbs only

main
Colin McMillen 9 months ago
parent
commit
cbea050334
  1. 6
      Photo.cs
  2. 8
      Program.cs

6
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<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);
image = tmp;
}

8
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<Photo> toLoad = new();
for (int i = minLoadedImage; i <= maxLoadedImage; i++) {
lock (loadedImagesLock) {

Loading…
Cancel
Save