<Compile Include="Services\UserSettingService.cs" />\r
<Compile Include="Startup\StartupOptions.cs" />\r
<Compile Include="Utilities\AppcastReader.cs" />\r
+ <Compile Include="Utilities\BitmapHelpers.cs" />\r
<Compile Include="Utilities\BitmapUtilities.cs" />\r
<Compile Include="Utilities\DelayedActionProcessor.cs" />\r
<Compile Include="Utilities\DPIAwareness.cs" />\r
}
}
+ /// <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>
<data name="MetadataView_TitleTag" xml:space="preserve">\r
<value>Title:</value>\r
</data>\r
+ <data name="StaticPreviewView_PreviewRotationFlip" xml:space="preserve">\r
+ <value>Preview Rotation and Flip</value>\r
+ </data>\r
</root>
\ No newline at end of file
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)
public const string AutonameFilePrePostString = "AutonameFilePrePostString";\r
public const string WhenDonePerformActionImmediately = "WhenDonePerformActionImmediately";\r
public const string UseDarkTheme = "UseDarkTheme";\r
+ public const string PreviewRotationFlip = "PreviewRotationFlip";\r
}\r
}
\ No newline at end of file
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <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;
+ }
+ }
+}
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();
/// </summary>\r
bool IsOpen { get; set; }\r
\r
- BitmapImage PreviewImage { get; }\r
+ BitmapSource PreviewImage { get; }\r
\r
void PreviousPreview();\r
void NextPreview();\r
get\r
{\r
if (this.SelectedTask != null &&\r
- (this.selectedTask.Status == QueueItemStatus.Completed || this.selectedTask.Status == QueueItemStatus.Error))\r
+ (this.selectedTask.Status == QueueItemStatus.Completed || this.selectedTask.Status == QueueItemStatus.Error || this.selectedTask.Status == QueueItemStatus.InProgress))\r
{\r
return true;\r
}\r
if (directory != null && Directory.Exists(directory))\r
{\r
Process.Start(directory);\r
-\r
}\r
}\r
}\r
using HandBrakeWPF.Services.Queue.Model;\r
using HandBrakeWPF.Services.Scan.Interfaces;\r
using HandBrakeWPF.Services.Scan.Model;\r
+ using HandBrakeWPF.Utilities;\r
using HandBrakeWPF.ViewModels.Interfaces;\r
\r
using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;\r
/// </summary>\r
public class StaticPreviewViewModel : ViewModelBase, IStaticPreviewViewModel\r
{\r
- /*\r
- * TODO\r
- * - Window Size / Scale to screen etc.\r
- */\r
-\r
- #region Fields\r
-\r
- /// <summary>\r
- /// The scan service.\r
- /// </summary>\r
private readonly IScan scanService;\r
-\r
- /// <summary>\r
- /// Backing field for the encode service.\r
- /// </summary>\r
private readonly IEncode encodeService;\r
-\r
- /// <summary>\r
- /// The error service\r
- /// </summary>\r
private readonly IErrorService errorService;\r
-\r
- /// <summary>\r
- /// The user Setting Service\r
- /// </summary>\r
private readonly IUserSettingService userSettingService;\r
-\r
- /// <summary>\r
- /// The height.\r
- /// </summary>\r
private int height;\r
-\r
- /// <summary>\r
- /// The preview image.\r
- /// </summary>\r
- private BitmapImage previewImage;\r
-\r
- /// <summary>\r
- /// The selected preview image.\r
- /// </summary>\r
+ private BitmapSource previewImage;\r
private int selectedPreviewImage;\r
-\r
- /// <summary>\r
- /// The width.\r
- /// </summary>\r
private int width;\r
-\r
- /// <summary>\r
- /// The preview not available.\r
- /// </summary>\r
private bool previewNotAvailable;\r
-\r
- /// <summary>\r
- /// The percentage.\r
- /// </summary>\r
private string percentage;\r
-\r
- /// <summary>\r
- /// The percentage value.\r
- /// </summary>\r
private double percentageValue;\r
-\r
- /// <summary>\r
- /// The Backing field for IsEncoding\r
- /// </summary>\r
private bool isEncoding;\r
-\r
- /// <summary>\r
- /// Backing field for use system default player\r
- /// </summary>\r
private bool useSystemDefaultPlayer;\r
-\r
- #endregion\r
+ private bool previewRotateFlip;\r
\r
#region Constructors and Destructors\r
\r
\r
this.useSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);\r
this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration);\r
+ this.previewRotateFlip = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreviewRotationFlip);\r
+ this.NotifyOfPropertyChange(() => this.previewRotateFlip); // Don't want to trigger an Update, so setting the backing variable. \r
}\r
\r
#endregion\r
/// <summary>\r
/// Gets or sets the preview image.\r
/// </summary>\r
- public BitmapImage PreviewImage\r
+ public BitmapSource PreviewImage\r
{\r
get\r
{\r
}\r
}\r
\r
+ public bool PreviewRotateFlip\r
+ {\r
+ get => this.previewRotateFlip;\r
+ set\r
+ {\r
+ if (value == this.previewRotateFlip)\r
+ {\r
+ return;\r
+ }\r
+\r
+ this.previewRotateFlip = value;\r
+ this.NotifyOfPropertyChange(() => this.PreviewRotateFlip);\r
+\r
+ this.UpdatePreviewFrame();\r
+ this.userSettingService.SetUserSetting(UserSettingConstants.PreviewRotationFlip, value);\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Gets or sets the task.\r
/// </summary>\r
return;\r
}\r
\r
- BitmapImage image = null;\r
+ BitmapSource image = null;\r
try\r
{\r
image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage, HBConfigurationFactory.Create());\r
\r
if (image != null)\r
{\r
+ if (previewRotateFlip)\r
+ {\r
+ image = BitmapHelpers.CreateTransformedBitmap(image, this.Task.Rotation, this.Task.FlipVideo);\r
+ }\r
+\r
PreviewNotAvailable = false;\r
this.Width = (int)Math.Ceiling(image.Width);\r
this.Height = (int)Math.Ceiling(image.Height);\r
using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;
+ using System.Windows.Media;
using System.Windows.Media.Imaging;
using HandBrake.Interop.Interop;
#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; }
return;
}
- BitmapImage image = null;
+ BitmapSource image = null;
try
{
image = this.scanService.GetPreview(this.Task, this.selectedPreview - 1, HBConfigurationFactory.Create());
if (image != null)
{
+ image = BitmapHelpers.CreateTransformedBitmap(image, this.task.Rotation, this.task.FlipVideo);
+
this.PreviewNotAvailable = false;
this.PreviewImage = image;
this.MaxWidth = (int)image.Width;
<RowDefinition Height="Auto" />\r
<RowDefinition Height="Auto" />\r
<RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
</Grid.RowDefinitions>\r
+\r
<Slider Maximum="{Binding TotalPreviews}" Minimum="0" AutomationProperties.Name="{x:Static Properties:Resources.StaticPreviewView_SelectPreviewImage}"\r
Value="{Binding SelectedPreviewImage}"\r
VerticalAlignment="Center"\r
HorizontalAlignment="Stretch"\r
- Background="Transparent" TickPlacement="TopLeft"\r
- Margin="0,0,0,5"\r
- />\r
+ Background="Transparent" TickPlacement="TopLeft" Margin="0,0,0,5" />\r
+\r
+ <CheckBox IsChecked="{Binding PreviewRotateFlip}" Content="{x:Static Properties:Resources.StaticPreviewView_PreviewRotationFlip}" Foreground="White" Grid.Row="1" Margin="0,0,0,10" />\r
\r
- <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Left">\r
+ <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Left">\r
<Button Content="{x:Static Properties:Resources.StaticPreviewView_LivePreview}" Padding="8,2" cal:Message.Attach="[Event Click] = [Action Play]" />\r
<TextBlock Margin="10,0,5,0" VerticalAlignment="Center" Foreground="White" Text="{x:Static Properties:Resources.StaticPreviewView_Duration}" />\r
<ComboBox Width="60"\r
<CheckBox VerticalAlignment="Center" Content="{x:Static Properties:Resources.StaticPreviewView_UseSystemDefault}" Foreground="White" Margin="10,0,0,0" IsChecked="{Binding UseSystemDefaultPlayer}" />\r
</StackPanel>\r
\r
- <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,5,0,0">\r
-\r
- </StackPanel>\r
-\r
- <Grid Margin="0,10,10,0" Grid.Row="2" Visibility="{Binding IsEncoding, Converter={StaticResource booleanToVisibilityConverter}}">\r
+ <Grid Margin="0,10,10,0" Grid.Row="3" Visibility="{Binding IsEncoding, Converter={StaticResource booleanToVisibilityConverter}}">\r
<Grid.ColumnDefinitions>\r
<ColumnDefinition Width="23*" />\r
<ColumnDefinition Width="289*"/>\r
\r
private void UpdateWindowTitle()\r
{\r
- BitmapImage image = ((IStaticPreviewViewModel)this.DataContext).PreviewImage;\r
+ BitmapSource image = ((IStaticPreviewViewModel)this.DataContext).PreviewImage;\r
if (image != null && this.previewImage != null && this.previewImage.ActualWidth > 0)\r
{\r
double origWidth = Math.Round(image.Width, 0);\r
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
</value>\r
</item>\r
+ <item>\r
+ <key>\r
+ <string>PreviewRotationFlip</string>\r
+ </key>\r
+ <value>\r
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
+ </value>\r
+ </item>\r
</dictionary>
\ No newline at end of file