1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
|
using System;
using System.Drawing;
using System.Windows.Forms;
using Handbrake.Parsing;
namespace Handbrake.Controls
{
// TODO
// - Tie in the cropping controls.
public partial class PictureSettings : UserControl
{
// Globals
public int maxWidth, maxHeight;
int widthVal, heightVal;
private double darValue;
private double storageAspect; // Storage Aspect Cache for current source and title
public Title selectedTitle { private get; set; }
private Boolean heightChangeGuard;
private Boolean looseAnamorphicHeightGuard;
private Boolean heightModJumpGaurd;
// Window Setup
public PictureSettings()
{
InitializeComponent();
lbl_max.Text = "";
drop_modulus.SelectedIndex = 0;
storageAspect = 0;
}
public void setComponentsAfterScan(Title st)
{
storageAspect = 0;
selectedTitle = st;
// Set the Aspect Ratio
lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
lbl_src_res.Text = selectedTitle.Resolution.Width + " x " + selectedTitle.Resolution.Height;
// Set the Recommended Cropping values
crop_top.Text = selectedTitle.AutoCropDimensions[0].ToString();
crop_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();
crop_left.Text = selectedTitle.AutoCropDimensions[2].ToString();
crop_right.Text = selectedTitle.AutoCropDimensions[3].ToString();
// Set the Resolution Boxes
text_width.Value = selectedTitle.Resolution.Width;
if (drp_anamorphic.SelectedIndex == 0)
text_height.Value = cacluateHeight(selectedTitle.Resolution.Width);
else if (drp_anamorphic.SelectedIndex == 1 || drp_anamorphic.SelectedIndex == 3)
{
heightModJumpGaurd = true;
text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
}
else if (drp_anamorphic.SelectedIndex == 2)
{
heightModJumpGaurd = false;
text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
}
if (drp_anamorphic.SelectedIndex == 3)
{
txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
txt_displayWidth.Text = displayWidth().ToString();
}
setMax();
}
public void setMax()
{
if (maxWidth != 0 && maxHeight != 0)
lbl_max.Text = "Max Width / Height";
else if (maxWidth != 0)
lbl_max.Text = "Max Width";
else
lbl_max.Text = "";
}
// Basic Picture Setting Controls
private void text_width_ValueChanged(object sender, EventArgs e)
{
maxWidth = 0;
setMax();
// Get the Modulus
int mod;
int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
// Increase or decrease value by the correct mod.
text_width.Value = widthChangeMod(mod);
// Mode Switch
switch (drp_anamorphic.SelectedIndex)
{
case 0:
if (calculateUnchangeValue(true) != -1 && check_KeepAR.Checked)
text_height.Value = calculateUnchangeValue(true);
break;
case 1:
lbl_anamorphic.Text = strictAnamorphic();
break;
case 2:
lbl_anamorphic.Text = looseAnamorphic();
break;
case 3:
customAnamorphic(text_width);
break;
}
}
private void text_height_ValueChanged(object sender, EventArgs e)
{
maxHeight = 0;
setMax();
// Get the Modulus
int mod;
int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
// Increase or decrease value by the correct mod.
if (drp_anamorphic.SelectedIndex != 2 && !heightModJumpGaurd)
{
decimal val = heightChangeMod(mod);
heightChangeGuard = true;
if (text_height.Value != val)
{
heightChangeGuard = false;
text_height.Value = val;
}
}
// Mode Switch
switch (drp_anamorphic.SelectedIndex)
{
case 0:
if (drp_anamorphic.SelectedIndex != 3)
{
if (calculateUnchangeValue(false) != -1)
text_width.Value = calculateUnchangeValue(false);
}
break;
case 1:
lbl_anamorphic.Text = strictAnamorphic();
break;
case 2:
if (!looseAnamorphicHeightGuard)
lbl_anamorphic.Text = looseAnamorphic();
break;
case 3:
if (!heightChangeGuard)
customAnamorphic(text_height);
break;
}
heightChangeGuard = false;
looseAnamorphicHeightGuard = false;
heightModJumpGaurd = false;
}
private void check_KeepAR_CheckedChanged(object sender, EventArgs e)
{
// Recalculate Height based on width when enabled
if (drp_anamorphic.SelectedIndex != 3 && check_KeepAR.Checked && selectedTitle != null)
text_height.Value = cacluateHeight(widthVal);
// Enable Par Width/Height Check boxes if Keep AR is enabled, otherwise disable them
if (check_KeepAR.Checked)
{
txt_parWidth.Enabled = false;
txt_parHeight.Enabled = false;
}
else
{
txt_parWidth.Enabled = true;
txt_parHeight.Enabled = true;
}
}
private void drp_anamorphic_SelectedIndexChanged(object sender, EventArgs e)
{
switch (drp_anamorphic.SelectedIndex)
{
case 0: // None
text_height.Enabled = true;
text_width.Enabled = true;
check_KeepAR.CheckState = CheckState.Checked;
check_KeepAR.Enabled = true;
disableCustomAnaControls();
if (selectedTitle != null)
{
text_width.Value = selectedTitle.Resolution.Width;
text_height.Value = selectedTitle.Resolution.Height;
}
check_KeepAR.Enabled = true;
lbl_anamorphic.Text = "";
lbl_anamprohicLbl.Visible = false;
break;
case 1: // Strict
if (selectedTitle != null)
{
heightModJumpGaurd = true;
text_width.Value = selectedTitle.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
}
text_height.Enabled = false;
text_width.Enabled = false;
check_KeepAR.CheckState = CheckState.Unchecked;
check_KeepAR.Enabled = false;
disableCustomAnaControls();
lbl_anamorphic.Text = strictAnamorphic();
lbl_anamprohicLbl.Visible = true;
break;
case 2: // Loose
disableCustomAnaControls();
storageAspect = 0;
text_height.Enabled = false;
text_width.Enabled = true;
if (selectedTitle != null)
{
heightModJumpGaurd = true;
text_width.Value = selectedTitle.Resolution.Width;
text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
}
lbl_anamorphic.Text = looseAnamorphic();
lbl_anamprohicLbl.Visible = true;
break;
case 3: // Custom
// Display Elements
enableCustomAnaControls();
text_height.Enabled = true;
text_width.Enabled = true;
// Actual Work
if (selectedTitle != null)
{
heightModJumpGaurd = true;
widthVal = selectedTitle.Resolution.Width;
text_width.Value = selectedTitle.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
txt_displayWidth.Text = displayWidth().ToString();
}
darValue = calculateDar();
check_KeepAR.CheckState = CheckState.Checked;
check_KeepAR.Enabled = true;
lbl_anamprohicLbl.Visible = true;
break;
}
}
// Custom Anamorphic Controls
private void txt_displayWidth_Keyup(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
customAnamorphic(txt_displayWidth);
}
private void txt_parHeight_Keyup(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
customAnamorphic(txt_parHeight);
}
private void txt_parWidth_Keyup(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
customAnamorphic(txt_parWidth);
}
// Cropping Controls
private void check_autoCrop_CheckedChanged(object sender, EventArgs e)
{
crop_left.Enabled = false;
crop_right.Enabled = false;
crop_top.Enabled = false;
crop_bottom.Enabled = false;
}
private void check_customCrop_CheckedChanged(object sender, EventArgs e)
{
crop_left.Enabled = true;
crop_right.Enabled = true;
crop_top.Enabled = true;
crop_bottom.Enabled = true;
if (selectedTitle != null)
{
crop_top.Text = selectedTitle.AutoCropDimensions[0].ToString();
crop_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();
crop_left.Text = selectedTitle.AutoCropDimensions[2].ToString();
crop_right.Text = selectedTitle.AutoCropDimensions[3].ToString();
}
else
{
crop_left.Text = "0";
crop_right.Text = "0";
crop_top.Text = "0";
crop_bottom.Text = "0";
}
}
private void crop_left_ValueChanged(object sender, EventArgs e)
{
if (crop_left.Value % 2 != 0)
crop_left.Value++;
}
private void crop_right_ValueChanged(object sender, EventArgs e)
{
if (crop_right.Value % 2 != 0)
crop_right.Value++;
}
private void crop_top_ValueChanged(object sender, EventArgs e)
{
if (crop_top.Value % 2 != 0)
crop_top.Value++;
}
private void crop_bottom_ValueChanged(object sender, EventArgs e)
{
if (crop_bottom.Value % 2 != 0)
crop_bottom.Value++;
}
// Custom Anamorphic Code
private void customAnamorphic(Control control)
{
// Get and parse all the required values
int cropLeft = (int)crop_left.Value;
int cropRight = (int)crop_right.Value;
int width = (int)text_width.Value;
int cropped_width = width - cropLeft - cropRight;
int mod = 16;
int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);
int parW, parH;
double displayWidth;
int.TryParse(txt_parWidth.Text, out parW);
int.TryParse(txt_parHeight.Text, out parH);
double.TryParse(txt_displayWidth.Text, out displayWidth);
/* NOT KEEPING DISPLAY ASPECT
* Changing STORAGE WIDTH changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
* Changing PIXEL dimensions changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT
* Changing DISPLAY WIDTH changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH
* Changing HEIGHT just....changes the height.
*/
if (!check_KeepAR.Checked)
{
switch (control.Name)
{
case "text_width":
double dw = (double)cropped_width * parW / parH;
dw = Math.Round(dw, 2);
txt_displayWidth.Text = dw.ToString();
break;
case "txt_parWidth":
double dwpw = (double)cropped_width * parW / parH;
dwpw = Math.Round(dwpw, 2);
txt_displayWidth.Text = dwpw.ToString();
break;
case "txt_parHeight":
double dwph = (double)cropped_width * parW / parH;
dwph = Math.Round(dwph, 2);
txt_displayWidth.Text = dwph.ToString();
break;
case "txt_displayWidth":
txt_parWidth.Text = Math.Round(displayWidth, 0).ToString();
txt_parHeight.Text = text_width.Text;
break;
}
}
/*
* KEEPING DISPLAY ASPECT RATIO
* 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
*/
if (check_KeepAR.Checked)
{
switch (control.Name)
{
case "txt_displayWidth":
heightChangeGuard = true;
text_height.Value = (decimal)getHeightKeepDar(); //Changes HEIGHT to keep DAR
//darValue = calculateDar(); // Cache the dar value
txt_parWidth.Text = txt_displayWidth.Text;
txt_parHeight.Text = cropped_width.ToString();
break;
case "text_height":
heightChangeGuard = true;
txt_displayWidth.Text = getDisplayWidthKeepDar().ToString(); //Changes DISPLAY WIDTH to keep DAR
txt_parWidth.Text = txt_displayWidth.Text;
txt_parHeight.Text = cropped_width.ToString();
break;
case "text_width":
txt_parWidth.Text = txt_displayWidth.Text;
txt_parHeight.Text = cropped_width.ToString();
break;
}
}
}
private double getDisplayWidthKeepDar()
{
double displayWidth;
double.TryParse(txt_displayWidth.Text, out displayWidth);
double currentDar = calculateDar();
double newDwValue = displayWidth;
// Correct display width up or down to correct for dar.
if (currentDar > darValue)
{
while (currentDar > darValue)
{
displayWidth--;
newDwValue = displayWidth;
currentDar = calculateDarByVal(text_height.Value, displayWidth);
}
}
else
{
while (currentDar < darValue)
{
displayWidth++;
newDwValue = displayWidth;
currentDar = calculateDarByVal(text_height.Value, displayWidth);
}
}
return Math.Round(newDwValue, 2);
}
private double getHeightKeepDar()
{
double displayWidth;
double.TryParse(txt_displayWidth.Text, out displayWidth);
double currentDar = calculateDar();
double newHeightVal = heightVal;
// Correct display width up or down.
if (currentDar > darValue)
{
while (currentDar > darValue)
{
heightVal++;
newHeightVal = heightVal;
currentDar = calculateDarByVal(heightVal, displayWidth);
}
}
else
{
while (currentDar < darValue)
{
heightVal--;
newHeightVal = heightVal;
currentDar = calculateDarByVal(heightVal, displayWidth);
}
}
return newHeightVal;
}
private double calculateDar()
{
// DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
double displayWidth;
double.TryParse(txt_displayWidth.Text, out displayWidth);
double calculatedDar = displayWidth / (int)text_height.Value;
return calculatedDar;
}
private double calculateDarByVal(decimal croppedHeight, double displayWidth)
{
// DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
double calculatedDar = darValue;
if (croppedHeight > 0)
calculatedDar = displayWidth / (double)croppedHeight;
return calculatedDar;
}
private int displayWidth()
{
if (selectedTitle != null)
{
int actualWidth = (int)text_width.Value;
int displayWidth = 0;
int parW, parH;
int.TryParse(txt_parWidth.Text, out parW);
int.TryParse(txt_parHeight.Text, out parH);
if (drp_anamorphic.SelectedIndex != 3)
displayWidth = (actualWidth * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height);
else if (parW > 0 && parH > 0)
displayWidth = (actualWidth * parW / parH);
return displayWidth;
}
return -1;
}
// Resolution calculation and controls
private decimal widthChangeMod(int mod)
{
// Increase or decrease the height based on the users input.
decimal returnVal = text_width.Value > widthVal ? getResolutionJump(mod, text_width.Value, true) : getResolutionJump(mod, text_width.Value, false);
// Make sure we don't go above source value
if (selectedTitle != null)
if (selectedTitle.Resolution.Width < returnVal)
returnVal = selectedTitle.Resolution.Width;
if (returnVal < 64)
returnVal = 64;
// Set the global tracker
widthVal = (int)returnVal;
return returnVal;
}
private decimal heightChangeMod(int mod)
{
// Increase or decrease the height based on the users input.
decimal returnVal = text_height.Value > heightVal ? getResolutionJump(mod, text_height.Value, true) : getResolutionJump(mod, text_height.Value, false);
// Make sure we don't go above source value
if (selectedTitle != null)
if (selectedTitle.Resolution.Height < returnVal)
returnVal = selectedTitle.Resolution.Height;
if (returnVal < 64)
returnVal = 64;
// Set the global tracker
heightVal = (int)returnVal;
return returnVal;
}
private decimal calculateUnchangeValue(Boolean widthChangeFromControl)
{
decimal newValue = -1;
if (selectedTitle != null && drp_anamorphic.SelectedIndex != 3 && drp_anamorphic.SelectedIndex != 2)
if (widthChangeFromControl)
newValue = cacluateHeight(widthVal);
else
{
if (check_KeepAR.Checked)
newValue = cacluateWidth(heightVal);
}
return newValue;
}
private int getResolutionJump(int mod, decimal value, Boolean up)
{
if (up)
while ((value % mod) != 0)
value++;
else
while ((value % mod) != 0)
value--;
return (int)value;
}
private double getModulusAuto(int mod, double value)
{
int modDiv2 = mod / 2;
if ((value % mod) != 0)
{
double modVal = (int)value % mod;
if (modVal >= modDiv2)
{
modVal = 16 - modVal;
value = (int)value + (int)modVal;
}
else
{
value = (int)value - (int)modVal;
}
}
return value;
}
private int cacluateHeight(int width)
{
if (selectedTitle != null)
{
int aw = 0;
int ah = 0;
if (selectedTitle.AspectRatio.ToString() == "1.78")
{
aw = 16;
ah = 9;
}
else if (selectedTitle.AspectRatio.ToString() == "1.33")
{
aw = 4;
ah = 3;
}
if (aw != 0)
{
// Crop_Width = Title->Width - crop_Left - crop_right
// Crop_Height = Title->Height - crop_top - crop_bottom
double crop_width = selectedTitle.Resolution.Width - (double) crop_left.Value -
(double) crop_right.Value;
double crop_height = selectedTitle.Resolution.Height - (double) crop_top.Value -
(double) crop_bottom.Value;
double new_height = (width*selectedTitle.Resolution.Width*ah*crop_height)/
(selectedTitle.Resolution.Height*aw*crop_width);
if (drp_anamorphic.SelectedIndex == 3)
new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);
else
new_height = getModulusAuto(16, new_height);
//16 * (421 / 16)
//double z = ( 16 * (( y + 8 ) / 16 ) );
int x = int.Parse(new_height.ToString());
if (x < 64)
x = 64;
return x;
}
}
return 0;
}
private int cacluateWidth(int height)
{
int aw = 0;
int ah = 0;
if (selectedTitle.AspectRatio.ToString() == "1.78")
{
aw = 16;
ah = 9;
}
else if (selectedTitle.AspectRatio.ToString() == "1.33")
{
aw = 4;
ah = 3;
}
if (aw != 0)
{
double crop_width = selectedTitle.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;
double crop_height = selectedTitle.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;
double new_width = (height * selectedTitle.Resolution.Height * aw * crop_width) /
(selectedTitle.Resolution.Width * ah * crop_height);
if (drp_anamorphic.SelectedIndex == 3)
new_width = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_width);
else
new_width = getModulusAuto(16, new_width);
//16 * (421 / 16)
//double z = ( 16 * (( y + 8 ) / 16 ) );
int x = int.Parse(new_width.ToString());
return x;
}
return 0;
}
// Calculate Resolution for Anamorphic functions
private string strictAnamorphic()
{
// TODO Make sure cropping is Mod2
if (selectedTitle != null)
{
// Calculate the Actual Height
int actualWidth = (int)text_width.Value - (int)crop_left.Value - (int)crop_right.Value; ;
int actualHeight = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
// Calculate Actual Width
double displayWidth = ((double)actualWidth * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height);
return Math.Round(displayWidth, 0) + "x" + actualHeight;
}
return "Select a Title";
}
private string looseAnamorphic()
{
if (selectedTitle != null)
{
// Get some values
int actualWidth = (int)text_width.Value - (int)crop_left.Value - (int)crop_right.Value;
int source_display_width = selectedTitle.Resolution.Width * selectedTitle.ParVal.Width / selectedTitle.ParVal.Height;
int source_cropped_height = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
// Calculate storage Aspect and cache it for reuse
if (storageAspect == 0)
storageAspect = (double)actualWidth / source_cropped_height;
// Calculate the new height based on the input cropped width
double hcalc = (actualWidth / storageAspect) + 0.5;
double newHeight = getModulusAuto(16, hcalc);
looseAnamorphicHeightGuard = true;
if (newHeight < 64)
newHeight = 64;
text_height.Value = (decimal)newHeight; // BUG Out of Range Exception with Width too low here.
// Calculate the anamorphic width
double parW = newHeight * source_display_width / source_cropped_height;
double parH = actualWidth;
double displayWidth = (actualWidth * parW / parH);
// Now correct DisplayWidth to maintain Aspect ratio. ActualHeight was mod16'd and thus AR is slightly different than the worked out displayWidths
return Math.Truncate(displayWidth) + "x" + newHeight;
}
return "Select a Title";
}
// GUI
private void disableCustomAnaControls()
{
// Disable Custom Anamorphic Stuff
lbl_modulus.Visible = false;
lbl_displayWidth.Visible = false;
lbl_parWidth.Visible = false;
lbl_parHeight.Visible = false;
drop_modulus.Visible = false;
txt_displayWidth.Visible = false;
txt_parWidth.Visible = false;
txt_parHeight.Visible = false;
check_KeepAR.Enabled = false;
}
private void enableCustomAnaControls()
{
// Disable Custom Anamorphic Stuff
lbl_modulus.Visible = true;
lbl_displayWidth.Visible = true;
lbl_parWidth.Visible = true;
lbl_parHeight.Visible = true;
drop_modulus.Visible = true;
txt_displayWidth.Visible = true;
txt_parWidth.Visible = true;
txt_parHeight.Visible = true;
check_KeepAR.Enabled = true;
}
}
}
|