2 using System.Drawing;
\r
3 using System.Windows.Forms;
\r
4 using Handbrake.Parsing;
\r
6 namespace Handbrake.Controls
\r
10 // - Fix MAX Width / Height Code.
\r
11 // - Tie in the cropping controls.
\r
13 /* Custom Anamorphic Mode
\r
15 * DISPLAY WIDTH STORAGE WIDTH PIXEL WIDTH
\r
16 * HEIGHT KEEP ASPECT PIXEL HEIGHT
\r
18 * --- NOT KEEPING DISPLAY ASPECT ---
\r
19 * Changing STORAGE WIDTH changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
20 * Changing PIXEL dimensions changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
21 * Changing DISPLAY WIDTH changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH
\r
22 * Changing HEIGHT just....changes the height.
\r
24 * --- KEEPING DISPLAY ASPECT RATIO ---
\r
25 * DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
26 * Disable editing: PIXEL WIDTH, PIXEL HEIGHT
\r
27 * Changing DISPLAY WIDTH:
\r
28 * Changes HEIGHT to keep DAR
\r
29 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
30 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
32 * Changes DISPLAY WIDTH to keep DAR
\r
33 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
34 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
35 * Changing STORAGE_WIDTH:
\r
36 * Changes PIXEL WIDTH to DISPLAY WIDTH
\r
37 * Changes PIXEL HEIGHT to new STORAGE WIDTH
\r
40 public partial class PictureSettings : UserControl
\r
43 int maxWidth, maxHeight;
\r
44 int widthVal, heightVal;
\r
45 private double darValue;
\r
46 private double storageAspect = 0; // Storage Aspect Cache for current source and title
\r
47 public Title selectedTitle { get; set; }
\r
48 private Boolean heightChangeGuard;
\r
49 private Boolean looseAnamorphicHeightGuard;
\r
50 private Boolean heightModJumpGaurd = false;
\r
53 public PictureSettings()
\r
55 InitializeComponent();
\r
57 drop_modulus.SelectedIndex = 0;
\r
60 public void setComponentsAfterScan(Title st)
\r
64 // Set the Aspect Ratio
\r
65 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
66 lbl_src_res.Text = selectedTitle.Resolution.Width + " x " + selectedTitle.Resolution.Height;
\r
68 // Set the Recommended Cropping values
\r
69 crop_top.Text = selectedTitle.AutoCropDimensions[0].ToString();
\r
70 crop_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();
\r
71 crop_left.Text = selectedTitle.AutoCropDimensions[2].ToString();
\r
72 crop_right.Text = selectedTitle.AutoCropDimensions[3].ToString();
\r
75 // Set the Resolution Boxes
\r
76 text_width.Value = selectedTitle.Resolution.Width;
\r
78 if (drp_anamorphic.SelectedIndex == 0)
\r
79 text_height.Value = cacluateHeight(selectedTitle.Resolution.Width);
\r
80 else if (drp_anamorphic.SelectedIndex == 1 || drp_anamorphic.SelectedIndex == 3)
\r
82 heightModJumpGaurd = true;
\r
83 text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
\r
85 else if (drp_anamorphic.SelectedIndex == 2)
\r
87 heightModJumpGaurd = false;
\r
88 text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
93 if (drp_anamorphic.SelectedIndex == 3)
\r
95 txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
\r
96 txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
\r
97 txt_displayWidth.Text = displayWidth().ToString();
\r
100 public void setMax()
\r
102 if (maxWidth != 0 && maxHeight != 0)
\r
103 lbl_max.Text = "Max Width / Height";
\r
104 else if (maxWidth != 0)
\r
105 lbl_max.Text = "Max Width";
\r
110 // Basic Picture Setting Controls
\r
111 private void text_width_ValueChanged(object sender, EventArgs e)
\r
115 int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
\r
117 // Increase or decrease value by the correct mod.
\r
118 text_width.Value = widthChangeMod(mod);
\r
121 switch (drp_anamorphic.SelectedIndex)
\r
124 if (calculateUnchangeValue(true) != -1)
\r
125 text_height.Value = calculateUnchangeValue(true);
\r
128 lbl_anamorphic.Text = strictAnamorphic();
\r
131 lbl_anamorphic.Text = looseAnamorphic();
\r
134 customAnamorphic(text_width);
\r
139 private void text_height_ValueChanged(object sender, EventArgs e)
\r
143 int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
\r
145 // Increase or decrease value by the correct mod.
\r
146 if (drp_anamorphic.SelectedIndex != 2 && !heightModJumpGaurd)
\r
148 decimal val = heightChangeMod(mod);
\r
149 heightChangeGuard = true;
\r
150 if (text_height.Value != val)
\r
152 heightChangeGuard = false;
\r
153 text_height.Value = val;
\r
158 switch (drp_anamorphic.SelectedIndex)
\r
161 if (drp_anamorphic.SelectedIndex != 3)
\r
163 if (calculateUnchangeValue(false) != -1)
\r
164 text_width.Value = calculateUnchangeValue(false);
\r
168 lbl_anamorphic.Text = strictAnamorphic();
\r
171 if (!looseAnamorphicHeightGuard)
\r
172 lbl_anamorphic.Text = looseAnamorphic();
\r
175 if (!heightChangeGuard)
\r
176 customAnamorphic(text_height);
\r
179 heightChangeGuard = false;
\r
180 looseAnamorphicHeightGuard = false;
\r
181 heightModJumpGaurd = false;
\r
183 private void check_KeepAR_CheckedChanged(object sender, EventArgs e)
\r
185 // Recalculate Height based on width when enabled
\r
186 if (drp_anamorphic.SelectedIndex != 3 && check_KeepAR.Checked && selectedTitle != null)
\r
187 text_height.Value = cacluateHeight(widthVal);
\r
189 // Enable Par Width/Height Check boxes if Keep AR is enabled, otherwise disable them
\r
190 if (check_KeepAR.Checked)
\r
192 txt_parWidth.Enabled = false;
\r
193 txt_parHeight.Enabled = false;
\r
197 txt_parWidth.Enabled = true;
\r
198 txt_parHeight.Enabled = true;
\r
201 private void drp_anamorphic_SelectedIndexChanged(object sender, EventArgs e)
\r
203 switch (drp_anamorphic.SelectedIndex)
\r
206 text_height.BackColor = Color.White;
\r
207 text_width.BackColor = Color.White;
\r
208 text_height.Enabled = true;
\r
209 text_width.Enabled = true;
\r
210 check_KeepAR.CheckState = CheckState.Checked;
\r
211 check_KeepAR.Enabled = true;
\r
212 disableCustomAnaControls();
\r
213 text_width.Text = widthVal.ToString();
\r
214 text_height.Text = heightVal.ToString();
\r
215 check_KeepAR.Enabled = true;
\r
216 lbl_anamorphic.Text = "";
\r
217 lbl_anamprohicLbl.Visible = false;
\r
220 text_height.BackColor = Color.LightGray;
\r
221 text_width.BackColor = Color.LightGray;
\r
222 if (selectedTitle != null)
\r
224 heightModJumpGaurd = true;
\r
225 text_width.Value = selectedTitle.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
\r
226 text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
228 text_height.Enabled = false;
\r
229 text_width.Enabled = false;
\r
230 check_KeepAR.CheckState = CheckState.Unchecked;
\r
231 check_KeepAR.Enabled = false;
\r
232 disableCustomAnaControls();
\r
233 lbl_anamorphic.Text = strictAnamorphic();
\r
234 lbl_anamprohicLbl.Visible = true;
\r
237 disableCustomAnaControls();
\r
239 text_height.Enabled = false;
\r
240 text_height.BackColor = Color.LightGray;
\r
241 text_width.Enabled = true;
\r
242 text_width.BackColor = Color.White;
\r
243 if (selectedTitle != null)
\r
245 heightModJumpGaurd = true;
\r
246 text_width.Value = selectedTitle.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;
\r
247 text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
\r
249 lbl_anamorphic.Text = looseAnamorphic();
\r
250 lbl_anamprohicLbl.Visible = true;
\r
254 // Display Elements
\r
255 enableCustomAnaControls();
\r
256 text_height.BackColor = Color.White;
\r
257 text_width.BackColor = Color.White;
\r
258 text_height.Enabled = true;
\r
259 text_width.Enabled = true;
\r
262 if (selectedTitle != null)
\r
264 heightModJumpGaurd = true;
\r
265 widthVal = selectedTitle.Resolution.Width;
\r
266 text_width.Value = selectedTitle.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
\r
267 text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
268 txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
\r
269 txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
\r
270 txt_displayWidth.Text = displayWidth().ToString();
\r
273 darValue = calculateDar();
\r
275 check_KeepAR.CheckState = CheckState.Checked;
\r
276 check_KeepAR.Enabled = true;
\r
277 lbl_anamprohicLbl.Visible = true;
\r
283 // Custom Anamorphic Controls
\r
284 private void txt_displayWidth_Keyup(object sender, KeyEventArgs e)
\r
286 if (e.KeyCode == Keys.Enter)
\r
287 customAnamorphic(txt_displayWidth);
\r
289 private void txt_parHeight_Keyup(object sender, KeyEventArgs e)
\r
291 if (e.KeyCode == Keys.Enter)
\r
292 customAnamorphic(txt_parHeight);
\r
294 private void txt_parWidth_Keyup(object sender, KeyEventArgs e)
\r
296 if (e.KeyCode == Keys.Enter)
\r
297 customAnamorphic(txt_parWidth);
\r
300 // Cropping Control
\r
301 private void check_autoCrop_CheckedChanged(object sender, EventArgs e)
\r
303 crop_left.Enabled = false;
\r
304 crop_right.Enabled = false;
\r
305 crop_top.Enabled = false;
\r
306 crop_bottom.Enabled = false;
\r
308 private void check_customCrop_CheckedChanged(object sender, EventArgs e)
\r
310 crop_left.Enabled = true;
\r
311 crop_right.Enabled = true;
\r
312 crop_top.Enabled = true;
\r
313 crop_bottom.Enabled = true;
\r
314 if (selectedTitle != null)
\r
316 crop_top.Text = selectedTitle.AutoCropDimensions[0].ToString();
\r
317 crop_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();
\r
318 crop_left.Text = selectedTitle.AutoCropDimensions[2].ToString();
\r
319 crop_right.Text = selectedTitle.AutoCropDimensions[3].ToString();
\r
323 crop_left.Text = "0";
\r
324 crop_right.Text = "0";
\r
325 crop_top.Text = "0";
\r
326 crop_bottom.Text = "0";
\r
330 // Custom Anamorphic Code
\r
331 private void customAnamorphic(Control control)
\r
333 // Get and parse all the required values
\r
334 int cropLeft = (int)crop_left.Value;
\r
335 int cropRight = (int)crop_right.Value;
\r
337 int width = (int)text_width.Value;
\r
338 int cropped_width = width - cropLeft - cropRight;
\r
341 int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
\r
344 double displayWidth;
\r
345 int.TryParse(txt_parWidth.Text, out parW);
\r
346 int.TryParse(txt_parHeight.Text, out parH);
\r
347 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
349 /* NOT KEEPING DISPLAY ASPECT
\r
350 * Changing STORAGE WIDTH changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
351 * Changing PIXEL dimensions changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
\r
352 * Changing DISPLAY WIDTH changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH
\r
353 * Changing HEIGHT just....changes the height.
\r
355 if (!check_KeepAR.Checked)
\r
357 switch (control.Name)
\r
360 double dw = (double)cropped_width * parW / parH;
\r
361 dw = Math.Round(dw, 2);
\r
362 txt_displayWidth.Text = dw.ToString();
\r
364 case "txt_parWidth":
\r
365 double dwpw = (double)cropped_width * parW / parH;
\r
366 dwpw = Math.Round(dwpw, 2);
\r
367 txt_displayWidth.Text = dwpw.ToString();
\r
369 case "txt_parHeight":
\r
370 double dwph = (double)cropped_width * parW / parH;
\r
371 dwph = Math.Round(dwph, 2);
\r
372 txt_displayWidth.Text = dwph.ToString();
\r
374 case "txt_displayWidth":
\r
375 txt_parWidth.Text = Math.Round(displayWidth, 0).ToString();
\r
376 txt_parHeight.Text = text_width.Text;
\r
382 * KEEPING DISPLAY ASPECT RATIO
\r
383 * DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
384 * Disable editing: PIXEL WIDTH, PIXEL HEIGHT
\r
385 * Changing DISPLAY WIDTH:
\r
386 * Changes HEIGHT to keep DAR
\r
387 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
388 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
390 * Changes DISPLAY WIDTH to keep DAR
\r
391 * Changes PIXEL WIDTH to new DISPLAY WIDTH
\r
392 * Changes PIXEL HEIGHT to STORAGE WIDTH
\r
393 * Changing STORAGE_WIDTH:
\r
394 * Changes PIXEL WIDTH to DISPLAY WIDTH
\r
395 * Changes PIXEL HEIGHT to new STORAGE WIDTH
\r
398 if (check_KeepAR.Checked)
\r
400 switch (control.Name)
\r
402 case "txt_displayWidth":
\r
403 heightChangeGuard = true;
\r
404 text_height.Value = (decimal)getHeightKeepDar(); //Changes HEIGHT to keep DAR
\r
405 //darValue = calculateDar(); // Cache the dar value
\r
406 txt_parWidth.Text = txt_displayWidth.Text;
\r
407 txt_parHeight.Text = cropped_width.ToString();
\r
409 case "text_height":
\r
410 heightChangeGuard = true;
\r
411 txt_displayWidth.Text = getDisplayWidthKeepDar().ToString(); //Changes DISPLAY WIDTH to keep DAR
\r
412 txt_parWidth.Text = txt_displayWidth.Text;
\r
413 txt_parHeight.Text = cropped_width.ToString();
\r
416 txt_parWidth.Text = txt_displayWidth.Text;
\r
417 txt_parHeight.Text = cropped_width.ToString();
\r
422 private double getDisplayWidthKeepDar()
\r
424 double displayWidth;
\r
425 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
426 double currentDar = calculateDar();
\r
427 double newDwValue = displayWidth;
\r
429 // Correct display width up or down to correct for dar.
\r
430 if (currentDar > darValue)
\r
432 while (currentDar > darValue)
\r
435 newDwValue = displayWidth;
\r
436 currentDar = calculateDarByVal(text_height.Value, displayWidth);
\r
441 while (currentDar < darValue)
\r
444 newDwValue = displayWidth;
\r
445 currentDar = calculateDarByVal(text_height.Value, displayWidth);
\r
449 return Math.Round(newDwValue, 2);
\r
451 private double getHeightKeepDar()
\r
453 double displayWidth;
\r
454 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
455 double currentDar = calculateDar();
\r
456 double newHeightVal = heightVal;
\r
458 // Correct display width up or down.
\r
459 if (currentDar > darValue)
\r
461 while (currentDar > darValue)
\r
464 newHeightVal = heightVal;
\r
465 currentDar = calculateDarByVal(heightVal, displayWidth);
\r
470 while (currentDar < darValue)
\r
473 newHeightVal = heightVal;
\r
474 currentDar = calculateDarByVal(heightVal, displayWidth);
\r
478 return newHeightVal;
\r
480 private double calculateDar()
\r
482 // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
483 double displayWidth;
\r
484 double.TryParse(txt_displayWidth.Text, out displayWidth);
\r
486 double calculatedDar = displayWidth / (int)text_height.Value;
\r
488 return calculatedDar;
\r
490 private double calculateDarByVal(decimal croppedHeight, double displayWidth)
\r
492 // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
\r
493 double calculatedDar = darValue;
\r
494 if (croppedHeight > 0)
\r
495 calculatedDar = displayWidth / (double)croppedHeight;
\r
497 return calculatedDar;
\r
499 private int displayWidth()
\r
501 if (selectedTitle != null)
\r
503 int actualWidth = (int)text_width.Value;
\r
504 int displayWidth = 0;
\r
507 int.TryParse(txt_parWidth.Text, out parW);
\r
508 int.TryParse(txt_parHeight.Text, out parH);
\r
510 if (drp_anamorphic.SelectedIndex != 3)
\r
511 displayWidth = (actualWidth * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height);
\r
512 else if (parW > 0 && parH > 0)
\r
513 displayWidth = (actualWidth * parW / parH);
\r
515 return displayWidth;
\r
520 // Resolution calculation and controls
\r
521 private decimal widthChangeMod(int mod)
\r
523 // Increase or decrease the height based on the users input.
\r
524 decimal returnVal = text_width.Value > widthVal ? getResolutionJump(mod, text_width.Value, true) : getResolutionJump(mod, text_width.Value, false);
\r
526 // Make sure we don't go above source value
\r
527 if (selectedTitle != null)
\r
528 if (selectedTitle.Resolution.Width < returnVal)
\r
529 returnVal = selectedTitle.Resolution.Width;
\r
531 // Set the global tracker
\r
532 widthVal = (int)returnVal;
\r
536 private decimal heightChangeMod(int mod)
\r
538 // Increase or decrease the height based on the users input.
\r
539 decimal returnVal = text_height.Value > heightVal ? getResolutionJump(mod, text_height.Value, true) : getResolutionJump(mod, text_height.Value, false);
\r
541 // Make sure we don't go above source value
\r
542 if (selectedTitle != null)
\r
543 if (selectedTitle.Resolution.Height < returnVal)
\r
544 returnVal = selectedTitle.Resolution.Height;
\r
546 // Set the global tracker
\r
547 heightVal = (int)returnVal; // TODO THIS IS CAUSING PROBLEM
\r
551 private decimal calculateUnchangeValue(Boolean widthChangeFromControl)
\r
553 decimal newValue = -1;
\r
554 if (selectedTitle != null && drp_anamorphic.SelectedIndex != 3 && drp_anamorphic.SelectedIndex != 2)
\r
555 if (widthChangeFromControl)
\r
556 newValue = cacluateHeight(widthVal);
\r
559 if (check_KeepAR.Checked)
\r
560 newValue = cacluateWidth(heightVal);
\r
565 private int getResolutionJump(int mod, decimal value, Boolean up)
\r
568 while ((value % mod) != 0)
\r
571 while ((value % mod) != 0)
\r
576 private double getModulusAuto(int mod, double value)
\r
578 int modDiv2 = mod / 2;
\r
580 if ((value % mod) != 0)
\r
582 double modVal = (int)value % mod;
\r
583 if (modVal >= modDiv2)
\r
585 modVal = 16 - modVal;
\r
586 value = (int)value + (int)modVal;
\r
590 value = (int)value - (int)modVal;
\r
595 private int cacluateHeight(int width)
\r
597 if (selectedTitle != null)
\r
601 if (selectedTitle.AspectRatio.ToString() == "1.78")
\r
606 else if (selectedTitle.AspectRatio.ToString() == "1.33")
\r
614 // Crop_Width = Title->Width - crop_Left - crop_right
\r
615 // Crop_Height = Title->Height - crop_top - crop_bottom
\r
616 double crop_width = selectedTitle.Resolution.Width - (double) crop_left.Value -
\r
617 (double) crop_right.Value;
\r
618 double crop_height = selectedTitle.Resolution.Height - (double) crop_top.Value -
\r
619 (double) crop_bottom.Value;
\r
621 double new_height = (width*selectedTitle.Resolution.Width*ah*crop_height)/
\r
622 (selectedTitle.Resolution.Height*aw*crop_width);
\r
624 if (drp_anamorphic.SelectedIndex == 3)
\r
625 new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);
\r
627 new_height = getModulusAuto(16, new_height);
\r
630 //double z = ( 16 * (( y + 8 ) / 16 ) );
\r
631 int x = int.Parse(new_height.ToString());
\r
639 private int cacluateWidth(int height)
\r
643 if (selectedTitle.AspectRatio.ToString() == "1.78")
\r
648 else if (selectedTitle.AspectRatio.ToString() == "1.33")
\r
657 double crop_width = selectedTitle.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;
\r
658 double crop_height = selectedTitle.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;
\r
660 double new_width = (height * selectedTitle.Resolution.Height * aw * crop_width) /
\r
661 (selectedTitle.Resolution.Width * ah * crop_height);
\r
663 if (drp_anamorphic.SelectedIndex == 3)
\r
664 new_width = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_width);
\r
666 new_width = getModulusAuto(16, new_width);
\r
669 //double z = ( 16 * (( y + 8 ) / 16 ) );
\r
670 int x = int.Parse(new_width.ToString());
\r
676 // Calculate Resolution for Anamorphic functions
\r
677 private string strictAnamorphic()
\r
679 // TODO Make sure cropping is Mod2
\r
680 if (selectedTitle != null)
\r
682 // Calculate the Actual Height
\r
683 int actualWidth = (int)text_width.Value - (int)crop_left.Value - (int)crop_right.Value; ;
\r
684 int actualHeight = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
686 // Calculate Actual Width
\r
687 double displayWidth = ((double)actualWidth * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height);
\r
688 return Math.Round(displayWidth, 0) + "x" + actualHeight;
\r
690 return "Select a Title";
\r
692 private string looseAnamorphic()
\r
694 if (selectedTitle != null)
\r
697 int actualWidth = (int)text_width.Value - (int)crop_left.Value - (int)crop_right.Value;
\r
699 int source_display_width = selectedTitle.Resolution.Width * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height;
\r
700 int source_cropped_height = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
\r
702 // Calculate storage Aspect and cache it for reuse
\r
703 if (storageAspect == 0)
\r
704 storageAspect = (double)actualWidth / source_cropped_height;
\r
706 // Calculate the new height based on the input cropped width
\r
707 double hcalc = (actualWidth / storageAspect) + 0.5;
\r
708 double newHeight = getModulusAuto(16, hcalc);
\r
709 looseAnamorphicHeightGuard = true;
\r
711 if (newHeight < 64)
\r
713 text_height.Value = (decimal)newHeight; // BUG Out of Range Exception with Width too low here.
\r
715 // Calculate the anamorphic width
\r
716 double parW = newHeight * source_display_width / source_cropped_height;
\r
717 double parH = actualWidth;
\r
718 double displayWidth = (actualWidth * parW / parH);
\r
720 // Now correct DisplayWidth to maintain Aspect ratio. ActualHeight was mod16'd and thus AR is slightly different than the worked out displayWidths
\r
721 return Math.Truncate(displayWidth) + "x" + newHeight;
\r
723 return "Select a Title";
\r
728 private void disableCustomAnaControls()
\r
730 // Disable Custom Anamorphic Stuff
\r
731 lbl_modulus.Visible = false;
\r
732 lbl_displayWidth.Visible = false;
\r
733 lbl_parWidth.Visible = false;
\r
734 lbl_parHeight.Visible = false;
\r
735 drop_modulus.Visible = false;
\r
736 txt_displayWidth.Visible = false;
\r
737 txt_parWidth.Visible = false;
\r
738 txt_parHeight.Visible = false;
\r
739 check_KeepAR.Enabled = false;
\r
741 private void enableCustomAnaControls()
\r
743 // Disable Custom Anamorphic Stuff
\r
744 lbl_modulus.Visible = true;
\r
745 lbl_displayWidth.Visible = true;
\r
746 lbl_parWidth.Visible = true;
\r
747 lbl_parHeight.Visible = true;
\r
748 drop_modulus.Visible = true;
\r
749 txt_displayWidth.Visible = true;
\r
750 txt_parWidth.Visible = true;
\r
751 txt_parHeight.Visible = true;
\r
752 check_KeepAR.Enabled = true;
\r