當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。