Browse Source

don't hard-code aspect ratio

main
Colin McMillen 9 months ago
parent
commit
c1ed48b917
  1. 14
      Program.cs

14
Program.cs

@ -186,20 +186,20 @@ public class CropTool : ITool {
// left, right, top, bottom
(int, int, int, int) GetCrop() {
// FIXME: allow for unconstrained crop, 1:1, etc.
float aspectRatio = 1f * photo.Size.X / photo.Size.Y;
Vector2i start = mouseDragStart;
Vector2i end = mouseDragEnd;
int width = Math.Abs(end.X - start.X);
int height = Math.Abs(end.Y - start.Y);
int heightChange = Math.Min(height, (int) (width / CameraInfo.AspectRatio));
int widthChange = (int) (heightChange * CameraInfo.AspectRatio);
int heightChange = Math.Min(height, (int) (width / aspectRatio));
int widthChange = (int) (heightChange * aspectRatio);
if (end.X < start.X) {
widthChange *= -1;
}
if (end.Y < start.Y) {
heightChange *= -1;
}
// FIXME: choose the aspect ratio based on the original image aspect ratio.
// FIXME: allow for unconstrained crop, 1:1, etc.
end.Y = start.Y + heightChange;
end.X = start.X + widthChange;
int left = Math.Min(start.X, end.X);
@ -684,11 +684,11 @@ public class Game : GameWindow {
false, 5 * sizeof(float), 3 * sizeof(float));
// Load photos from a directory.
// 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\23\");
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\29");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\29");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\import");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
@ -804,8 +804,6 @@ public class Game : GameWindow {
// $ identify -verbose image.jpg | grep Quality:
// FIXME: don't ExportPhotos() if another export is already active.
// FIXME: show a progress bar or something.
// FIXME: if there's a photo missing GPS information, copy the information
// from the previous photo in the export.
private async void ExportPhotos() {
JpegEncoder encoder = new JpegEncoder() { Quality = 100 };
foreach (Photo p in photos) {

Loading…
Cancel
Save