Example #1
0
        private void gridASS_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            switch (e.ColumnIndex)
            {
                case 1:
                    //MessageBox.Show(script.GetLines()[e.RowIndex].ToString());
                    string presx = script.GetHeader().GetHeaderValue("PlayResX");
                    string presy = script.GetHeader().GetHeaderValue("PlayResY");

                    int py = -1, px = -1;

                    if (presx.Equals(string.Empty) && presy.Equals(string.Empty)) return;
                    if (presx.Equals(string.Empty))
                    {
                        py = int.Parse(presy);
                        px = ((py * 4) / 3);
                    }
                    else if (presy.Equals(string.Empty))
                    {
                        px = int.Parse(presx);
                        py = ((px * 3) / 4);
                    }
                    else
                    {
                        px = int.Parse(presx);
                        py = int.Parse(presy);
                    }

                    try
                    {
                        AviSynthScriptEnvironment env = new AviSynthScriptEnvironment();
                        string script0rz = "blankclip(color=$000000,width=" + px + ",height=" + py + ")";
                        AviSynthClip avs = env.ParseScript(script0rz);

                        string vsf_path = AviSynthFunctions.getVSFilterPath(avs);
                        if (vsf_path != null)
                            avs.AviSynthInvoke(avs.GetAVS(), 0, "LoadPlugin", false, vsf_path);

                        // escribir ssa temporal

                        string PreviewFile = "PrevFile-l" + e.RowIndex + ".ass";

                        lineaASS actual = (lineaASS)script.GetLineArrayList().GetFullArrayList()[e.RowIndex];

                        TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
                        o.WriteLine(headerMark);
                        o.WriteLine(script.GetHeader().ToString());

                        o.WriteLine(stylesMark);
                        foreach (estiloV4 e2 in script.GetStyles())
                        {
                            if (e2.Name.Equals(actual.estilo))
                            {
                                estiloV4 new_est = new estiloV4(e2.ToString());
                                new_est.PrimaryColor = "&H00FFFFFF";
                                new_est.SecondaryColor = "&H00FFFFFF";
                                new_est.OutlineColor = "&H00FFFFFF";
                                new_est.ShadowColor = "&H00FFFFFF";
                                o.WriteLine(new_est.ToString().Replace("\n", string.Empty));
                            }
                        }

                        o.WriteLine(); // ---

                        o.WriteLine(dialoguesMark);

                        actual.t_inicial.setTiempo(0);
                        actual.t_final.setTiempo(50);
                        o.WriteLine(actual.ToString());

                        o.Close();

                        avs.AviSynthInvoke(avs.GetAVS(), 0, "Eval", false, script0rz);
                        avs.AviSynthInvoke(avs.GetAVS(), 0, "TextSub", true, PreviewFile);
                        //LinePreviewBox.Image = (Image)AviSynthFunctions.getBitmapFromFrame(avs, 0, 0);
                        avs.cleanup(true);

                        File.Delete(PreviewFile);
                        //b = BitmapFunctions.Crop(b, 640, 480, 0, 376);
                    }
                    catch
                    {
                        errorMsg("Error cargando AviSynth.");
                    }

                    break;
            }
        }
Example #2
0
        private void makeTempFile()
        {
            TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
            o.WriteLine(mW.headerMark);
            o.WriteLine("PlayResY: " + textPlayResY.Text);
            o.WriteLine();
            o.WriteLine(mW.stylesMark);
            estiloV4 e = (estiloV4)mW.v4[listBox1.SelectedIndex];
            estiloV4 e2 = new estiloV4(e.ToString());

            switch (e.Alignment)
            {
                case 4:
                case 7:
                    e2.Alignment = 1;
                    break;
                case 5:
                case 8:
                    e2.Alignment = 2;
                    break;
                case 6:
                case 9:
                    e2.Alignment = 3;
                    break;
                default:
                    e2.Alignment = e.Alignment;
                    break;
            }

            o.WriteLine(e2.ToString());
            o.WriteLine();
            o.WriteLine(mW.dialoguesMark);
            lineaASS l = new lineaASS();
            if (checkBox2.Checked)
                l.texto = "{\\be1}"+previewText.Text;
            else l.texto = previewText.Text;
            l.estilo = e.Name;
            l.t_final.setTiempo(50);
            o.WriteLine(l.ToString());
            o.Close();
        }
Example #3
0
        private int CalcularLineas(AviSynthClip avs, string PreviewFile, lineaASS actual)
        {
            int nLineas;

            //lineaASS actual = (lineaASS)lass.Clone();

            TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
            o.WriteLine(headerMark);
            o.WriteLine(script.GetHeader().ToString());

            o.WriteLine(stylesMark);
            foreach (estiloV4 e2 in script.GetStyles())
            {
                if (e2.Name.Equals(actual.estilo))
                {
                    estiloV4 new_est = new estiloV4(e2.ToString());
                    new_est.PrimaryColor = "&H00FFFFFF";
                    new_est.SecondaryColor = "&H00FFFFFF";
                    new_est.OutlineColor = "&H00FFFFFF";
                    new_est.ShadowColor = "&H00FFFFFF";
                    o.WriteLine(new_est.ToString().Replace("\n", string.Empty));
                }
            }

            o.WriteLine(); // ---

            o.WriteLine(dialoguesMark);

            actual.t_inicial.setTiempo(0);
            actual.t_final.setTiempo(50);
            o.WriteLine(actual.ToString());

            o.Close();

            avs.AviSynthInvoke(avs.GetAVS(), 0, "Eval", false, "blankclip(color=$000000,width=" + width + ",height=" + height + ")");
            avs.AviSynthInvoke(avs.GetAVS(), 0, "TextSub", true, PreviewFile);

            Image iimg = (Image)AviSynthFunctions.getBitmapFromFrame(avs, 0, 0);

            int x,y,x2,y2;

            nLineas = ContarLineas(iimg, out x, out y, out x2, out y2);

            iimg.Dispose();

            File.Delete(PreviewFile);
            return nLineas;
        }