Compare commits
No commits in common. "6c7dbe551680070ec37e7dc127e9d65005d6985f" and "56311bc56c1ab5992accc7d27c9dc4658a6353bd" have entirely different histories.
6c7dbe5516
...
56311bc56c
82
Program.cs
82
Program.cs
@ -142,15 +142,8 @@ void main() {
|
|||||||
|
|
||||||
// FIXME: this should probably be IDisposable?
|
// FIXME: this should probably be IDisposable?
|
||||||
public class Photo {
|
public class Photo {
|
||||||
public string File;
|
|
||||||
public bool Loaded = false;
|
public bool Loaded = false;
|
||||||
public string? CameraModel;
|
public string File;
|
||||||
public string? LensModel;
|
|
||||||
public string FocalLength = "<unk>";
|
|
||||||
public string FNumber = "<unk>";
|
|
||||||
public string ExposureTime = "<unk>";
|
|
||||||
public string IsoSpeed = "<unk>";
|
|
||||||
|
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Texture placeholder;
|
private Texture placeholder;
|
||||||
private Image<Rgba32>? image = null;
|
private Image<Rgba32>? image = null;
|
||||||
@ -165,61 +158,12 @@ public class Photo {
|
|||||||
image = await Image.LoadAsync<Rgba32>(File);
|
image = await Image.LoadAsync<Rgba32>(File);
|
||||||
ExifProfile? exifs = image.Metadata.ExifProfile;
|
ExifProfile? exifs = image.Metadata.ExifProfile;
|
||||||
if (exifs != null) {
|
if (exifs != null) {
|
||||||
// FIXME: handle Orientation
|
foreach (IExifValue exif in exifs.Values) {
|
||||||
IExifValue<string>? model;
|
if (exif.Tag.ToString() == "Model") {
|
||||||
if (exifs.TryGetValue(ExifTag.Model, out model)) {
|
Console.WriteLine($"{File} {exif.Tag}: {exif.GetValue()}");
|
||||||
CameraModel = model.Value;
|
|
||||||
}
|
|
||||||
IExifValue<string>? lensModel;
|
|
||||||
if (exifs.TryGetValue(ExifTag.LensModel, out lensModel)) {
|
|
||||||
LensModel = lensModel.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
IExifValue<Rational>? focalLength;
|
|
||||||
if (exifs.TryGetValue(ExifTag.FocalLength, out focalLength)) {
|
|
||||||
Rational r = focalLength.Value;
|
|
||||||
FocalLength = $"{r.Numerator / r.Denominator}mm";
|
|
||||||
}
|
|
||||||
|
|
||||||
IExifValue<Rational>? fNumber;
|
|
||||||
if (exifs.TryGetValue(ExifTag.FNumber, out fNumber)) {
|
|
||||||
Rational r = fNumber.Value;
|
|
||||||
if (r.Denominator == 1) {
|
|
||||||
FNumber = $"f/{r.Numerator}";
|
|
||||||
} else {
|
|
||||||
// FIXME: assert that numerator is 10
|
|
||||||
if (r.Numerator % 10 == 0) {
|
|
||||||
FNumber = $"f/{r.Numerator / 10}";
|
|
||||||
} else {
|
|
||||||
FNumber= $"f/{r.Numerator / 10}.{r.Numerator % 10}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IExifValue<Rational>? exposureTime;
|
|
||||||
if (exifs.TryGetValue(ExifTag.ExposureTime, out exposureTime)) {
|
|
||||||
Rational r = exposureTime.Value;
|
|
||||||
if (r.Numerator == 1) {
|
|
||||||
ExposureTime = $"1/{r.Denominator}";
|
|
||||||
} else if (r.Numerator == 10) {
|
|
||||||
ExposureTime = $"1/{r.Denominator / 10}";
|
|
||||||
} else {
|
|
||||||
Console.WriteLine("*** WARNING: unexpected ExposureTime numerator");
|
|
||||||
ExposureTime = r.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IExifValue<ushort[]>? isoSpeed;
|
|
||||||
if (exifs.TryGetValue(ExifTag.ISOSpeedRatings, out isoSpeed)) {
|
|
||||||
ushort[]? iso = isoSpeed.Value;
|
|
||||||
if (iso != null && iso.Length >= 1) {
|
|
||||||
IsoSpeed = $"ISO {iso[0]}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// foreach (IExifValue exif in exifs.Values) {
|
|
||||||
// Console.WriteLine(exif.Tag.ToString() + " " + exif.GetValue().ToString());
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture Texture() {
|
public Texture Texture() {
|
||||||
@ -231,15 +175,6 @@ public class Photo {
|
|||||||
}
|
}
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Description() {
|
|
||||||
if (Loaded) {
|
|
||||||
string shootingInfo = $"{FocalLength}, {FNumber} at {ExposureTime}, {IsoSpeed}";
|
|
||||||
return String.Format("{0,-40} {1,-50} {2}", shootingInfo, $"{CameraModel} {LensModel}", File);
|
|
||||||
} else {
|
|
||||||
return String.Format("{0,-90} {1}", "", File);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Texture : IDisposable {
|
public class Texture : IDisposable {
|
||||||
@ -358,6 +293,7 @@ public static class Util {
|
|||||||
image.Dispose();
|
image.Dispose();
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Game : GameWindow {
|
public class Game : GameWindow {
|
||||||
@ -499,10 +435,8 @@ public class Game : GameWindow {
|
|||||||
// Load textures from JPEGs.
|
// Load textures from JPEGs.
|
||||||
string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
|
string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
|
||||||
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
|
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
|
||||||
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
|
|
||||||
// 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\");
|
|
||||||
|
|
||||||
for (int i = 0; i < files.Count(); i++) {
|
for (int i = 0; i < files.Count(); i++) {
|
||||||
string file = files[i];
|
string file = files[i];
|
||||||
@ -510,9 +444,7 @@ public class Game : GameWindow {
|
|||||||
Photo photo = new Photo(file, TEXTURE_WHITE);
|
Photo photo = new Photo(file, TEXTURE_WHITE);
|
||||||
photos.Add(photo);
|
photos.Add(photo);
|
||||||
await Task.Run( () => { photo.Load(); });
|
await Task.Run( () => { photo.Load(); });
|
||||||
if (photos.Count == 100) {
|
Console.WriteLine("file " + i);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -562,7 +494,7 @@ public class Game : GameWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw status box.
|
// Draw status box.
|
||||||
DrawText(activePhoto.Description(), geometry.StatusBox.Min.X + 80, geometry.StatusBox.Min.Y);
|
DrawText(activePhoto.File, geometry.StatusBox.Min.X + 80, geometry.StatusBox.Min.Y);
|
||||||
if (activePhoto.Loaded) {
|
if (activePhoto.Loaded) {
|
||||||
DrawText($"{(scale * 100):F1}%", geometry.StatusBox.Min.X, geometry.StatusBox.Min.Y);
|
DrawText($"{(scale * 100):F1}%", geometry.StatusBox.Min.X, geometry.StatusBox.Min.Y);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user