2 using System.Drawing;
\r
3 using System.Windows.Forms;
\r
4 using Handbrake.Parsing;
\r
6 namespace Handbrake.Controls
\r
9 * ***** WARNING *****
\r
10 * This file is incomplete.
\r
11 * - Custom Anamorphic mode does not work.
\r
12 * - Several Out of bound exceptions on the numeric up down width/height inputs need fixed.
\r
13 * - Code needs cleaned up and a ton of bugs probably need fixed.
\r
17 * DISPLAY WIDTH STORAGE WIDTH PIXEL WIDTH
\r
18 * HEIGHT KEEP ASPECT PIXEL HEIGHT
\r
20 * --- NOT KEEPING DISPLAY ASPECT ---
\r
21 * Changing STORAGE WIDTH changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
22 * Changing PIXEL dimensions changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
23 * Changing DISPLAY WIDTH changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH
\r
24 * Changing HEIGHT just....changes the height.
\r
26 * --- KEEPING DISPLAY ASPECT RATIO ---
\r
27 * DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
28 * Disable editing: PIXEL WIDTH, PIXEL HEIGHT
\r
29 * Changing DISPLAY WIDTH:
\r
30 * Changes HEIGHT to keep DAR
\r
31 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
32 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
34 * Changes DISPLAY WIDTH to keep DAR
\r
35 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
36 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
37 * Changing STORAGE_WIDTH:
\r
38 * Changes PIXEL WIDTH to DISPLAY WIDTH
\r
39 * Changes PIXEL HEIGHT to new STORAGE WIDTH
\r
42 public partial class PictureSettings : UserControl
\r
45 int maxWidth, maxHeight;
\r
46 int widthVal, heightVal;
\r
47 private double darValue;
\r
48 private double storageAspect = 0; // Storage Aspect Cache for current source and title
\r
49 public Title selectedTitle { get; set; }
\r
50 private Boolean heightChangeGuard;
\r
51 private Boolean looseAnamorphicHeightGuard;
\r
52 private Boolean heightModJumpGaurd = false;
\r
55 public PictureSettings()
\r
57 InitializeComponent();
\r
59 drop_modulus.SelectedIndex = 0;
\r
62 public void setComponentsAfterScan(Title st)
\r
66 // Set the Aspect Ratio
\r
67 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
68 lbl_src_res.Text = selectedTitle.Resolution.Width + " x " + selectedTitle.Resolution.Height;
\r
70 // Set the Recommended Cropping values
\r
71 crop_top.Text = selectedTitle.AutoCropDimensions[0].ToString();
\r
72 crop_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();
\r
73 crop_left.Text = selectedTitle.AutoCropDimensions[2].ToString();
\r
74 crop_right.Text = selectedTitle.AutoCropDimensions[3].ToString();
\r
77 // Set the Resolution Boxes
\r
78 text_width.Value = selectedTitle.Resolution.Width;
\r
79 text_height.Value = cacluateHeight(selectedTitle.Resolution.Width);
\r
81 if (drp_anamorphic.SelectedIndex == 3)
\r
83 txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
\r
84 txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
\r
85 txt_displayWidth.Text = displayWidth().ToString();
\r
88 public void setMax()
\r
90 if (maxWidth != 0 && maxHeight != 0)
\r
91 lbl_max.Text = "Max Width / Height";
\r
92 else if (maxWidth != 0)
\r
93 lbl_max.Text = "Max Width";
\r
98 // Basic Picture Setting Controls
\r
99 private void text_width_ValueChanged(object sender, EventArgs e)
\r
103 int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
\r
105 // Increase or decrease value by the correct mod.
\r
106 text_width.Value = widthChangeMod(mod);
\r
109 switch (drp_anamorphic.SelectedIndex)
\r
112 if (calculateUnchangeValue(true) != -1)
\r
113 text_height.Value = calculateUnchangeValue(true);
\r
116 lbl_anamorphic.Text = strictAnamorphic();
\r
119 lbl_anamorphic.Text = looseAnamorphic();
\r
122 customAnamorphic(text_width);
\r
127 private void text_height_ValueChanged(object sender, EventArgs e)
\r
131 int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
\r
133 // Increase or decrease value by the correct mod.
\r
134 if (drp_anamorphic.SelectedIndex != 2 && !heightModJumpGaurd)
\r
136 decimal val = heightChangeMod(mod);
\r
137 heightChangeGuard = true;
\r
138 if (text_height.Value != val)
\r
140 heightChangeGuard = false;
\r
141 text_height.Value = val;
\r
146 switch (drp_anamorphic.SelectedIndex)
\r
149 if (drp_anamorphic.SelectedIndex != 3)
\r
151 if (calculateUnchangeValue(false) != -1)
\r
152 text_width.Value = calculateUnchangeValue(false);
\r
156 lbl_anamorphic.Text = strictAnamorphic();
\r
159 if (!looseAnamorphicHeightGuard)
\r
160 lbl_anamorphic.Text = looseAnamorphic();
\r
163 if (!heightChangeGuard)
\r
164 customAnamorphic(text_height);
\r
167 heightChangeGuard = false;
\r
168 looseAnamorphicHeightGuard = false;
\r
169 heightModJumpGaurd = false;
\r
171 private void check_KeepAR_CheckedChanged(object sender, EventArgs e)
\r
173 // Recalculate Height based on width when enabled
\r
174 if (drp_anamorphic.SelectedIndex != 3 && check_KeepAR.Checked && selectedTitle != null)
\r
175 text_height.Value = cacluateHeight(widthVal);
\r
177 // Enable Par Width/Height Check boxes if Keep AR is enabled, otherwise disable them
\r
178 if (check_KeepAR.Checked)
\r
180 txt_parWidth.Enabled = false;
\r
181 txt_parHeight.Enabled = false;
\r
185 txt_parWidth.Enabled = true;
\r
186 txt_parHeight.Enabled = true;
\r
189 private void drp_anamorphic_SelectedIndexChanged(object sender, EventArgs e)
\r
191 switch (drp_anamorphic.SelectedIndex)
\r
194 text_height.BackColor = Color.White;
\r
195 text_width.BackColor = Color.White;
\r
196 text_height.Enabled = true;
\r
197 text_width.Enabled = true;
\r
198 check_KeepAR.CheckState = CheckState.Checked;
\r
199 check_KeepAR.Enabled = true;
\r
200 disableCustomAnaControls();
\r
201 text_width.Text = widthVal.ToString();
\r
202 text_height.Text = heightVal.ToString();
\r
203 check_KeepAR.Enabled = true;
\r
204 lbl_anamorphic.Text = "";
\r
205 lbl_anamprohicLbl.Visible = false;
\r
208 text_height.BackColor = Color.LightGray;
\r
209 text_width.BackColor = Color.LightGray;
\r
210 if (selectedTitle != null)
\r
212 heightModJumpGaurd = true;
\r
213 text_width.Value = selectedTitle.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
\r
214 text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
216 text_height.Enabled = false;
\r
217 text_width.Enabled = false;
\r
218 check_KeepAR.CheckState = CheckState.Unchecked;
\r
219 check_KeepAR.Enabled = false;
\r
220 disableCustomAnaControls();
\r
221 lbl_anamorphic.Text = strictAnamorphic();
\r
222 lbl_anamprohicLbl.Visible = true;
\r
225 disableCustomAnaControls();
\r
227 text_height.Enabled = false;
\r
228 text_height.BackColor = Color.LightGray;
\r
229 text_width.Enabled = true;
\r
230 text_width.BackColor = Color.White;
\r
231 if (selectedTitle != null)
\r
233 heightModJumpGaurd = true;
\r
234 text_width.Value = selectedTitle.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;
\r
235 text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
\r
237 lbl_anamorphic.Text = looseAnamorphic();
\r
238 lbl_anamprohicLbl.Visible = true;
\r
242 // Display Elements
\r
243 enableCustomAnaControls();
\r
244 text_height.BackColor = Color.White;
\r
245 text_width.BackColor = Color.White;
\r
246 text_height.Enabled = true;
\r
247 text_width.Enabled = true;
\r
250 if (selectedTitle != null)
\r
252 heightModJumpGaurd = true;
\r
253 widthVal = selectedTitle.Resolution.Width;
\r
254 text_width.Value = selectedTitle.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
\r
255 text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
256 txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
\r
257 txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
\r
258 txt_displayWidth.Text = displayWidth().ToString();
\r
261 darValue = calculateDar();
\r
263 check_KeepAR.CheckState = CheckState.Checked;
\r
264 check_KeepAR.Enabled = true;
\r
265 lbl_anamprohicLbl.Visible = true;
\r
271 // Custom Anamorphic Controls
\r
272 private void txt_displayWidth_Keyup(object sender, KeyEventArgs e)
\r
274 if (e.KeyCode == Keys.Enter)
\r
275 customAnamorphic(txt_displayWidth);
\r
277 private void txt_parHeight_Keyup(object sender, KeyEventArgs e)
\r
279 if (e.KeyCode == Keys.Enter)
\r
280 customAnamorphic(txt_parHeight);
\r
282 private void txt_parWidth_Keyup(object sender, KeyEventArgs e)
\r
284 if (e.KeyCode == Keys.Enter)
\r
285 customAnamorphic(txt_parWidth);
\r
288 // Cropping Control
\r
289 private void check_autoCrop_CheckedChanged(object sender, EventArgs e)
\r
291 crop_left.Enabled = false;
\r
292 crop_right.Enabled = false;
\r
293 crop_top.Enabled = false;
\r
294 crop_bottom.Enabled = false;
\r
296 private void check_customCrop_CheckedChanged(object sender, EventArgs e)
\r
298 crop_left.Enabled = true;
\r
299 crop_right.Enabled = true;
\r
300 crop_top.Enabled = true;
\r
301 crop_bottom.Enabled = true;
\r
302 if (selectedTitle != null)
\r
304 crop_top.Text = selectedTitle.AutoCropDimensions[0].ToString();
\r
305 crop_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();
\r
306 crop_left.Text = selectedTitle.AutoCropDimensions[2].ToString();
\r
307 crop_right.Text = selectedTitle.AutoCropDimensions[3].ToString();
\r
311 crop_left.Text = "0";
\r
312 crop_right.Text = "0";
\r
313 crop_top.Text = "0";
\r
314 crop_bottom.Text = "0";
\r
318 // Custom Anamorphic Code
\r
319 private void customAnamorphic(Control control)
\r
321 // Get and parse all the required values
\r
322 int cropLeft = (int)crop_left.Value;
\r
323 int cropRight = (int)crop_right.Value;
\r
325 int width = (int)text_width.Value;
\r
326 int cropped_width = width - cropLeft - cropRight;
\r
329 int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
\r
332 double displayWidth;
\r
333 int.TryParse(txt_parWidth.Text, out parW);
\r
334 int.TryParse(txt_parHeight.Text, out parH);
\r
335 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
337 /* NOT KEEPING DISPLAY ASPECT
\r
338 * Changing STORAGE WIDTH changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
339 * Changing PIXEL dimensions changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
340 * Changing DISPLAY WIDTH changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH
\r
341 * Changing HEIGHT just....changes the height.
\r
343 if (!check_KeepAR.Checked)
\r
345 switch (control.Name)
\r
348 double dw = (double)cropped_width * parW / parH;
\r
349 dw = Math.Round(dw, 2);
\r
350 txt_displayWidth.Text = dw.ToString();
\r
352 case "txt_parWidth":
\r
353 double dwpw = (double)cropped_width * parW / parH;
\r
354 dwpw = Math.Round(dwpw, 2);
\r
355 txt_displayWidth.Text = dwpw.ToString();
\r
357 case "txt_parHeight":
\r
358 double dwph = (double)cropped_width * parW / parH;
\r
359 dwph = Math.Round(dwph, 2);
\r
360 txt_displayWidth.Text = dwph.ToString();
\r
362 case "txt_displayWidth":
\r
363 txt_parWidth.Text = Math.Round(displayWidth, 0).ToString();
\r
364 txt_parHeight.Text = text_width.Text;
\r
370 * KEEPING DISPLAY ASPECT RATIO
\r
371 * DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
372 * Disable editing: PIXEL WIDTH, PIXEL HEIGHT
\r
373 * Changing DISPLAY WIDTH:
\r
374 * Changes HEIGHT to keep DAR
\r
375 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
376 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
378 * Changes DISPLAY WIDTH to keep DAR
\r
379 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
380 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
381 * Changing STORAGE_WIDTH:
\r
382 * Changes PIXEL WIDTH to DISPLAY WIDTH
\r
383 * Changes PIXEL HEIGHT to new STORAGE WIDTH
\r
386 if (check_KeepAR.Checked)
\r
388 switch (control.Name)
\r
390 case "txt_displayWidth":
\r
391 heightChangeGuard = true;
\r
392 text_height.Value = (decimal)getHeightKeepDar(); //Changes HEIGHT to keep DAR
\r
393 txt_parWidth.Text = txt_displayWidth.Text;
\r
394 txt_parHeight.Text = cropped_width.ToString();
\r
396 case "text_height":
\r
397 heightChangeGuard = true;
\r
398 txt_displayWidth.Text = getDisplayWidthKeepDar().ToString(); //Changes DISPLAY WIDTH to keep DAR
\r
399 txt_parWidth.Text = txt_displayWidth.Text;
\r
400 txt_parHeight.Text = cropped_width.ToString();
\r
403 txt_parWidth.Text = txt_displayWidth.Text;
\r
404 txt_parHeight.Text = cropped_width.ToString();
\r
409 private double getDisplayWidthKeepDar()
\r
411 double displayWidth;
\r
412 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
413 double currentDar = calculateDar();
\r
414 double newDwValue = displayWidth;
\r
416 // Correct display width up or down to correct for dar.
\r
417 if (currentDar > darValue)
\r
419 while (currentDar > darValue)
\r
422 newDwValue = displayWidth;
\r
423 currentDar = calculateDarByVal(text_height.Value, displayWidth);
\r
428 while (currentDar < darValue)
\r
431 newDwValue = displayWidth;
\r
432 currentDar = calculateDarByVal(text_height.Value, displayWidth);
\r
436 darValue = calculateDar(); // Cache the dar value
\r
439 private double getHeightKeepDar()
\r
441 double displayWidth;
\r
442 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
443 double currentDar = calculateDar();
\r
444 double newHeightVal = heightVal;
\r
446 // Correct display width up or down.
\r
447 if (currentDar > darValue)
\r
449 while (currentDar > darValue)
\r
452 newHeightVal = heightVal;
\r
453 currentDar = calculateDarByVal(heightVal, displayWidth);
\r
458 while (currentDar < darValue)
\r
461 newHeightVal = heightVal;
\r
462 currentDar = calculateDarByVal(heightVal, displayWidth);
\r
466 darValue = calculateDar(); // Cache the dar value
\r
467 return newHeightVal;
\r
469 private double calculateDar()
\r
471 // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
472 int cropTop = (int)crop_top.Value;
\r
473 int cropBottom = (int)crop_bottom.Value;
\r
474 int croppedHeight = (int)text_height.Value - cropTop - cropBottom;
\r
476 double displayWidth;
\r
477 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
479 double calculatedDar = displayWidth / croppedHeight;
\r
481 return calculatedDar;
\r
483 private double calculateDarByVal(decimal height, double displayWidth)
\r
485 // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
486 int cropTop = (int)crop_top.Value;
\r
487 int cropBottom = (int)crop_bottom.Value;
\r
488 int croppedHeight = (int)height - cropTop - cropBottom;
\r
490 double calculatedDar = darValue;
\r
491 if (croppedHeight > 0)
\r
492 calculatedDar = displayWidth / croppedHeight;
\r
494 return calculatedDar;
\r
496 private int displayWidth()
\r
498 if (selectedTitle != null)
\r
500 int actualWidth = (int)text_width.Value;
\r
501 int displayWidth = 0;
\r
504 int.TryParse(txt_parWidth.Text, out parW);
\r
505 int.TryParse(txt_parHeight.Text, out parH);
\r
507 if (drp_anamorphic.SelectedIndex != 3)
\r
508 displayWidth = (actualWidth * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height);
\r
509 else if (parW > 0 && parH > 0)
\r
510 displayWidth = (actualWidth * parW / parH);
\r
512 return displayWidth;
\r
517 // Resolution calculation and controls
\r
518 private decimal widthChangeMod(int mod)
\r
520 // Increase or decrease the height based on the users input.
\r
521 decimal returnVal = text_width.Value > widthVal ? getResolutionJump(mod, text_width.Value, true) : getResolutionJump(mod, text_width.Value, false);
\r
523 // Make sure we don't go above source value
\r
524 if (selectedTitle != null)
\r
525 if (selectedTitle.Resolution.Width < returnVal)
\r
526 returnVal = selectedTitle.Resolution.Width;
\r
528 // Set the global tracker
\r
529 widthVal = (int)returnVal;
\r
533 private decimal heightChangeMod(int mod)
\r
535 // Increase or decrease the height based on the users input.
\r
536 decimal returnVal = text_height.Value > heightVal ? getResolutionJump(mod, text_height.Value, true) : getResolutionJump(mod, text_height.Value, false);
\r
538 // Make sure we don't go above source value
\r
539 if (selectedTitle != null)
\r
540 if (selectedTitle.Resolution.Height < returnVal)
\r
541 returnVal = selectedTitle.Resolution.Height;
\r
543 // Set the global tracker
\r
544 heightVal = (int)returnVal; // TODO THIS IS CAUSING PROBLEM
\r
548 private decimal calculateUnchangeValue(Boolean widthChangeFromControl)
\r
550 decimal newValue = -1;
\r
551 if (selectedTitle != null && drp_anamorphic.SelectedIndex != 3 && drp_anamorphic.SelectedIndex != 2)
\r
552 if (widthChangeFromControl)
\r
553 newValue = cacluateHeight(widthVal);
\r
556 if (check_KeepAR.Checked)
\r
557 newValue = cacluateWidth(heightVal);
\r
562 private int getResolutionJump(int mod, decimal value, Boolean up)
\r
565 while ((value % mod) != 0)
\r
568 while ((value % mod) != 0)
\r
573 private double getModulusAuto(int mod, double value)
\r
575 int modDiv2 = mod / 2;
\r
577 if ((value % mod) != 0)
\r
579 double modVal = (int)value % mod;
\r
580 if (modVal >= modDiv2)
\r
582 modVal = 16 - modVal;
\r
583 value = (int)value + (int)modVal;
\r
587 value = (int)value - (int)modVal;
\r
592 private int cacluateHeight(int width)
\r
594 if (selectedTitle != null)
\r
598 if (selectedTitle.AspectRatio.ToString() == "1.78")
\r
603 else if (selectedTitle.AspectRatio.ToString() == "1.33")
\r
611 // Crop_Width = Title->Width - crop_Left - crop_right
\r
612 // Crop_Height = Title->Height - crop_top - crop_bottom
\r
613 double crop_width = selectedTitle.Resolution.Width - (double) crop_left.Value -
\r
614 (double) crop_right.Value;
\r
615 double crop_height = selectedTitle.Resolution.Height - (double) crop_top.Value -
\r
616 (double) crop_bottom.Value;
\r
618 double new_height = (width*selectedTitle.Resolution.Width*ah*crop_height)/
\r
619 (selectedTitle.Resolution.Height*aw*crop_width);
\r
621 if (drp_anamorphic.SelectedIndex == 3)
\r
622 new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);
\r
624 new_height = getModulusAuto(16, new_height);
\r
627 //double z = ( 16 * (( y + 8 ) / 16 ) );
\r
628 int x = int.Parse(new_height.ToString());
\r
636 private int cacluateWidth(int height)
\r
640 if (selectedTitle.AspectRatio.ToString() == "1.78")
\r
645 else if (selectedTitle.AspectRatio.ToString() == "1.33")
\r
654 double crop_width = selectedTitle.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;
\r
655 double crop_height = selectedTitle.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;
\r
657 double new_width = (height * selectedTitle.Resolution.Height * aw * crop_width) /
\r
658 (selectedTitle.Resolution.Width * ah * crop_height);
\r
660 if (drp_anamorphic.SelectedIndex == 3)
\r
661 new_width = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_width);
\r
663 new_width = getModulusAuto(16, new_width);
\r
666 //double z = ( 16 * (( y + 8 ) / 16 ) );
\r
667 int x = int.Parse(new_width.ToString());
\r
673 // Calculate Resolution for Anamorphic functions
\r
674 private string strictAnamorphic()
\r
676 // TODO Make sure cropping is Mod2
\r
677 if (selectedTitle != null)
\r
679 // Calculate the Actual Height
\r
680 int actualWidth = (int)text_width.Value - (int)crop_left.Value - (int)crop_right.Value; ;
\r
681 int actualHeight = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
683 // Calculate Actual Width
\r
684 double displayWidth = ((double)actualWidth * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height);
\r
685 return Math.Round(displayWidth, 0) + "x" + actualHeight;
\r
687 return "Select a Title";
\r
689 private string looseAnamorphic()
\r
691 if (selectedTitle != null)
\r
694 int actualWidth = (int)text_width.Value - (int)crop_left.Value - (int)crop_right.Value;
\r
696 int source_display_width = selectedTitle.Resolution.Width * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height;
\r
697 int source_cropped_height = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
699 // Calculate storage Aspect and cache it for reuse
\r
700 if (storageAspect == 0)
\r
701 storageAspect = (double)actualWidth / source_cropped_height;
\r
703 // Calculate the new height based on the input cropped width
\r
704 double hcalc = (actualWidth / storageAspect) + 0.5;
\r
705 double newHeight = getModulusAuto(16, hcalc);
\r
706 looseAnamorphicHeightGuard = true;
\r
708 if (newHeight < 64)
\r
710 text_height.Value = (decimal)newHeight; // BUG Out of Range Exception with Width too low here.
\r
712 // Calculate the anamorphic width
\r
713 double parW = newHeight * source_display_width / source_cropped_height;
\r
714 double parH = actualWidth;
\r
715 double displayWidth = (actualWidth * parW / parH);
\r
717 // Now correct DisplayWidth to maintain Aspect ratio. ActualHeight was mod16'd and thus AR is slightly different than the worked out displayWidths
\r
718 return Math.Truncate(displayWidth) + "x" + newHeight;
\r
720 return "Select a Title";
\r
725 private void disableCustomAnaControls()
\r
727 // Disable Custom Anamorphic Stuff
\r
728 lbl_modulus.Visible = false;
\r
729 lbl_displayWidth.Visible = false;
\r
730 lbl_parWidth.Visible = false;
\r
731 lbl_parHeight.Visible = false;
\r
732 drop_modulus.Visible = false;
\r
733 txt_displayWidth.Visible = false;
\r
734 txt_parWidth.Visible = false;
\r
735 txt_parHeight.Visible = false;
\r
736 check_KeepAR.Enabled = false;
\r
738 private void enableCustomAnaControls()
\r
740 // Disable Custom Anamorphic Stuff
\r
741 lbl_modulus.Visible = true;
\r
742 lbl_displayWidth.Visible = true;
\r
743 lbl_parWidth.Visible = true;
\r
744 lbl_parHeight.Visible = true;
\r
745 drop_modulus.Visible = true;
\r
746 txt_displayWidth.Visible = true;
\r
747 txt_parWidth.Visible = true;
\r
748 txt_parHeight.Visible = true;
\r
749 check_KeepAR.Enabled = true;
\r