handle ExposureTime edge cases (for long exposures)
use a black texture while loading instead of white print some more error messages in EXIF edge cases
This commit is contained in:
parent
6c7dbe5516
commit
25ca0d99ff
24
Program.cs
24
Program.cs
@ -166,10 +166,12 @@ public class Photo {
|
||||
ExifProfile? exifs = image.Metadata.ExifProfile;
|
||||
if (exifs != null) {
|
||||
// FIXME: handle Orientation
|
||||
|
||||
IExifValue<string>? model;
|
||||
if (exifs.TryGetValue(ExifTag.Model, out model)) {
|
||||
CameraModel = model.Value;
|
||||
}
|
||||
|
||||
IExifValue<string>? lensModel;
|
||||
if (exifs.TryGetValue(ExifTag.LensModel, out lensModel)) {
|
||||
LensModel = lensModel.Value;
|
||||
@ -187,7 +189,9 @@ public class Photo {
|
||||
if (r.Denominator == 1) {
|
||||
FNumber = $"f/{r.Numerator}";
|
||||
} else {
|
||||
// FIXME: assert that numerator is 10
|
||||
if (r.Denominator != 10) {
|
||||
Console.WriteLine($"*** WARNING: unexpected FNumber denominator: {r.Denominator}");
|
||||
}
|
||||
if (r.Numerator % 10 == 0) {
|
||||
FNumber = $"f/{r.Numerator / 10}";
|
||||
} else {
|
||||
@ -203,8 +207,12 @@ public class Photo {
|
||||
ExposureTime = $"1/{r.Denominator}";
|
||||
} else if (r.Numerator == 10) {
|
||||
ExposureTime = $"1/{r.Denominator / 10}";
|
||||
} else if (r.Denominator == 1) {
|
||||
ExposureTime = $"{r.Numerator }\"";
|
||||
} else if (r.Denominator == 10) {
|
||||
ExposureTime = $"{r.Numerator / 10}.{r.Numerator % 10}\"";
|
||||
} else {
|
||||
Console.WriteLine("*** WARNING: unexpected ExposureTime numerator");
|
||||
Console.WriteLine($"*** WARNING: unexpected ExposureTime: {r.Numerator}/{r.Denominator}");
|
||||
ExposureTime = r.ToString();
|
||||
}
|
||||
}
|
||||
@ -212,8 +220,13 @@ public class Photo {
|
||||
IExifValue<ushort[]>? isoSpeed;
|
||||
if (exifs.TryGetValue(ExifTag.ISOSpeedRatings, out isoSpeed)) {
|
||||
ushort[]? iso = isoSpeed.Value;
|
||||
if (iso != null && iso.Length >= 1) {
|
||||
IsoSpeed = $"ISO {iso[0]}";
|
||||
if (iso != null) {
|
||||
if (iso.Length != 1) {
|
||||
Console.WriteLine($"*** WARNING: unexpected ISOSpeedRatings array length: {iso.Length}");
|
||||
}
|
||||
if (iso.Length >= 1) {
|
||||
IsoSpeed = $"ISO {iso[0]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
// foreach (IExifValue exif in exifs.Values) {
|
||||
@ -364,6 +377,7 @@ public class Game : GameWindow {
|
||||
public Game(GameWindowSettings gwSettings, NativeWindowSettings nwSettings) : base(gwSettings, nwSettings) {}
|
||||
|
||||
private static Texture TEXTURE_WHITE = new(new Image<Rgba32>(1, 1, new Rgba32(255, 255, 255)));
|
||||
private static Texture TEXTURE_BLACK = new(new Image<Rgba32>(1, 1, new Rgba32(0, 0, 0)));
|
||||
|
||||
UiGeometry geometry = new();
|
||||
|
||||
@ -507,7 +521,7 @@ public class Game : GameWindow {
|
||||
for (int i = 0; i < files.Count(); i++) {
|
||||
string file = files[i];
|
||||
if (file.ToLower().EndsWith(".jpg")) {
|
||||
Photo photo = new Photo(file, TEXTURE_WHITE);
|
||||
Photo photo = new Photo(file, TEXTURE_BLACK);
|
||||
photos.Add(photo);
|
||||
await Task.Run( () => { photo.Load(); });
|
||||
if (photos.Count == 100) {
|
||||
|
Loading…
Reference in New Issue
Block a user