public void TestResampleOverridePositionTags3() { var result = AssaResampler.ResampleOverrideTagsPosition(100, 200, 100, 200, "{\\pos(10.111,20.222)\\pos(20.333,30.444)}Hallo!"); Assert.AreEqual("{\\pos(20.2,40.4)\\pos(40.7,60.9)}Hallo!", result); }
public void TestResampleOverrideDrawingTags1() { var result = AssaResampler.ResampleOverrideTagsDrawing(100, 200, 100, 200, "{\\p1}m 0 0 l 100 0 100 100 0 100{\\p0}"); Assert.AreEqual("{\\p1}m 0 0 l 200 0 200 200 0 200{\\p0}", result); }
public void TestResampleOverridePositionTags1() { var result = AssaResampler.ResampleOverrideTagsPosition(100, 200, 100, 200, "{\\pos(10,20)}Hallo!"); Assert.AreEqual("{\\pos(20,40)}Hallo!", result); }
public void TestResampleOverridePositionTags2Negative() { var result = AssaResampler.ResampleOverrideTagsPosition(100, 200, 100, 200, "{\\pos(-10,20)\\pos(20,-30)}Hallo!"); Assert.AreEqual("{\\pos(-20,40)\\pos(40,-60)}Hallo!", result); }
public void TestResampleOverrideFontTags5() { var result = AssaResampler.ResampleOverrideTagsFont(1280, 1920, 720, 1080, "{\\blur0.667}Hallo!"); Assert.AreEqual("{\\blur1}Hallo!", result); }
public void TestResampleOverrideFontTags6DoNotChange() { var result = AssaResampler.ResampleOverrideTagsFont(100, 200, 100, 200, "{\\fscx110\\fscy138}Hallo!"); Assert.AreEqual("{\\fscx110\\fscy138}Hallo!", result); }
public void TestResampleOverrideFontTags4() { var result = AssaResampler.ResampleOverrideTagsFont(100, 200, 100, 200, "{\\blur1.111}Hallo!"); Assert.AreEqual("{\\blur2.2}Hallo!", result); }
public void TestResampleOverrideFontTags3() { var result = AssaResampler.ResampleOverrideTagsFont(100, 200, 100, 200, "{\\fs10\\fs20\\fs30}Hallo!"); Assert.AreEqual("{\\fs20\\fs40\\fs60}Hallo!", result); }
public void TestResampleOverrideDrawingTags5() { var result = AssaResampler.ResampleOverrideTagsDrawing(100, 200, 100, 200, "{\\an7\\p1}m 0 0 l 100 0 100 100 0 100{\\p0}" + Environment.NewLine + "{\\iclip(m 0 0 l 100 0 100 100 0 100)}"); Assert.AreEqual("{\\an7\\p1}m 0 0 l 200 0 200 200 0 200{\\p0}" + Environment.NewLine + "{\\iclip(m 0 0 l 200 0 200 200 0 200)}", result); }
public void TestResampleOverrideDrawingTags4() { var result = AssaResampler.ResampleOverrideTagsDrawing(100, 200, 100, 200, "{\\p1\\an7}m 0 0 l 100.1 0.2 100 100 0 100"); Assert.AreEqual("{\\p1\\an7}m 0 0 l 200.2 0.4 200 200 0 200", result); }
private void buttonOK_Click(object sender, EventArgs e) { if (!checkBoxMargins.Checked && !checkBoxFontSize.Checked && !checkBoxPosition.Checked && !checkBoxDrawing.Checked) { return; } if (string.IsNullOrEmpty(_subtitle.Header)) { _subtitle.Header = AdvancedSubStationAlpha.DefaultHeader; } var sourceWidth = numericUpDownSourceWidth.Value; var sourceHeight = numericUpDownSourceHeight.Value; var targetWidth = numericUpDownTargetWidth.Value; var targetHeight = numericUpDownTargetHeight.Value; if (sourceWidth == 0 || sourceHeight == 0 || targetWidth == 0 || targetHeight == 0) { MessageBox.Show("Video width/height cannot be zero"); return; } if (sourceWidth == targetWidth && sourceHeight == targetHeight) { MessageBox.Show("Source and target resolution is the same - nothing to do."); return; } var fixMargins = checkBoxMargins.Checked; var fixFonts = checkBoxFontSize.Checked; var fixPos = checkBoxPosition.Checked; var fixDraw = checkBoxDrawing.Checked; var styles = AdvancedSubStationAlpha.GetSsaStylesFromHeader(_subtitle.Header); foreach (var style in styles) { if (fixMargins) { style.MarginLeft = AssaResampler.Resample(sourceWidth, targetWidth, style.MarginLeft); style.MarginRight = AssaResampler.Resample(sourceWidth, targetWidth, style.MarginRight); style.MarginVertical = AssaResampler.Resample(sourceHeight, targetHeight, style.MarginVertical); } if (fixFonts) { style.FontSize = AssaResampler.Resample(sourceHeight, targetHeight, style.FontSize); } if (fixFonts || fixDraw) { style.OutlineWidth = (decimal)AssaResampler.Resample(sourceHeight, targetHeight, (float)style.OutlineWidth); style.ShadowWidth = (decimal)AssaResampler.Resample(sourceHeight, targetHeight, (float)style.ShadowWidth); style.Spacing = (decimal)AssaResampler.Resample(sourceWidth, targetWidth, (float)style.Spacing); } } _subtitle.Header = AdvancedSubStationAlpha.GetHeaderAndStylesFromAdvancedSubStationAlpha(_subtitle.Header, styles); _subtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + targetWidth.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitle.Header); _subtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + targetHeight.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitle.Header); foreach (var p in _subtitle.Paragraphs) { if (fixFonts) { p.Text = AssaResampler.ResampleOverrideTagsFont(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text); } if (fixPos) { p.Text = AssaResampler.ResampleOverrideTagsPosition(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text); } if (fixDraw) { p.Text = AssaResampler.ResampleOverrideTagsDrawing(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text, null); } } DialogResult = DialogResult.OK; }