示例#1
0
        public Style ScaleStyle(Style s)
        {
            //No need to scale 1:1
            if (scalefactorx==1.0 && scalefactory==1.0) return s;

            s.fontSize *= (float)scalefactory;
            s.shadowDepth *= scalefactory;
            s.outlineWidth *= scalefactory;
            s.margint = Convert.ToInt32(Math.Round(s.margint * scalefactory, 0), Util.nfi);
            s.marginb = Convert.ToInt32(Math.Round(s.marginb * scalefactory, 0), Util.nfi);
            s.marginl = Convert.ToInt32(Math.Round(s.marginl * scalefactorx, 0), Util.nfi);
            s.marginr = Convert.ToInt32(Math.Round(s.marginr * scalefactorx, 0), Util.nfi);
            return s;
        }
示例#2
0
文件: Style.cs 项目: Aegisub/SSATool
        public static Style ParseStyle(string inStr, int scriptVer)
        {
            int startpos = inStr.IndexOf(':')+1;
            string[] xInfo = inStr.Substring(startpos,inStr.Length-startpos).TrimStart().Split(",".ToCharArray());
            Style style = new Style();
            int index;
            uint alpha = (scriptVer != 4 ? 0 : (Util.ReadColor(xInfo[16]) << 24));
            style.name = xInfo[0];
            style.fontName = xInfo[1];
            style.fontSize = float.Parse(xInfo[2]);
            style.colors[0] = Util.uintToColor(Util.ReadColor(xInfo[3])+alpha);
            style.colors[1] = Util.uintToColor(Util.ReadColor(xInfo[4])+alpha);
            style.colors[2] = Util.uintToColor(Util.ReadColor(xInfo[5])+alpha);
            style.colors[3] = Util.uintToColor(Util.ReadColor(xInfo[6])+alpha);
            style.fBold = !String.Equals(xInfo[7], "0", StringComparison.Ordinal);
            style.fItalic = !String.Equals(xInfo[index=8], "0", StringComparison.Ordinal);
            if (scriptVer >= 5) {
                style.fUnderline = !String.Equals(xInfo[++index], "0", StringComparison.Ordinal);
                style.fStrikeOut = !String.Equals(xInfo[++index], "0", StringComparison.Ordinal);
                style.fontScaleX = double.Parse(xInfo[++index]);
                style.fontScaleY = double.Parse(xInfo[++index]);
                style.fontSpacing = double.Parse(xInfo[++index]);
                style.fontAngleZ = double.Parse(xInfo[++index]);
            }
            style.borderStyle = int.Parse(xInfo[++index]);
            style.outlineWidth = double.Parse(xInfo[++index]);
            style.shadowDepth = double.Parse(xInfo[++index]);
            style.scrAlignment = int.Parse(xInfo[++index]);
            style.marginl = int.Parse(xInfo[++index]);
            style.marginr = int.Parse(xInfo[++index]);
            style.margint = int.Parse(xInfo[++index]);
            if (scriptVer >= 6) style.marginb = int.Parse(xInfo[++index]);
            if (scriptVer == 4) index++; //alphaLevel is in v4 only and is taken care of at the top (uint alpha), so just advance the index
            style.charset = int.Parse(xInfo[++index]);
            if (scriptVer >= 6) style.relativeTo = byte.Parse(xInfo[++index]);

            //Following is code from VSFilter, but since we're not interpreting this, merely spitting it back out the way it came in, we don't currently need it
            //if (sver <= 4) style.scrAlignment = ((style.scrAlignment & 4) == 1) ? ((style.scrAlignment & 3) + 6) // top
            //                   : ((style.scrAlignment & 8) == 1) ? ((style.scrAlignment & 3) + 3) // mid
            //                   : (style.scrAlignment & 3); // bottom

            return style;
        }