load all metadata at beginning, load textures afterwards
This commit is contained in:
parent
9796827f96
commit
060565b44a
26
Program.cs
26
Program.cs
@ -147,6 +147,7 @@ void main() {
|
|||||||
public class Photo {
|
public class Photo {
|
||||||
public string File;
|
public string File;
|
||||||
public bool Loaded = false;
|
public bool Loaded = false;
|
||||||
|
public Vector2i Size;
|
||||||
public string CameraModel = "";
|
public string CameraModel = "";
|
||||||
public string LensModel = "";
|
public string LensModel = "";
|
||||||
public string FocalLength = "<unk>";
|
public string FocalLength = "<unk>";
|
||||||
@ -164,6 +165,11 @@ public class Photo {
|
|||||||
File = file;
|
File = file;
|
||||||
this.placeholder = placeholder;
|
this.placeholder = placeholder;
|
||||||
texture = 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() {
|
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
|
// 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.
|
||||||
Image<Rgba32> tmpImage = await Image.LoadAsync<Rgba32>(File);
|
Image<Rgba32> tmpImage = await Image.LoadAsync<Rgba32>(File);
|
||||||
ParseExif(tmpImage.Metadata.ExifProfile);
|
|
||||||
TryParseRating(tmpImage.Metadata.XmpProfile, out Rating);
|
|
||||||
Util.RotateImageFromExif(tmpImage, Orientation);
|
Util.RotateImageFromExif(tmpImage, Orientation);
|
||||||
image = tmpImage;
|
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\Germany all\104D7000");
|
||||||
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
|
// 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++) {
|
for (int i = 0; i < files.Count(); i++) {
|
||||||
string file = files[i];
|
string file = files[i];
|
||||||
if (file.ToLower().EndsWith(".jpg")) {
|
if (file.ToLower().EndsWith(".jpg")) {
|
||||||
Photo photo = new Photo(file, TEXTURE_BLACK);
|
Photo photo = new Photo(file, TEXTURE_BLACK);
|
||||||
photos.Add(photo);
|
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() {
|
protected override void OnUnload() {
|
||||||
|
Loading…
Reference in New Issue
Block a user