diff options
author | sr55 <[email protected]> | 2009-07-30 16:10:24 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-07-30 16:10:24 +0000 |
commit | c128a2446a8822918dcff743647a4645fe8c24a6 (patch) | |
tree | 4719cde309c89dc4164fb6eda956fbcc485bf850 /win/C#/Controls/PictureSettings.cs | |
parent | 513cec67cd834a9220c3ef514429fae1e8023600 (diff) |
WinGui:
- Picture Settings Custom Anamorphic feature, Keep AR mode completed.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2738 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Controls/PictureSettings.cs')
-rw-r--r-- | win/C#/Controls/PictureSettings.cs | 73 |
1 files changed, 52 insertions, 21 deletions
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index 84d397237..8352f52af 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -7,27 +7,6 @@ using Handbrake.Parsing; namespace Handbrake.Controls
{
-
- // TODO Custom Anamorphic
- /* NOT KEEPING DISPLAY ASPECT == [Complete]
-
- KEEPING DISPLAY ASPECT RATIO == [TODO]
- DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
- Disable editing: PIXEL WIDTH, PIXEL HEIGHT
- Changing DISPLAY WIDTH:
- Changes HEIGHT to keep DAR
- Changes PIXEL WIDTH to new DISPLAY WIDTH
- Changes PIXEL HEIGHT to STORAGE WIDTH
- Changing HEIGHT
- Changes DISPLAY WIDTH to keep DAR
- Changes PIXEL WIDTH to new DISPLAY WIDTH
- Changes PIXEL HEIGHT to STORAGE WIDTH
- Changing STORAGE_WIDTH:
- Changes PIXEL WIDTH to DISPLAY WIDTH
- Changes PIXEL HEIGHT to new STORAGE WIDTH
- * */
-
-
public partial class PictureSettings : UserControl
{
private readonly CultureInfo Culture = new CultureInfo("en-US", false);
@@ -35,6 +14,7 @@ namespace Handbrake.Controls private Boolean preventChangingWidth, preventChangingHeight, preventChangingCustom, preventChangingDisplayWidth;
private int _PresetMaximumWidth, _PresetMaximumHeight;
+ private double cachedDar;
private Title _SourceTitle;
public PictureSettings()
@@ -86,6 +66,7 @@ namespace Handbrake.Controls updownDisplayWidth.Value = calculateAnamorphicSizes().Width;
updownParWidth.Value = _SourceTitle.ParVal.Width;
updownParHeight.Value = _SourceTitle.ParVal.Height;
+ cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;
}
}
@@ -155,6 +136,12 @@ namespace Handbrake.Controls labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;
}
+
+ if (check_KeepAR.CheckState == CheckState.Checked && Source != null)
+ {
+ updownParWidth.Value = updownDisplayWidth.Value;
+ updownParHeight.Value = text_width.Value;
+ }
break;
default:
labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;
@@ -192,6 +179,27 @@ namespace Handbrake.Controls break;
case 3:
labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;
+
+ if (check_KeepAR.CheckState == CheckState.Checked && Source != null)
+ {
+ // - Changes DISPLAY WIDTH to keep DAR
+ // - Changes PIXEL WIDTH to new DISPLAY WIDTH
+ // - Changes PIXEL HEIGHT to STORAGE WIDTH
+ // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
+
+ double rawCalculatedDisplayWidth = (double)text_height.Value * cachedDar;
+
+ preventChangingDisplayWidth = true; // Start Guards
+ preventChangingWidth = true;
+
+ updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;
+ updownParWidth.Value = updownDisplayWidth.Value;
+ updownParHeight.Value = text_width.Value;
+
+ preventChangingWidth = false; // Reset Guards
+ preventChangingDisplayWidth = false;
+ }
+
break;
default:
labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;
@@ -226,6 +234,29 @@ namespace Handbrake.Controls updownParHeight.Value = text_width.Value;
preventChangingCustom = false;
}
+
+ if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked)
+ {
+ // - Changes HEIGHT to keep DAR
+ // - Changes PIXEL WIDTH to new DISPLAY WIDTH
+ // - Changes PIXEL HEIGHT to STORAGE WIDTH
+ // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
+
+ // Calculate new Height Value
+ int modulus = 16;
+ int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus);
+
+ int rawCalculatedHeight = (int) ((int)updownDisplayWidth.Value/cachedDar);
+ int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);
+
+ // Update value
+ preventChangingHeight = true;
+ text_height.Value = (decimal)modulusHeight;
+ updownParWidth.Value = updownDisplayWidth.Value;
+ updownParHeight.Value = text_width.Value;
+ preventChangingHeight = false;
+ }
+
}
// Anamorphic Controls
|