当前位置: 首页>>代码示例>>C#>>正文


C# NikseBitmap.CropTop方法代码示例

本文整理汇总了C#中Nikse.SubtitleEdit.Logic.NikseBitmap.CropTop方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.CropTop方法的具体用法?C# NikseBitmap.CropTop怎么用?C# NikseBitmap.CropTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nikse.SubtitleEdit.Logic.NikseBitmap的用法示例。


在下文中一共展示了NikseBitmap.CropTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateImageFromTextWithStyleInner


//.........这里部分代码省略.........
                        TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
                        isItalic = false;
                        i += 3;
                    }
                    else if (text.Substring(i).ToLower().StartsWith("<b>"))
                    {
                        if (sb.ToString().Trim().Length > 0)
                        {
                            lastText.Append(sb);
                            TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
                        }
                        isBold = true;
                        i += 2;
                    }
                    else if (text.Substring(i).ToLower().StartsWith("</b>") && isBold)
                    {
                        if (lastText.ToString().EndsWith(" ") && !sb.ToString().StartsWith(" "))
                        {
                            string t = sb.ToString();
                            sb = new StringBuilder();
                            sb.Append(" " + t);
                        }
                        lastText.Append(sb);
                        TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
                        isBold = false;
                        i += 3;
                    }
                    else if (text.Substring(i).StartsWith(Environment.NewLine))
                    {
                        lastText.Append(sb);
                        TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);

                        top += lineHeight;
                        newLine = true;
                        i += Environment.NewLine.Length - 1;
                        lineNumber++;
                        if (lineNumber < lefts.Count)
                        {
                            leftMargin = lefts[lineNumber];
                            left = leftMargin;
                        }
                    }
                    else
                    {
                        sb.Append(text.Substring(i, 1));
                    }
                    i++;
                }
                if (sb.Length > 0)
                    TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);

                DrawShadowAndPAth(parameter, g, path);
                g.FillPath(new SolidBrush(c), path);
            }
            g.Dispose();
            sf.Dispose();

            var nbmp = new NikseBitmap(bmp);
            if (parameter.BackgroundColor == Color.Transparent)
            {
                nbmp.CropTransparentSidesAndBottom(baseLinePadding, true);
                nbmp.CropTransparentSidesAndBottom(2, false);
            }
            else
            {
                nbmp.CropSidesAndBottom(4, parameter.BackgroundColor, true);
                nbmp.CropTop(4, parameter.BackgroundColor);
            }

            if (nbmp.Width > parameter.ScreenWidth)
            {
                parameter.Error = "#" + parameter.P.Number.ToString(CultureInfo.InvariantCulture) + ": " + nbmp.Width.ToString(CultureInfo.InvariantCulture) + " > " + parameter.ScreenWidth.ToString(CultureInfo.InvariantCulture);
            }

            if (parameter.Type3D == 1) // Half-side-by-side 3D
            {
                Bitmap singleBmp = nbmp.GetBitmap();
                Bitmap singleHalfBmp = ScaleToHalfWidth(singleBmp);
                singleBmp.Dispose();
                Bitmap sideBySideBmp = new Bitmap(parameter.ScreenWidth, singleHalfBmp.Height);
                int singleWidth = parameter.ScreenWidth / 2;
                int singleLeftMargin = (singleWidth - singleHalfBmp.Width) / 2;

                using (Graphics gSideBySide = Graphics.FromImage(sideBySideBmp))
                {
                    gSideBySide.DrawImage(singleHalfBmp, singleLeftMargin + parameter.Depth3D, 0);
                    gSideBySide.DrawImage(singleHalfBmp, singleWidth + singleLeftMargin - parameter.Depth3D, 0);
                }
                nbmp = new NikseBitmap(sideBySideBmp);
                if (parameter.BackgroundColor == Color.Transparent)
                    nbmp.CropTransparentSidesAndBottom(2, true);
                else
                    nbmp.CropSidesAndBottom(4, parameter.BackgroundColor, true);
            }
            else if (parameter.Type3D == 2) // Half-Top/Bottom 3D
            {
                nbmp = Make3DTopBottom(parameter, nbmp);
            }
            return nbmp.GetBitmap();
        }
开发者ID:nguansak,项目名称:subtitleedit,代码行数:101,代码来源:ExportPngXml.cs

示例2: Make3DTopBottom

        private static NikseBitmap Make3DTopBottom(MakeBitmapParameter parameter, NikseBitmap nbmp)
        {
            Bitmap singleBmp = nbmp.GetBitmap();
            Bitmap singleHalfBmp = ScaleToHalfHeight(singleBmp);
            singleBmp.Dispose();
            Bitmap topBottomBmp = new Bitmap(parameter.ScreenWidth, parameter.ScreenHeight - parameter.BottomMargin);
            int singleHeight = parameter.ScreenHeight / 2;
            int leftM = (parameter.ScreenWidth / 2) - (singleHalfBmp.Width / 2);

            using (Graphics gTopBottom = Graphics.FromImage(topBottomBmp))
            {
                gTopBottom.DrawImage(singleHalfBmp, leftM + parameter.Depth3D, singleHeight - singleHalfBmp.Height - parameter.BottomMargin);
                gTopBottom.DrawImage(singleHalfBmp, leftM - parameter.Depth3D, parameter.ScreenHeight - parameter.BottomMargin - singleHalfBmp.Height);
            }
            nbmp = new NikseBitmap(topBottomBmp);
            if (parameter.BackgroundColor == Color.Transparent)
            {
                nbmp.CropTop(2, Color.Transparent);
                nbmp.CropTransparentSidesAndBottom(2, false);
            }
            else
            {
                nbmp.CropTop(4, parameter.BackgroundColor);
                nbmp.CropSidesAndBottom(4, parameter.BackgroundColor, false);
            }
            return nbmp;
        }
开发者ID:nguansak,项目名称:subtitleedit,代码行数:27,代码来源:ExportPngXml.cs


注:本文中的Nikse.SubtitleEdit.Logic.NikseBitmap.CropTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。