Browse Source

actually rotate the image in output

main
Colin McMillen 9 months ago
parent
commit
9db0ddd15c
  1. 3
      Photo.cs
  2. 11
      Program.cs

3
Photo.cs

@ -219,6 +219,9 @@ public class Photo {
Console.WriteLine($"{Filename} => {jpgOut}");
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
if (Math.Abs(RotationDegrees) > 0.001) {
image.Mutate(x => x.Rotate(RotationDegrees));
}
if (CropRectangle != Rectangle.Empty) {
image.Mutate(x => x.Crop(CropRectangle));
}

11
Program.cs

@ -265,6 +265,10 @@ public class StraightenTool : ITool {
}
public ToolStatus HandleInput(KeyboardState input, MouseState mouse, Transform transform, Game game, Photo photo, UiGeometry geometry) {
if (input.IsKeyPressed(Keys.D0)) {
photo.RotationDegrees = 0;
}
if (input.IsKeyPressed(Keys.Left)) {
photo.RotationDegrees += .1f;
}
@ -700,6 +704,7 @@ public class Game : GameWindow {
}
// Handle tool switching.
// FIXME: prevent photo switching when tools other than ViewTool are active?
if (photos[photoIndex] != previousPhoto) {
activeTool = viewTool;
}
@ -708,7 +713,7 @@ public class Game : GameWindow {
if (input.IsKeyPressed(Keys.C)) {
activeTool = new CropTool(photos[photoIndex]);
}
if (input.IsKeyPressed(Keys.S)) {
if (input.IsKeyPressed(Keys.X)) {
activeTool = new StraightenTool(photos[photoIndex]);
}
}
@ -789,10 +794,10 @@ public class Game : GameWindow {
// Load photos from a directory.
// 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\09\06\jpg");
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\09\06\jpg");
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\08\03");
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\export");
string[] files = Directory.GetFiles(@"c:\users\colin\desktop\export");
// 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\many-birds\");

Loading…
Cancel
Save