actually rotate the image in output

This commit is contained in:
Colin McMillen 2023-09-15 13:10:41 -04:00
parent 0417c354d5
commit 9db0ddd15c
2 changed files with 11 additions and 3 deletions

View File

@ -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));
}

View File

@ -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\");