private void PopulateMaskBitmask(OFXEffect fx) { string[] paramNames = { "Enable_0", "Enable_1", "Enable_2", "Enable_3", "Enable_4" }; for (int i = 0; i < paramNames.Length; ++i) { int BITMASK_NUMBER = (int)Math.Pow(2, i); OFXBooleanParameter param = fx.FindParameterByName(paramNames[i]) as OFXBooleanParameter; if (param.Value) { MASK_BITMASK += BITMASK_NUMBER; } } }
Take GenerateTakeText(Vegas vegas, string text) { if (text.Length == 0) { return(null); } // テキストを順次追加 PlugInNode plugin = vegas.Generators.GetChildByName("VEGAS タイトルおよびテキスト"); // 日本語版だとプラグイン名はこれです。英語版は不明 Media media = new Media(plugin); // これちょっと遅いです if (media.Generator == null) { return(null); } if (!media.Generator.IsOFX) { return(null); } // Text属性を得る。 // 全属性を見たい場合はウォッチのOfxEffect.Parameters.Results Viewを見るとある。(多分21個) OFXEffect ofxEffect = media.Generator.OFXEffect; OFXStringParameter textParam = (OFXStringParameter)ofxEffect.FindParameterByName("Text"); if (textParam == null) { return(null); } // テキストをセット RichTextBox richtextBox1 = new RichTextBox(); richtextBox1.Text = text; richtextBox1.SelectAll(); // 全テキストが対象 richtextBox1.SelectionFont = new System.Drawing.Font(_fontFamily, _fontSize); // フォント変更 //richtextBox.SaveFile(file); // debug. フォントが変わったか確認してみよう // OFXEffectの"Text" Parameterに対して再登録する System.Xml.XmlDocument textValDoc = new System.Xml.XmlDocument(); textValDoc.LoadXml("<OfxParamValue>" + textParam.Value + "</OfxParamValue>"); System.Xml.XmlNode textPValue = textValDoc.FirstChild; textPValue.InnerText = richtextBox1.Rtf; // your new rtf words. textParam.Value = textPValue.InnerText; textParam.ParameterChanged(); // Apply changed. // これらはTextが見つかれば絶対全部見つかるからnullチェックしない OFXRGBAParameter textColorParam = (OFXRGBAParameter)ofxEffect.FindParameterByName("TextColor"); OFXDouble2DParameter locationParam = (OFXDouble2DParameter)ofxEffect.FindParameterByName("Location"); OFXChoiceParameter alignmentParam = (OFXChoiceParameter)ofxEffect.FindParameterByName("Alignment"); OFXDoubleParameter outlineWidthParam = (OFXDoubleParameter)ofxEffect.FindParameterByName("OutlineWidth"); OFXRGBAParameter outlineColorParam = (OFXRGBAParameter)ofxEffect.FindParameterByName("OutlineColor"); OFXBooleanParameter shadowEnableParam = (OFXBooleanParameter)ofxEffect.FindParameterByName("ShadowEnable"); //OFXStringParameter shadowColorParam = (OFXStringParameter)ofxEffect.FindParameterByName("ShadowColor"); // パラメータセット // // TextColor textColorParam.Value = _fontColor;// new OFXColor(50.0f / 255.0, 100.0f / 255.0f, 150.0f / 255.0f); // Alignment // alignmentParam.Choiesを確認すること // OFXChoiceはReadOnly型なのでなにもできません alignmentParam.Value = alignmentParam.Choices[_Align]; //alignmentParam.Choices[7]; //Location OFXDouble2D loc; loc.X = _locationX; loc.Y = _locationY; locationParam.Value = loc; // Outline outlineWidthParam.Value = _outlineWidth; outlineColorParam.Value = _outlineColor;// new OFXColor(10 / 255.0, 10 / 255.0f, 10 / 255.0f); MediaStream stream = media.Streams[0]; //VideoEvent videoEvent = new VideoEvent(Timecode.FromSeconds(_currentTime), Timecode.FromSeconds(_timeLength)); //track.Events.Add(videoEvent); Take take = new Take(stream); //videoEvent.Takes.Add(take); //_currentTime += _timeLength; return(take); }