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


C# GraphicsPath.AddRoundedRectangleProper方法代码示例

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


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

示例1: DrawRoundedRectangle

 public static void DrawRoundedRectangle(this Graphics g, Brush brush, Pen pen, Rectangle rect, float radius)
 {
     using (GraphicsPath gp = new GraphicsPath())
     {
         gp.AddRoundedRectangleProper(rect, radius);
         if (brush != null) g.FillPath(brush, gp);
         if (pen != null) g.DrawPath(pen, gp);
     }
 }
开发者ID:Rapti,项目名称:ShareX,代码行数:9,代码来源:GraphicsExtensions.cs

示例2: RoundedCorners

        public static Image RoundedCorners(Image img, int cornerRadius)
        {
            Bitmap bmp = img.CreateEmptyBitmap();

            using (Graphics g = Graphics.FromImage(bmp))
            using (img)
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;

                using (GraphicsPath gp = new GraphicsPath())
                {
                    gp.AddRoundedRectangleProper(new RectangleF(0, 0, img.Width, img.Height), cornerRadius);

                    using (TextureBrush brush = new TextureBrush(img))
                    {
                        g.FillPath(brush, gp);
                    }
                }
            }

            return bmp;
        }
开发者ID:ElectronicWar,项目名称:ShareX,代码行数:23,代码来源:ImageHelpers.cs

示例3: Apply

        public override Image Apply(Image img)
        {
            if (string.IsNullOrEmpty(Text))
            {
                return img;
            }

            using (Font textFont = TextFont)
            {
                if (textFont == null || textFont.Size < 1)
                {
                    return img;
                }

                NameParser parser = new NameParser(NameParserType.Text);

                if (img != null)
                {
                    parser.ImageWidth = img.Width;
                    parser.ImageHeight = img.Height;
                }

                string parsedText = parser.Parse(Text);

                Size textSize = Helpers.MeasureText(parsedText, textFont);
                Size watermarkSize = new Size(textSize.Width + BackgroundPadding * 2, textSize.Height + BackgroundPadding * 2);
                Point watermarkPosition = Helpers.GetPosition(Placement, Offset, img.Size, watermarkSize);
                Rectangle watermarkRectangle = new Rectangle(watermarkPosition, watermarkSize);

                if (AutoHide && !new Rectangle(0, 0, img.Width, img.Height).Contains(watermarkRectangle))
                {
                    return img;
                }

                using (Graphics g = Graphics.FromImage(img))
                {
                    g.SetHighQuality();

                    using (GraphicsPath gp = new GraphicsPath())
                    {
                        gp.AddRoundedRectangleProper(watermarkRectangle, CornerRadius);

                        if (DrawBackground)
                        {
                            Brush backgroundBrush = null;

                            try
                            {
                                if (UseGradient)
                                {
                                    if (UseCustomGradient && Gradient != null && Gradient.IsValid)
                                    {
                                        backgroundBrush = new LinearGradientBrush(watermarkRectangle, Color.Transparent, Color.Transparent, Gradient.Type);
                                        ColorBlend colorBlend = new ColorBlend();
                                        IEnumerable<GradientStop> gradient = Gradient.Colors.OrderBy(x => x.Location);
                                        colorBlend.Colors = gradient.Select(x => x.Color).ToArray();
                                        colorBlend.Positions = gradient.Select(x => x.Location / 100).ToArray();
                                        ((LinearGradientBrush)backgroundBrush).InterpolationColors = colorBlend;
                                    }
                                    else
                                    {
                                        backgroundBrush = new LinearGradientBrush(watermarkRectangle, BackgroundColor, BackgroundColor2, GradientType);
                                    }
                                }
                                else
                                {
                                    backgroundBrush = new SolidBrush(BackgroundColor);
                                }

                                g.FillPath(backgroundBrush, gp);
                            }
                            finally
                            {
                                if (backgroundBrush != null) backgroundBrush.Dispose();
                            }
                        }

                        if (DrawBorder)
                        {
                            using (Pen borderPen = new Pen(BorderColor))
                            {
                                g.DrawPath(borderPen, gp);
                            }
                        }
                    }

                    using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
                    {
                        float centerX = watermarkRectangle.Width / 2f;
                        float centerY = watermarkRectangle.Height / 2f;

                        if (DrawTextShadow)
                        {
                            using (Brush textShadowBrush = new SolidBrush(TextShadowColor))
                            {
                                g.DrawString(parsedText, textFont, textShadowBrush, watermarkRectangle.X + centerX + TextShadowOffset.X, watermarkRectangle.Y + centerY + TextShadowOffset.Y, sf);
                            }
                        }

                        using (Brush textBrush = new SolidBrush(TextColor))
//.........这里部分代码省略.........
开发者ID:Rapti,项目名称:ShareX,代码行数:101,代码来源:DrawText.cs


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