summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj1
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.Designer.cs9
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.resx3
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/LibScan.cs2
-rw-r--r--win/CS/HandBrakeWPF/UserSettingConstants.cs1
-rw-r--r--win/CS/HandBrakeWPF/Utilities/BitmapHelpers.cs39
-rw-r--r--win/CS/HandBrakeWPF/Utilities/SystemInfo.cs1
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs3
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs93
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs7
-rw-r--r--win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml16
-rw-r--r--win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs2
-rw-r--r--win/CS/HandBrakeWPF/defaultsettings.xml8
14 files changed, 108 insertions, 79 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index 56f0fc2dc..fbb3669ca 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -259,6 +259,7 @@
<Compile Include="Services\UserSettingService.cs" />
<Compile Include="Startup\StartupOptions.cs" />
<Compile Include="Utilities\AppcastReader.cs" />
+ <Compile Include="Utilities\BitmapHelpers.cs" />
<Compile Include="Utilities\BitmapUtilities.cs" />
<Compile Include="Utilities\DelayedActionProcessor.cs" />
<Compile Include="Utilities\DPIAwareness.cs" />
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
index 11cf168a3..915eb3eb4 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
@@ -4840,6 +4840,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Preview Rotation and Flip.
+ /// </summary>
+ public static string StaticPreviewView_PreviewRotationFlip {
+ get {
+ return ResourceManager.GetString("StaticPreviewView_PreviewRotationFlip", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Select a preview image.
/// </summary>
public static string StaticPreviewView_SelectPreviewImage {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx
index 2d0e235bf..437efe84c 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.resx
+++ b/win/CS/HandBrakeWPF/Properties/Resources.resx
@@ -2045,4 +2045,7 @@ Where supported, any user presets will have been imported.</value>
<data name="MetadataView_TitleTag" xml:space="preserve">
<value>Title:</value>
</data>
+ <data name="StaticPreviewView_PreviewRotationFlip" xml:space="preserve">
+ <value>Preview Rotation and Flip</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
index d545ee2ed..e69f9aee4 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
@@ -217,7 +217,7 @@ namespace HandBrakeWPF.Services.Scan
PixelAspectY = job.PixelAspectY
};
- var bitmapData = this.instance.GetPreview(settings, preview, job.DeinterlaceFilter != DeinterlaceFilter.Off);
+ RawPreviewData bitmapData = this.instance.GetPreview(settings, preview, job.DeinterlaceFilter != DeinterlaceFilter.Off);
bitmapImage = BitmapUtilities.ConvertToBitmapImage(BitmapUtilities.ConvertByteArrayToBitmap(bitmapData));
}
catch (AccessViolationException e)
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs
index c591443b5..92832a124 100644
--- a/win/CS/HandBrakeWPF/UserSettingConstants.cs
+++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs
@@ -73,5 +73,6 @@ namespace HandBrakeWPF
public const string AutonameFilePrePostString = "AutonameFilePrePostString";
public const string WhenDonePerformActionImmediately = "WhenDonePerformActionImmediately";
public const string UseDarkTheme = "UseDarkTheme";
+ public const string PreviewRotationFlip = "PreviewRotationFlip";
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Utilities/BitmapHelpers.cs b/win/CS/HandBrakeWPF/Utilities/BitmapHelpers.cs
new file mode 100644
index 000000000..f9856d2aa
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Utilities/BitmapHelpers.cs
@@ -0,0 +1,39 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DelayedActionProcessor.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An Action processor that supports queueing/delayed action processing.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System.Windows.Media;
+ using System.Windows.Media.Imaging;
+
+ public class BitmapHelpers
+ {
+ public static BitmapSource CreateTransformedBitmap(BitmapSource source, int rotation, bool flip)
+ {
+ if ((rotation == 0) && !flip)
+ {
+ return source;
+ }
+
+ TransformedBitmap transformedBitmap = new TransformedBitmap();
+ transformedBitmap.BeginInit();
+ transformedBitmap.Source = source;
+
+ var transformGroup = new TransformGroup();
+ transformGroup.Children.Add(new ScaleTransform(1, flip ? -1 : 1));
+ transformGroup.Children.Add(new RotateTransform(rotation));
+
+ transformedBitmap.Transform = transformGroup;
+ transformedBitmap.EndInit();
+ transformedBitmap.Freeze();
+
+ return (BitmapSource)transformedBitmap;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Utilities/SystemInfo.cs b/win/CS/HandBrakeWPF/Utilities/SystemInfo.cs
index ca32b7af4..be7c1827b 100644
--- a/win/CS/HandBrakeWPF/Utilities/SystemInfo.cs
+++ b/win/CS/HandBrakeWPF/Utilities/SystemInfo.cs
@@ -82,6 +82,7 @@ namespace HandBrakeWPF.Utilities
foreach (PropertyData pc in share.Properties)
{
+ Console.WriteLine(pc.Name + ": " + pc.Value);
if (!string.IsNullOrEmpty(pc.Name) && pc.Value != null)
{
if (pc.Name.Equals("DriverVersion")) version = pc.Value.ToString();
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs
index 0c1884bb1..9605537c9 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs
@@ -36,7 +36,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
/// </summary>
bool IsOpen { get; set; }
- BitmapImage PreviewImage { get; }
+ BitmapSource PreviewImage { get; }
void PreviousPreview();
void NextPreview();
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index 0cb68435e..5114949c4 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -253,7 +253,7 @@ namespace HandBrakeWPF.ViewModels
get
{
if (this.SelectedTask != null &&
- (this.selectedTask.Status == QueueItemStatus.Completed || this.selectedTask.Status == QueueItemStatus.Error))
+ (this.selectedTask.Status == QueueItemStatus.Completed || this.selectedTask.Status == QueueItemStatus.Error || this.selectedTask.Status == QueueItemStatus.InProgress))
{
return true;
}
@@ -726,7 +726,6 @@ namespace HandBrakeWPF.ViewModels
if (directory != null && Directory.Exists(directory))
{
Process.Start(directory);
-
}
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index 72a36aa9a..8608ea259 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -30,6 +30,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrakeWPF.Services.Queue.Model;
using HandBrakeWPF.Services.Scan.Interfaces;
using HandBrakeWPF.Services.Scan.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;
@@ -45,79 +46,20 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public class StaticPreviewViewModel : ViewModelBase, IStaticPreviewViewModel
{
- /*
- * TODO
- * - Window Size / Scale to screen etc.
- */
-
- #region Fields
-
- /// <summary>
- /// The scan service.
- /// </summary>
private readonly IScan scanService;
-
- /// <summary>
- /// Backing field for the encode service.
- /// </summary>
private readonly IEncode encodeService;
-
- /// <summary>
- /// The error service
- /// </summary>
private readonly IErrorService errorService;
-
- /// <summary>
- /// The user Setting Service
- /// </summary>
private readonly IUserSettingService userSettingService;
-
- /// <summary>
- /// The height.
- /// </summary>
private int height;
-
- /// <summary>
- /// The preview image.
- /// </summary>
- private BitmapImage previewImage;
-
- /// <summary>
- /// The selected preview image.
- /// </summary>
+ private BitmapSource previewImage;
private int selectedPreviewImage;
-
- /// <summary>
- /// The width.
- /// </summary>
private int width;
-
- /// <summary>
- /// The preview not available.
- /// </summary>
private bool previewNotAvailable;
-
- /// <summary>
- /// The percentage.
- /// </summary>
private string percentage;
-
- /// <summary>
- /// The percentage value.
- /// </summary>
private double percentageValue;
-
- /// <summary>
- /// The Backing field for IsEncoding
- /// </summary>
private bool isEncoding;
-
- /// <summary>
- /// Backing field for use system default player
- /// </summary>
private bool useSystemDefaultPlayer;
-
- #endregion
+ private bool previewRotateFlip;
#region Constructors and Destructors
@@ -141,6 +83,8 @@ namespace HandBrakeWPF.ViewModels
this.useSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);
this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration);
+ this.previewRotateFlip = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreviewRotationFlip);
+ this.NotifyOfPropertyChange(() => this.previewRotateFlip); // Don't want to trigger an Update, so setting the backing variable.
}
#endregion
@@ -170,7 +114,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Gets or sets the preview image.
/// </summary>
- public BitmapImage PreviewImage
+ public BitmapSource PreviewImage
{
get
{
@@ -210,6 +154,24 @@ namespace HandBrakeWPF.ViewModels
}
}
+ public bool PreviewRotateFlip
+ {
+ get => this.previewRotateFlip;
+ set
+ {
+ if (value == this.previewRotateFlip)
+ {
+ return;
+ }
+
+ this.previewRotateFlip = value;
+ this.NotifyOfPropertyChange(() => this.PreviewRotateFlip);
+
+ this.UpdatePreviewFrame();
+ this.userSettingService.SetUserSetting(UserSettingConstants.PreviewRotationFlip, value);
+ }
+ }
+
/// <summary>
/// Gets or sets the task.
/// </summary>
@@ -455,7 +417,7 @@ namespace HandBrakeWPF.ViewModels
return;
}
- BitmapImage image = null;
+ BitmapSource image = null;
try
{
image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage, HBConfigurationFactory.Create());
@@ -468,6 +430,11 @@ namespace HandBrakeWPF.ViewModels
if (image != null)
{
+ if (previewRotateFlip)
+ {
+ image = BitmapHelpers.CreateTransformedBitmap(image, this.Task.Rotation, this.Task.FlipVideo);
+ }
+
PreviewNotAvailable = false;
this.Width = (int)Math.Ceiling(image.Width);
this.Height = (int)Math.Ceiling(image.Height);
diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
index 771fbec6e..aaf477e1b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
@@ -15,6 +15,7 @@ namespace HandBrakeWPF.ViewModels
using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;
+ using System.Windows.Media;
using System.Windows.Media.Imaging;
using HandBrake.Interop.Interop;
@@ -131,7 +132,7 @@ namespace HandBrakeWPF.ViewModels
#region DisplayProperties
- public BitmapImage PreviewImage { get; set; }
+ public BitmapSource PreviewImage { get; set; }
public bool PreviewNotAvailable { get; set; }
public int MaxWidth { get; set; }
public int MaxHeight { get; set; }
@@ -668,7 +669,7 @@ namespace HandBrakeWPF.ViewModels
return;
}
- BitmapImage image = null;
+ BitmapSource image = null;
try
{
image = this.scanService.GetPreview(this.Task, this.selectedPreview - 1, HBConfigurationFactory.Create());
@@ -681,6 +682,8 @@ namespace HandBrakeWPF.ViewModels
if (image != null)
{
+ image = BitmapHelpers.CreateTransformedBitmap(image, this.task.Rotation, this.task.FlipVideo);
+
this.PreviewNotAvailable = false;
this.PreviewImage = image;
this.MaxWidth = (int)image.Width;
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml
index 6f1b54694..db622c247 100644
--- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml
+++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml
@@ -31,16 +31,18 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
+
<Slider Maximum="{Binding TotalPreviews}" Minimum="0" AutomationProperties.Name="{x:Static Properties:Resources.StaticPreviewView_SelectPreviewImage}"
Value="{Binding SelectedPreviewImage}"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
- Background="Transparent" TickPlacement="TopLeft"
- Margin="0,0,0,5"
- />
+ Background="Transparent" TickPlacement="TopLeft" Margin="0,0,0,5" />
+
+ <CheckBox IsChecked="{Binding PreviewRotateFlip}" Content="{x:Static Properties:Resources.StaticPreviewView_PreviewRotationFlip}" Foreground="White" Grid.Row="1" Margin="0,0,0,10" />
- <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Left">
+ <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Left">
<Button Content="{x:Static Properties:Resources.StaticPreviewView_LivePreview}" Padding="8,2" cal:Message.Attach="[Event Click] = [Action Play]" />
<TextBlock Margin="10,0,5,0" VerticalAlignment="Center" Foreground="White" Text="{x:Static Properties:Resources.StaticPreviewView_Duration}" />
<ComboBox Width="60"
@@ -50,11 +52,7 @@
<CheckBox VerticalAlignment="Center" Content="{x:Static Properties:Resources.StaticPreviewView_UseSystemDefault}" Foreground="White" Margin="10,0,0,0" IsChecked="{Binding UseSystemDefaultPlayer}" />
</StackPanel>
- <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,5,0,0">
-
- </StackPanel>
-
- <Grid Margin="0,10,10,0" Grid.Row="2" Visibility="{Binding IsEncoding, Converter={StaticResource booleanToVisibilityConverter}}">
+ <Grid Margin="0,10,10,0" Grid.Row="3" Visibility="{Binding IsEncoding, Converter={StaticResource booleanToVisibilityConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="23*" />
<ColumnDefinition Width="289*"/>
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs
index 2289cfe45..2a36e71af 100644
--- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs
+++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs
@@ -64,7 +64,7 @@ namespace HandBrakeWPF.Views
private void UpdateWindowTitle()
{
- BitmapImage image = ((IStaticPreviewViewModel)this.DataContext).PreviewImage;
+ BitmapSource image = ((IStaticPreviewViewModel)this.DataContext).PreviewImage;
if (image != null && this.previewImage != null && this.previewImage.ActualWidth > 0)
{
double origWidth = Math.Round(image.Width, 0);
diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml
index 04ce09cd5..1efd1113a 100644
--- a/win/CS/HandBrakeWPF/defaultsettings.xml
+++ b/win/CS/HandBrakeWPF/defaultsettings.xml
@@ -561,4 +561,12 @@
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
</value>
</item>
+ <item>
+ <key>
+ <string>PreviewRotationFlip</string>
+ </key>
+ <value>
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
+ </value>
+ </item>
</dictionary> \ No newline at end of file