From e9cbd4a18b6c56c608119e0c9d77c8266479a184 Mon Sep 17 00:00:00 2001 From: randomengy Date: Fri, 11 Apr 2014 06:54:33 +0000 Subject: Interop: Support for rotation and reflection. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6161 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeInterop/HandBrakeInstance.cs | 43 ++++++++++++++++++++++ .../HandBrakeInterop/HandBrakeInterop.csproj | 1 + .../Model/Encoding/EncodingProfile.cs | 20 +++++++++- .../Model/Encoding/PictureRotation.cs | 19 ++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs (limited to 'win') diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index e97343852..bfd0c44de 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -16,6 +16,7 @@ namespace HandBrake.Interop using System.Linq; using System.Runtime.InteropServices; using System.Text; + using System.Windows.Media; using System.Windows.Media.Imaging; using HandBrake.Interop.EventArgs; @@ -1502,6 +1503,48 @@ namespace HandBrake.Interop } } + // Rotate + if (profile.FlipHorizontal || profile.FlipVertical || profile.Rotation != PictureRotation.None) + { + bool rotate90 = false; + bool flipHorizontal = profile.FlipHorizontal; + bool flipVertical = profile.FlipVertical; + + switch (profile.Rotation) + { + case PictureRotation.Clockwise90: + rotate90 = true; + break; + case PictureRotation.Clockwise180: + flipHorizontal = !flipHorizontal; + flipVertical = !flipVertical; + break; + case PictureRotation.Clockwise270: + rotate90 = true; + flipHorizontal = !flipHorizontal; + flipVertical = !flipVertical; + break; + } + + int rotateSetting = 0; + if (flipVertical) + { + rotateSetting |= 1; + } + + if (flipHorizontal) + { + rotateSetting |= 2; + } + + if (rotate90) + { + rotateSetting |= 4; + } + + this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_ROTATE, rotateSetting.ToString(CultureInfo.InvariantCulture), allocatedMemory); + } + // Construct final filter list nativeJob.list_filter = this.ConvertFilterListToNative(filterList, allocatedMemory).Ptr; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index bb4bd48cf..d86da1833 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -151,6 +151,7 @@ + diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs index 257c324d7..2dea5624b 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/EncodingProfile.cs @@ -130,6 +130,21 @@ namespace HandBrake.Interop.Model.Encoding /// Gets or sets the modulus. /// public int Modulus { get; set; } + + /// + /// Gets or sets the rotation. + /// + public PictureRotation Rotation { get; set; } + + /// + /// Gets or sets a value indicating whether the picture should be flipped horizontally. + /// + public bool FlipHorizontal { get; set; } + + /// + /// Gets or sets a value indicating whether the picture should be flipped vertically. + /// + public bool FlipVertical { get; set; } #endregion #region Filters @@ -180,7 +195,7 @@ namespace HandBrake.Interop.Model.Encoding public int Deblock { get; set; } /// - /// Gets or sets a value indicating whether grayscale. + /// Gets or sets a value indicating whether the grayscale filter will be applied. /// public bool Grayscale { get; set; } #endregion @@ -307,6 +322,9 @@ namespace HandBrake.Interop.Model.Encoding PixelAspectX = this.PixelAspectX, PixelAspectY = this.PixelAspectY, Modulus = this.Modulus, + Rotation = this.Rotation, + FlipHorizontal = this.FlipHorizontal, + FlipVertical = this.FlipVertical, Deinterlace = this.Deinterlace, CustomDeinterlace = this.CustomDeinterlace, diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs new file mode 100644 index 000000000..0476b1673 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/PictureRotation.cs @@ -0,0 +1,19 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Model.Encoding +{ + /// + /// Possible picture rotations. + /// + public enum PictureRotation + { + None = 0, + Clockwise90, + Clockwise180, + Clockwise270 + } +} -- cgit v1.2.3