diff --git a/src/Chronos.App/Editor/CropCommit.cs b/src/Chronos.App/Editor/CropCommit.cs
new file mode 100644
index 00000000..219885d8
--- /dev/null
+++ b/src/Chronos.App/Editor/CropCommit.cs
@@ -0,0 +1,31 @@
+using System.Windows;
+using System.Windows.Input;
+using Chronos.Ui.Visuals;
+
+namespace Chronos.App.Editor;
+
+///
+/// Runs a command after every finished edit of the crop box on a (a drag released, a key
+/// press), with the as its parameter (owner review 1, R5).
+///
+public static class CropCommit
+{
+ public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached(
+ "Command", typeof(ICommand), typeof(CropCommit), new PropertyMetadata(null, OnCommandChanged));
+
+ public static ICommand? GetCommand(DependencyObject d) => (ICommand?)d.GetValue(CommandProperty);
+
+ public static void SetCommand(DependencyObject d, ICommand? value) => d.SetValue(CommandProperty, value);
+
+ private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is not PreviewViewport viewport) return;
+ viewport.CropEditCompleted -= OnEditCompleted;
+ if (e.NewValue is not null) viewport.CropEditCompleted += OnEditCompleted;
+ }
+
+ private static void OnEditCompleted(object sender, CropEditEventArgs e)
+ {
+ if (GetCommand((DependencyObject)sender) is { } command && command.CanExecute(e)) command.Execute(e);
+ }
+}
diff --git a/src/Chronos.App/Editor/EditorViewModel.cs b/src/Chronos.App/Editor/EditorViewModel.cs
index cff714b2..e4ffdf26 100644
--- a/src/Chronos.App/Editor/EditorViewModel.cs
+++ b/src/Chronos.App/Editor/EditorViewModel.cs
@@ -13,6 +13,7 @@ using Chronos.Core.Advice;
using Chronos.Core.Analysis;
using Chronos.Core.Diagnostics;
using Chronos.Core.Export;
+using Chronos.Core.Imaging.Geometry;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
@@ -64,9 +65,18 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
private bool _showRegions;
private bool _showCropMask;
private bool _exportCropMask = true;
+
+ /// The Camera step's Crop mask, on by default: the crop box is edited there (owner review 1, R5).
+ private bool _cameraCropMask = true;
private CropMaskMode _cropMaskMode = CropMaskMode.ShowLoss;
private PreviewZoomMode _zoomMode = PreviewZoomMode.Fit;
private Rect _cropRect = new(0, 0, 1, 1);
+ private Rect _editCrop = new(0, 0, 1, 1);
+ private double _cropLockRatio = 1;
+ private bool _isStraightening;
+
+ /// The orientation of the camera the picture on screen was framed with (the crop box maps onto that view frame).
+ private (int Rotate, bool Mirror, bool Flip, double Straighten) _shownOrientation;
private IReadOnlyList? _regionBoundary;
private IReadOnlyList? _motionVectors;
private int _previewEdge = DefaultPreviewEdge;
@@ -126,6 +136,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
{
if (StepFor(p) is { } step) SelectedTab = step;
});
+ CommitCropCommand = new RelayCommand(CommitCrop, _ => CropEditable);
Analysis = new AnalysisTab(this);
Frames = new FramesTab(this);
@@ -144,6 +155,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
// Until the link is read (AttachJobsAsync), a sequence of this PC cannot send its renders.
_syncGate = session.IsRemote ? ExportSyncGate.Remote : ExportSyncGate.SignedOut;
RenderChoices = [.. ExportPresets.BuiltIn.Select(p => new Choice(p.Id, p.NameKey))];
+ _shownOrientation = OrientationOf(session.Project.Camera);
+ UpdateCropBox();
session.ProjectChanged += OnProjectChanged;
session.ContentChanged += OnContentChanged;
@@ -277,6 +290,9 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
/// The Export step swaps the preview tools for compare, crop mask and a 10-second preview (Export.html).
public bool IsExportTab => SelectedTab is ExportTab;
+ /// The Camera step: its crop mask shows the crop box itself, edited on the picture (owner review 1, R5).
+ public bool IsCameraTab => SelectedTab is CameraTab;
+
/// The measuring area takes more of the height than the preview (the Analysis findings, the Export preset cards).
public bool IsTallMeasure => SelectedTab.PrefersTallMeasure;
@@ -364,21 +380,72 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
}
}
- /// The Crop mask tool of the current tab: the Export tab has its own, on by default (Export.html).
+ ///
+ /// The Crop mask tool of the current tab: the Export tab has its own, on by default (Export.html), and so has the Camera
+ /// step, where the crop box is edited (owner review 1, R5).
+ ///
public bool ShowCropMask
{
- get => IsExportTab ? _exportCropMask : _showCropMask;
+ get => IsExportTab ? _exportCropMask : IsCameraTab ? _cameraCropMask : _showCropMask;
set
{
if (value == ShowCropMask) return;
if (IsExportTab) _exportCropMask = value;
+ else if (IsCameraTab) _cameraCropMask = value;
else _showCropMask = value;
OnPropertyChanged();
OnPropertyChanged(nameof(CropModeToolTip));
+ OnCropEditableChanged();
RequestPreview(immediate: true);
}
}
+ ///
+ /// The crop box is moved and resized on the preview: the Camera step with its mask on, while the project can change
+ /// (not read-only, in a newer format, outdated or busy).
+ ///
+ public bool CropEditable => IsCameraTab && ShowCropMask && IsEditable && !Session.Project.IsNewerFormat && FrameCount > 0;
+
+ ///
+ /// The crop box the Camera step shows and edits (), normalised in the view frame
+ /// the Source picture shows; the preview sets it to each finished edit before runs.
+ ///
+ public Rect EditCrop
+ {
+ get => _editCrop;
+ set
+ {
+ if (!Set(ref _editCrop, value)) return;
+ if (IsCameraTab) OnPropertyChanged(nameof(CropRect));
+ }
+ }
+
+ /// The crop box's width over its height in normalised units (): the output proportions on the view frame.
+ public double CropLockRatio { get => _cropLockRatio; private set => Set(ref _cropLockRatio, value); }
+
+ ///
+ /// Writes a finished edit of the crop box (, or a normalised ) as the
+ /// camera crop, locked and with the offsets at 0 (owner review 1, R5): one drag is one undo step, a run of key presses
+ /// merges into one ("Camera.Crop") that the key release ends.
+ ///
+ public ICommand CommitCropCommand { get; }
+
+ /// The Straighten slider is dragged or has the keyboard: the preview shows a fine grid to level the horizon against.
+ public bool IsStraightening
+ {
+ get => _isStraightening;
+ set
+ {
+ if (Set(ref _isStraightening, value)) OnPropertyChanged(nameof(ShowStraightenGrid));
+ }
+ }
+
+ /// The straighten grid over the preview (Camera step, while straightening).
+ public bool ShowStraightenGrid => IsStraightening && IsCameraTab;
+
+ /// What a drag on the preview does: the crop box's moves and keys while it is edited there, else compare, pan and zoom.
+ public string PreviewToolTip => Loc.L(CropEditable ? "Tooltips.Editor.Preview.CropEdit" : "Tooltips.Editor.Preview.View");
+
/// Overlays the viewport draws: only tools that have a button on the current tab.
public bool ViewVectors => ShowVectors && !IsExportTab;
@@ -422,7 +489,20 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
set => ZoomMode = value ? PreviewZoomMode.Actual : PreviewZoomMode.Fit;
}
- public Rect CropRect { get => _cropRect; private set => Set(ref _cropRect, value); }
+ ///
+ /// The crop mask: on the Camera step the crop box (), elsewhere the footprint of the frame's output
+ /// (stabilisation and camera pose included) on the Source picture.
+ ///
+ public Rect CropRect
+ {
+ get => IsCameraTab ? _editCrop : _cropRect;
+ private set
+ {
+ if (_cropRect == value) return;
+ _cropRect = value;
+ if (!IsCameraTab) OnPropertyChanged();
+ }
+ }
public IReadOnlyList? RegionBoundary { get => _regionBoundary; private set => Set(ref _regionBoundary, value); }
@@ -800,6 +880,10 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
PreviewImage = r.Corrected;
OriginalImage = r.Original;
CropRect = r.Crop;
+ // The crop box of the picture now on screen: its view frame, its proportions.
+ _shownOrientation = OrientationOf(request.Project.Camera);
+ CropLockRatio = r.LockRatio;
+ EditCrop = r.EditCrop;
RegionBoundary = ViewRegions ? r.Horizon : null;
MotionVectors = ViewVectors ? r.Vectors : null;
WaveformImage = r.Waveform;
@@ -983,14 +1067,69 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
private void OnToolsChanged()
{
+ OnPropertyChanged(nameof(IsCameraTab));
OnPropertyChanged(nameof(ShowCropMask));
OnPropertyChanged(nameof(CropModeToolTip));
OnPropertyChanged(nameof(ViewVectors));
OnPropertyChanged(nameof(ViewRegions));
+ OnPropertyChanged(nameof(CropRect));
+ OnPropertyChanged(nameof(ShowStraightenGrid));
+ OnCropEditableChanged();
+ }
+
+ /// Whether the crop box is edited on the preview, and what a drag there does.
+ private void OnCropEditableChanged()
+ {
+ OnPropertyChanged(nameof(CropEditable));
+ OnPropertyChanged(nameof(PreviewToolTip));
+ }
+
+ /// The rendered orientation members of : the view frame the crop box is normalised in.
+ private static (int, bool, bool, double) OrientationOf(CameraSettings camera) =>
+ (FrameOrientation.TurnsOf(camera.Rotate), camera.Mirror, camera.Flip, FrameOrientation.StraightenOf(camera.Straighten));
+
+ ///
+ /// The crop box and its proportions for the project now, at once, while the picture on screen shows the same view frame
+ /// (a crop row, an aspect or preset change: no frame to wait for); a turn, mirror, flip or straighten waits for the
+ /// picture it applies to.
+ ///
+ private void UpdateCropBox()
+ {
+ var project = Session.Project;
+ if (OrientationOf(project.Camera) != _shownOrientation || Session.Content.SourceWidth <= 0 || Session.Content.SourceHeight <= 0) return;
+ try
+ {
+ var geometry = RenderGeometry.Create(project.Camera, ExportResolver.Resolve(project.Export), Session.Content.SourceWidth, Session.Content.SourceHeight);
+ CropLockRatio = geometry.LockRatio;
+ var box = geometry.EditableCrop;
+ EditCrop = new Rect(box.X, box.Y, box.Width, box.Height);
+ }
+ catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or RenderException)
+ {
+ Log.Warning("editor", "The crop box could not be worked out", ex);
+ }
+ }
+
+ private void CommitCrop(object? parameter)
+ {
+ var (crop, nudge) = parameter switch
+ {
+ CropEditEventArgs edit => (edit.Crop, edit.IsNudge),
+ Rect rect => (rect, false),
+ _ => (Rect.Empty, false),
+ };
+ if (crop.IsEmpty || !CropEditable) return;
+ // The box itself, locked to the proportions on screen, with the offsets at 0: the render's FitCrop returns it unchanged.
+ var box = CropFrame.Clamp(new RectD(crop.X, crop.Y, crop.Width, crop.Height), CropLockRatio);
+ EditCrop = new Rect(box.X, box.Y, box.Width, box.Height);
+ Session.Edit(p => p with { Camera = p.Camera with { Crop = CropFrame.ToCrop(box), OffsetX = 0, OffsetY = 0 } }, "Camera.Crop");
+ if (!nudge) Session.EndEditRun();
}
private void OnProjectChanged()
{
+ UpdateCropBox();
+ OnCropEditableChanged();
foreach (var tab in Tabs) tab.Refresh();
UpdateMarkers();
RefreshSteps();
@@ -1009,6 +1148,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
Planner = new ExportPlanner(Session.Content, _encoders, _host);
if (Thumbnails.Count != FrameCount) Thumbnails = new EditorThumbnails(Session.Source, FrameCount);
Corrections = null;
+ UpdateCropBox();
_rendered = new RenderedSettings(Session.Content.Renders);
foreach (var tab in Tabs) tab.OnContentChanged();
OnPropertyChanged(nameof(Summary));
@@ -1347,6 +1487,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
OnPropertyChanged(nameof(IsAnalysing));
OnPropertyChanged(nameof(IsLocked));
OnPropertyChanged(nameof(IsEditable));
+ OnCropEditableChanged();
OnPropertyChanged(nameof(LockedToolTip));
OnPropertyChanged(nameof(AnalyseToolTip));
OnPropertyChanged(nameof(OptimiseAllToolTip));
@@ -1377,13 +1518,15 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
}
/// A rendered preview as frozen bitmaps and overlays in picture pixels (built off the UI thread).
- private sealed record PreviewResult(ImageSource Corrected, ImageSource Original, Rect Crop, IReadOnlyList Horizon, IReadOnlyList Vectors,
- ImageSource? Waveform)
+ private sealed record PreviewResult(ImageSource Corrected, ImageSource Original, Rect Crop, Rect EditCrop, double LockRatio, IReadOnlyList Horizon,
+ IReadOnlyList Vectors, ImageSource? Waveform)
{
public static PreviewResult From(PreviewFrame frame) => new(
EditorImages.ToBitmap(frame.Corrected),
EditorImages.ToBitmap(frame.Original),
new Rect(frame.Crop.X, frame.Crop.Y, frame.Crop.Width, frame.Crop.Height),
+ new Rect(frame.EditCrop.X, frame.EditCrop.Y, frame.EditCrop.Width, frame.EditCrop.Height),
+ frame.LockRatio,
[.. frame.Horizon.Select(p => new Point(p.X, p.Y))],
[.. frame.Vectors.Select(v => new MotionVector(v.X, v.Y, v.Dx, v.Dy))],
frame.Waveform is { } waveform ? EditorImages.ToMask(waveform) : null);
diff --git a/src/Chronos.App/Editor/FullScreenPreview.xaml b/src/Chronos.App/Editor/FullScreenPreview.xaml
index 545d1316..af0bd2be 100644
--- a/src/Chronos.App/Editor/FullScreenPreview.xaml
+++ b/src/Chronos.App/Editor/FullScreenPreview.xaml
@@ -15,7 +15,8 @@
+ WipeLabel="{Binding WipeLabel}" ZoomMode="Actual" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
+ AutomationProperties.Name="{l:Loc Editor.Preview}">
diff --git a/src/Chronos.App/Editor/PreviewRenderer.cs b/src/Chronos.App/Editor/PreviewRenderer.cs
index 334361f4..2ca2c864 100644
--- a/src/Chronos.App/Editor/PreviewRenderer.cs
+++ b/src/Chronos.App/Editor/PreviewRenderer.cs
@@ -15,7 +15,11 @@ public enum PreviewFraming
/// Through the render geometry (stabilisation, virtual camera, crop): what the video shows.
Output,
- /// The whole frame, exposure-corrected; marks what the output keeps.
+ ///
+ /// The whole view frame (owner review 1, R6: the frame turned, mirrored, flipped and straightened as the camera says;
+ /// the decoded frame itself without them), exposure-corrected, without stabilisation, camera pose or crop;
+ /// marks what the output keeps and the crop box.
+ ///
Source,
}
@@ -36,9 +40,24 @@ public sealed class PreviewFrame(int index, ImageBuffer corrected, ImageBuffer o
public ImageBuffer Original { get; } = original;
- /// The output's part of the picture, normalised (the whole picture in ).
+ ///
+ /// The output's part of the picture on this frame, normalised: the footprint of the frame's output (stabilisation and
+ /// camera pose included) in the view frame; the whole picture in . The Export step's mask.
+ ///
public RectD Crop { get; init; } = new(0, 0, 1, 1);
+ ///
+ /// The crop box the Camera step shows and edits (), normalised in the view
+ /// frame, the same on every frame: in it maps 1:1 onto the picture.
+ ///
+ public RectD EditCrop { get; init; } = new(0, 0, 1, 1);
+
+ /// The crop box's width over its height in normalised units ().
+ public double LockRatio { get; init; } = 1;
+
+ /// The view frame's size at full resolution (): the source's, swapped by an odd turn.
+ public (int Width, int Height) ViewSize { get; init; }
+
/// Sky/land boundary in picture pixels; empty when the analysis found no horizon.
public IReadOnlyList<(double X, double Y)> Horizon { get; init; } = [];
@@ -59,7 +78,9 @@ public sealed class PreviewFrame(int index, ImageBuffer corrected, ImageBuffer o
/// single-frame entry point, so the per-frame steps of RenderRun are followed here: corrections from
/// exactly as a render prepares them, then each frame through the render's exposure
/// stage, its single geometry warp and its finish (look, then highlight knee). Stacking and motion blur need neighbouring frames and are
-/// left to the render.
+/// left to the render. The Source framing of an oriented camera warps the corrected and the original picture once each
+/// into the whole view frame (), so the crop box maps onto it 1:1; without a turn,
+/// mirror, flip or straighten it is the decoded frame itself, at no cost.
///
/// Preparing is split so a slider never decodes the sequence again: a measuring preparation (luminance, colour means,
/// stabilisation; keyed on the settings that change what is measured) runs once, and every other change re-solves
@@ -144,16 +165,20 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
var (geometry, edge) = setup.Value;
var frame = await PictureAsync(request.Index, request, corrections, geometry, edge, cancellationToken).ConfigureAwait(false);
if (frame is null) return null;
- var (corrected, original, plan) = frame.Value;
+ var (corrected, original, footprint, frameSize) = frame.Value;
try
{
var vectors = request.Vectors && request.Index + 1 < content.Count
? await VectorsAsync(request, corrections, corrected.Width, corrected.Height, cancellationToken).ConfigureAwait(false)
: [];
+ var source = request.Framing == PreviewFraming.Source;
return new PreviewFrame(request.Index, corrected, original)
{
- Crop = request.Framing == PreviewFraming.Source ? CropOf(plan, corrected.Width, corrected.Height) : new RectD(0, 0, 1, 1),
- Horizon = request.Framing == PreviewFraming.Source ? HorizonOf(corrected.Width, corrected.Height) : [],
+ Crop = footprint,
+ EditCrop = geometry.EditableCrop,
+ LockRatio = geometry.LockRatio,
+ ViewSize = (geometry.ViewWidth, geometry.ViewHeight),
+ Horizon = source ? HorizonOf(geometry, frameSize.Width, frameSize.Height) : [],
Vectors = vectors,
Waveform = request.Waveform ? LumaWaveform.Measure(corrected) : null,
};
@@ -259,8 +284,11 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
return (geometry, int.Max(16, edge));
}
- /// Decodes, corrects and frames one source frame: (corrected, original, output→picture plan).
- private async Task<(ImageBuffer, ImageBuffer, GeometryPlan?)?> PictureAsync(int index, PreviewRequest request, RenderCorrections? corrections,
+ ///
+ /// Decodes, corrects and frames one source frame: (corrected, original, the output's footprint on the picture
+ /// normalised, the decoded frame's size).
+ ///
+ private async Task<(ImageBuffer, ImageBuffer, RectD, (int Width, int Height))?> PictureAsync(int index, PreviewRequest request, RenderCorrections? corrections,
RenderGeometry geometry, int edge, CancellationToken cancellationToken)
{
var decoded = await source.DecodeAsync(index, edge, DecodePurpose.Proxy, cancellationToken).ConfigureAwait(false);
@@ -271,19 +299,29 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
{
corrected = raw.Clone();
if (corrections is not null && corrections.FrameCount == content.Count) ApplyExposure(corrected, index, corrections);
+ var frame = (raw.Width, raw.Height);
var settings = geometry.For(raw.Width, raw.Height, index, corrections?.StabilizationAt(index, raw.Width, raw.Height) ?? Affine2D.Identity);
- var plan = GeometryStage.Plan(raw.Width, raw.Height, settings);
- if (request.Framing == PreviewFraming.Output)
+ var footprint = new RectD(0, 0, 1, 1);
+ GeometrySettings? warp = settings;
+ if (request.Framing == PreviewFraming.Source)
{
- var framed = GeometryStage.Apply(corrected, settings, cancellationToken);
+ footprint = geometry.FootprintInView(GeometryStage.Plan(raw.Width, raw.Height, settings), raw.Width, raw.Height);
+ // The whole view frame: the same turn, mirror, flip and straighten as the render, without pose or stabilisation.
+ var orientation = geometry.Orientation.Resized(raw.Width, raw.Height);
+ warp = orientation.IsIdentity ? null : geometry.ViewFor(raw.Width, raw.Height, orientation.ViewWidth, orientation.ViewHeight);
+ }
+ if (warp is not null)
+ {
+ var framed = GeometryStage.Apply(corrected, warp, cancellationToken);
corrected.Dispose();
corrected = framed;
- framed = GeometryStage.Apply(raw, settings, cancellationToken);
+ framed = GeometryStage.Apply(raw, warp, cancellationToken);
raw.Dispose();
raw = framed;
}
+ // The look and the knee change the corrected side only: the wipe compares before and after.
FrameFinish.Apply(corrected, request.Project.Look, request.Project.Exposure.HighlightKnee);
- return (corrected, raw, request.Framing == PreviewFraming.Output ? null : plan);
+ return (corrected, raw, footprint, frame);
}
catch
{
@@ -316,12 +354,12 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
var small = request with { LongEdge = int.Min(request.LongEdge, VectorLongEdge), Vectors = false, Waveform = false };
if (Geometry(small, corrections) is not var (geometry, edge)) return [];
var current = await PictureAsync(request.Index, small, corrections, geometry, edge, cancellationToken).ConfigureAwait(false);
- if (current is not var (a, aOriginal, _)) return [];
+ if (current is not var (a, aOriginal, _, _)) return [];
aOriginal.Dispose();
using (a)
{
var next = await PictureAsync(request.Index + 1, small, corrections, geometry, edge, cancellationToken).ConfigureAwait(false);
- if (next is not var (b, bOriginal, _)) return [];
+ if (next is not var (b, bOriginal, _, _)) return [];
bOriginal.Dispose();
using (b)
{
@@ -344,27 +382,26 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
}
}
- /// The output's footprint on the source picture (bounding box of the warped output corners), normalised.
- private static RectD CropOf(GeometryPlan? plan, int width, int height)
- {
- if (plan is not { } p) return new RectD(0, 0, 1, 1);
- double left = double.MaxValue, top = double.MaxValue, right = double.MinValue, bottom = double.MinValue;
- foreach (var (u, v) in new[] { (-0.5, -0.5), (p.OutputWidth - 0.5, -0.5), (-0.5, p.OutputHeight - 0.5), (p.OutputWidth - 0.5, p.OutputHeight - 0.5) })
- {
- var (x, y) = p.OutputToSource.Apply(u, v);
- (left, top, right, bottom) = (double.Min(left, x + 0.5), double.Min(top, y + 0.5), double.Max(right, x + 0.5), double.Max(bottom, y + 0.5));
- }
- left = double.Clamp(left / width, 0, 1);
- top = double.Clamp(top / height, 0, 1);
- return new RectD(left, top, double.Clamp(right / width, 0, 1) - left, double.Clamp(bottom / height, 0, 1) - top);
- }
-
- /// The analysed horizon (normalised rows at evenly spaced columns) in pixels of the whole-frame picture.
- private IReadOnlyList<(double X, double Y)> HorizonOf(int width, int height)
+ ///
+ /// The analysed horizon (normalised rows at evenly spaced columns) in pixels of the Source picture: measured on the
+ /// decoded frame of ×, mapped into the view frame when the camera turns,
+ /// mirrors, flips or straightens it (⁻¹, pixel-centre coordinates).
+ ///
+ private IReadOnlyList<(double X, double Y)> HorizonOf(RenderGeometry geometry, int width, int height)
{
if (content.Deep?.Regions is not { Horizon: { Length: > 1 } rows }) return [];
+ var toView = geometry.Orientation.IsIdentity ? (Affine2D?)null : geometry.ViewToFrame(width, height).Invert();
var points = new (double X, double Y)[rows.Length];
- for (var k = 0; k < rows.Length; k++) points[k] = ((double)k / (rows.Length - 1) * width, rows[k] * height);
+ for (var k = 0; k < rows.Length; k++)
+ {
+ var (x, y) = ((double)k / (rows.Length - 1) * width, rows[k] * height);
+ if (toView is { } map)
+ {
+ var (vx, vy) = map.Apply(x - 0.5, y - 0.5);
+ (x, y) = (vx + 0.5, vy + 0.5);
+ }
+ points[k] = (x, y);
+ }
return points;
}
diff --git a/src/Chronos.App/Sections/SequenceView.xaml b/src/Chronos.App/Sections/SequenceView.xaml
index 2a12b9af..00762e8e 100644
--- a/src/Chronos.App/Sections/SequenceView.xaml
+++ b/src/Chronos.App/Sections/SequenceView.xaml
@@ -5,6 +5,7 @@
xmlns:v="clr-namespace:Chronos.Ui.Visuals;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
+ xmlns:e="clr-namespace:Chronos.App.Editor"
xmlns:sections="clr-namespace:Chronos.App.Sections"
KeyDown="OnKeyDown" Loaded="OnLoaded">
@@ -223,7 +224,9 @@
WipeLabel="{Binding WipeLabel}" ZoomMode="{Binding ZoomMode, Mode=TwoWay}" ShowVectors="{Binding ViewVectors}"
MotionVectors="{Binding MotionVectors}" VectorScale="{Binding VectorScale}" ShowRegions="{Binding ViewRegions}"
RegionBoundary="{Binding RegionBoundary}" ShowCropMask="{Binding ShowCropMask}" CropRect="{Binding CropRect}"
- CropMaskMode="{Binding CropMaskMode}" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
+ CropMaskMode="{Binding CropMaskMode}" CropEditable="{Binding CropEditable}" CropLockRatio="{Binding CropLockRatio}"
+ EditCrop="{Binding EditCrop}" ShowGrid="{Binding ShowStraightenGrid}" e:CropCommit.Command="{Binding CommitCropCommand}"
+ InfoText="{Binding InfoText}" ToolTip="{Binding PreviewToolTip}"
AutomationProperties.Name="{l:Loc Editor.Preview}" SizeChanged="OnPreviewSizeChanged">