Compare commits

..

2 Commits

Author SHA1 Message Date
775252b567 thumbnail size to 150x150 2023-09-19 14:14:07 -04:00
7bd3719c72 performance enhancements 2023-09-19 14:11:03 -04:00

View File

@ -846,7 +846,7 @@ public class Game : GameWindow {
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg"); // string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg");
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\"); // string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\03"); // string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\03");
string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import"); string[] files = Directory.GetFiles(@"c:\users\colin\desktop\17\2-jpg");
// 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\");
@ -897,7 +897,7 @@ public class Game : GameWindow {
private void UnloadImages() { private void UnloadImages() {
// Unload images that haven't been touched in a while. // Unload images that haven't been touched in a while.
lock (loadedImagesLock) { lock (loadedImagesLock) {
while (loadedImages.Count > 30) { while (loadedImages.Count > 20) {
long earliestTime = long.MaxValue; long earliestTime = long.MaxValue;
Photo? earliest = null; Photo? earliest = null;
foreach (Photo photo in loadedImages) { foreach (Photo photo in loadedImages) {
@ -926,7 +926,7 @@ 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 - 10); int minLoadedImage = Math.Max(0, photoIndex - 5);
int maxLoadedImage = Math.Min(photoIndex + 10, photos.Count - 1); int maxLoadedImage = Math.Min(photoIndex + 10, 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++) {
@ -939,7 +939,8 @@ public class Game : GameWindow {
} }
} }
foreach (Photo p in toLoad) { foreach (Photo p in toLoad) {
await Task.Run( () => { p.LoadAsync(p.Size); }); // await Task.Run( () => { p.LoadAsync(p.Size); });
await Task.Run( () => { p.LoadAsync(geometry.PhotoBox.Size); });
} }
} }
@ -947,7 +948,7 @@ public class Game : GameWindow {
List<Task> tasks = new(); List<Task> tasks = new();
foreach (Photo p in allPhotos) { foreach (Photo p in allPhotos) {
tasks.Add(Task.Run( () => { tasks.Add(Task.Run( () => {
p.LoadThumbnailAsync(new Vector2i(256, 256)); p.LoadThumbnailAsync(new Vector2i(150, 150));
lock (numThumbnailsLoadedLock) { lock (numThumbnailsLoadedLock) {
numThumbnailsLoaded++; numThumbnailsLoaded++;
toast.Set($"[{numThumbnailsLoaded}/{allPhotos.Count}] Loading thumbnails"); toast.Set($"[{numThumbnailsLoaded}/{allPhotos.Count}] Loading thumbnails");