diff --git a/Program.cs b/Program.cs index 14ac841..71b437f 100644 --- a/Program.cs +++ b/Program.cs @@ -147,6 +147,7 @@ void main() { public class Photo { public string File; public bool Loaded = false; + public Vector2i Size; public string CameraModel = ""; public string LensModel = ""; public string FocalLength = ""; @@ -164,6 +165,11 @@ public class Photo { File = file; this.placeholder = placeholder; texture = placeholder; + + ImageInfo info = Image.Identify(file); + Size = new(info.Size.Width, info.Size.Height); + ParseExif(info.Metadata.ExifProfile); + TryParseRating(info.Metadata.XmpProfile, out Rating); } public async void Load() { @@ -171,8 +177,6 @@ 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. Image tmpImage = await Image.LoadAsync(File); - ParseExif(tmpImage.Metadata.ExifProfile); - TryParseRating(tmpImage.Metadata.XmpProfile, out Rating); Util.RotateImageFromExif(tmpImage, Orientation); image = tmpImage; } @@ -585,27 +589,17 @@ public class Game : GameWindow { // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\"); - Console.WriteLine(DateTime.Now.ToString()); - for (int i = 0; i < files.Count(); i++) { - string file = files[i]; - if (file.ToLower().EndsWith(".jpg")) { - ImageInfo info = Image.Identify(file); - Console.WriteLine(file + " " + i + " " + info.Size); - } - } - Console.WriteLine(DateTime.Now.ToString()); - for (int i = 0; i < files.Count(); i++) { string file = files[i]; if (file.ToLower().EndsWith(".jpg")) { Photo photo = new Photo(file, TEXTURE_BLACK); photos.Add(photo); - await Task.Run( () => { photo.Load(); }); - if (photos.Count == 100) { - break; - } } } + + for (int i = 0; i < 100 && i < photos.Count; i++) { + await Task.Run( () => { photos[i].Load(); }); + } } protected override void OnUnload() {