• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Drawing2D.PathGradientBrush类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PathGradientBrush类属于System.Drawing.Drawing2D命名空间,在下文中一共展示了PathGradientBrush类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RenderEllipseGlass

        public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position,
            float positionFactor, Color glassColor, int alphaCenter, int alphaSurround)
        {
            if (!(positionFactor > 0 && positionFactor < 1))
                throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ",
                    "positionFactor");

            ownerRect.Height--;
            ownerRect.Width--;

            if (ownerRect.Width < 1 || ownerRect.Height < 1)
                return;

            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddEllipse(ownerRect);
                using (PathGradientBrush pb = new PathGradientBrush(gp))
                {
                    pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor);
                    pb.CenterColor = Color.FromArgb(alphaCenter, glassColor);
                    pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) };
                    using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias))
                    {
                        g.FillPath(pb, gp);
                    }
                }
            }
        }
开发者ID:webxiaohua,项目名称:SmartControls,代码行数:28,代码来源:GlassPainter.cs


示例2: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                // Создаем траекторию
                GraphicsPath path = new GraphicsPath();
                Rectangle rect = new Rectangle(20, 20, 150, 150);
                path.AddRectangle(rect);
                // Создаем градиентную кисть
                PathGradientBrush pgBrush =
                    new PathGradientBrush(path.PathPoints);
                // Уснинавливаем цвета кисти
                pgBrush.CenterColor = Color.Red;
                pgBrush.SurroundColors = new Color[] { Color.Blue };
                // Создаем объект Matrix
                Matrix X = new Matrix();
                // Translate
                X.Translate(30.0f, 10.0f, MatrixOrder.Append);
                // Rotate
                X.Rotate(10.0f, MatrixOrder.Append);
                // Scale
                X.Scale(1.2f, 1.0f, MatrixOrder.Append);
                // Shear
                X.Shear(.2f, 0.03f, MatrixOrder.Prepend);
                // Применяем преобразование к траектории и кисти
                path.Transform(X);
                pgBrush.Transform = X;
                // Выполняем визуализацию
                g.FillPath(pgBrush, path);
            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:32,代码来源:Form1.cs


示例3: Paint

 public void Paint(PaintEventArgs e)
 {
     Graphics g = e.Graphics;
     rect = new Rectangle(x, y, width, height);
     Point[] pt =
     {
         new Point(rect.X,rect.Y),
         new Point(rect.X+rect.Width,rect.Y),
         new Point(rect.X+rect.Width,rect.Y+rect.Height),
         new Point(rect.X,rect.Y+rect.Height)
     };
     PathGradientBrush pth = new PathGradientBrush(pt);
     pth.SurroundColors = new Color[]
     {
         Color.FromArgb(10,R,G,B)
     };
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X + rect.Width / 10, rect.Y), new Point(rect.X + rect.Width / 10, rect.Y + rect.Height));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X, rect.Y), new Point(rect.X + (rect.Width / 10), rect.Y));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X + (rect.Width - rect.Width / 10), rect.Y), new Point(rect.X + rect.Width, rect.Y));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X + (rect.Width - rect.Width / 10), rect.Y), new Point(rect.X + (rect.Width - rect.Width / 10), rect.Y + rect.Height));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X + rect.Width / 3, rect.Y + 3), new Point(rect.X + rect.Width / 3, rect.Y + rect.Height));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X + (rect.Width / 3) * 2, rect.Y + 3), new Point(rect.X + (rect.Width / 3) * 2, rect.Y + rect.Height));
     g.DrawLine(new Pen(Color.FromArgb(255, R, G, B), 2), new Point(rect.X + rect.Width, rect.Y), new Point(rect.X + rect.Width, rect.Y + rect.Height));
     pth.CenterColor = Color.FromArgb(A, R, G, B);
     g.FillRectangle(pth, rect);
 }
开发者ID:veranyan,项目名称:Arcanoid_Game,代码行数:27,代码来源:Paddle.cs


示例4: OnPaintBackground

        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            base.OnPaintBackground(pevent);
            pevent.Graphics.Clear(Color.FromArgb(0));

            foreach (TabPage tab in this.TabPages)
            {
                Rectangle tabRect = GetTabRect(this.TabPages.IndexOf(tab));

                using (StringFormat sf = new StringFormat(StringFormatFlags.NoWrap))
                {
                    sf.Alignment = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    SizeF textSize = pevent.Graphics.MeasureString(tab.Text, this.Font);
                    RectangleF rc = new RectangleF(tabRect.Left + ((tabRect.Width / 2) - (textSize.Width / 2)), tabRect.Top + tabRect.Height / 2 - textSize.Height / 2, textSize.Width, textSize.Height);
                    rc.Inflate(4, 5);

                    GraphicsPath path = new GraphicsPath();
                    path.AddRectangle(rc);

                    using (PathGradientBrush brush = new PathGradientBrush(path))
                    {
                        brush.CenterColor = Color.FromArgb(192, tab == this.SelectedTab ? Color.Red : Color.Black);
                        brush.SurroundColors = new Color[] { Color.Black };
                        pevent.Graphics.FillRectangle(brush,rc);
                    }

                    var tc = new SolidBrush(Color.FromArgb(tab.ForeColor.A, tab.ForeColor.R, tab.ForeColor.G, tab.ForeColor.B));

                    pevent.Graphics.DrawString(tab.Text, this.Font, tc, rc, sf);

                }
            }
        }
开发者ID:liuxingghost,项目名称:MTK-FirmwareAdapter-Tool,代码行数:34,代码来源:GlassTabControl.cs


示例5: DrawBreakpoint

    /// <summary>
    /// Draws a breakpoint icon in the margin.
    /// </summary>
    /// <param name="g">The <see cref="Graphics"/> context.</param>
    /// <param name="rectangle">The bounding rectangle.</param>
    /// <param name="isEnabled"><c>true</c> if enabled..</param>
    /// <param name="willBeHit"><c>true</c> if it will be hit.</param>
    public static void DrawBreakpoint(Graphics g, Rectangle rectangle, bool isEnabled, bool willBeHit)
    {
      int diameter = Math.Min(rectangle.Width - 4, rectangle.Height);
      Rectangle rect = new Rectangle(2, rectangle.Y + (rectangle.Height - diameter) / 2, diameter, diameter);

      using (GraphicsPath path = new GraphicsPath())
      {
        path.AddEllipse(rect);
        using (PathGradientBrush pthGrBrush = new PathGradientBrush(path))
        {
          pthGrBrush.CenterPoint = new PointF(rect.Left + rect.Width / 3, rect.Top + rect.Height / 3);
          pthGrBrush.CenterColor = Color.MistyRose;
          Color[] colors = { willBeHit ? Color.Firebrick : Color.Olive };
          pthGrBrush.SurroundColors = colors;

          if (isEnabled)
          {
            g.FillEllipse(pthGrBrush, rect);
          }
          else
          {
            g.FillEllipse(SystemBrushes.Control, rect);
            using (Pen pen = new Pen(pthGrBrush))
            {
              g.DrawEllipse(pen, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2));
            }
          }
        }
      }
    }
开发者ID:Finarch,项目名称:DigitalRune.Windows.TextEditor,代码行数:37,代码来源:BookmarkRenderer.cs


示例6: RenderFrameByCenter

        protected override void RenderFrameByCenter(PaintEventArgs e, Rectangle r)
        {
            Graphics g = e.Graphics;

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddRectangle(GaugeFrame.Bounds);

                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterPoint = GaugeFrame.Center;
                    br.CenterColor = GaugeFrame.FrameColor.Start;
                    br.SurroundColors = new Color[] { GaugeFrame.FrameColor.End };

                    br.SetSigmaBellShape(GaugeFrame.FrameSigmaFocus, GaugeFrame.FrameSigmaScale);

                    g.FillRectangle(br, GaugeFrame.Bounds);
                }

                path.AddRectangle(r);

                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterPoint = GaugeFrame.Center;
                    br.CenterColor = GaugeFrame.FrameColor.End;
                    br.SurroundColors = new Color[] { GaugeFrame.FrameColor.Start };

                    g.FillRectangle(br, r);
                }
            }

            RenderFrameBorder(g, GaugeFrame.Bounds);
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:33,代码来源:GaugeFrameRectangularRenderer.cs


示例7: OnPaint

		protected override void OnPaint(PaintEventArgs e)
		{
			using (SolidBrush b = new SolidBrush(BackColor))
			{
				e.Graphics.FillRectangle(b, ClientRectangle);
			}
			RectangleF wheelrect = WheelRectangle;
			Util.DrawFrame(e.Graphics, wheelrect, 6, m_frameColor);
			
			wheelrect = ColorWheelRectangle;
			PointF center = Util.Center(wheelrect);
			e.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
			if (m_brush == null)
			{
				m_brush = new PathGradientBrush(m_path.ToArray(), WrapMode.Clamp);
				m_brush.CenterPoint = center;
				m_brush.CenterColor = Color.White;
				m_brush.SurroundColors = m_colors.ToArray();
			}
			e.Graphics.FillPie(m_brush, Util.Rect(wheelrect), 0, 360);
			DrawColorSelector(e.Graphics);

			if (Focused)
			{
				RectangleF r = WheelRectangle;
				r.Inflate(-2,-2);
				ControlPaint.DrawFocusRectangle(e.Graphics, Util.Rect(r));
			}
		}
开发者ID:Nullstr1ng,项目名称:MultiRDPClient.NET,代码行数:29,代码来源:ColorWheel.cs


示例8: OnPaint

            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);

                Rectangle rect = ClientRectangle;

                if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(rect);
                        using (PathGradientBrush brush = new PathGradientBrush(path) { CenterColor = Color.FromArgb(0xFF, 204, 206, 219), SurroundColors = new[] { SystemColors.Control } })
                        {
                            e.Graphics.FillRectangle(brush, rect.X + Measures.SplitterSize / 2 - 1, rect.Y,
                                Measures.SplitterSize / 3, rect.Height);
                        }
                    }
                }
                else
                {
                    if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
                    {
                        using (SolidBrush brush = new SolidBrush(Color.FromArgb(0xFF, 204, 206, 219)))
                        {
                            e.Graphics.FillRectangle(brush, rect.X, rect.Y,
                                rect.Width, Measures.SplitterSize);
                        }
                    }
                }
            }
开发者ID:GamehubDev,项目名称:Nin_Online_Unity,代码行数:30,代码来源:VS2012LightDockWindow.cs


示例9: PaintVignette

        public static void PaintVignette(Graphics g, Rectangle bounds)
        {
            Rectangle ellipsebounds = bounds;
            ellipsebounds.Offset(-ellipsebounds.X, -ellipsebounds.Y);
            int x = ellipsebounds.Width - (int)Math.Round(.70712 * ellipsebounds.Width);
            int y = ellipsebounds.Height - (int)Math.Round(.70712 * ellipsebounds.Height);
            ellipsebounds.Inflate(x, y);

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(ellipsebounds);
                using (PathGradientBrush brush = new PathGradientBrush(path))
                {
                    brush.WrapMode = WrapMode.Tile;
                    brush.CenterColor = Color.FromArgb(0, 0, 0, 0);
                    brush.SurroundColors = new Color[] { Color.FromArgb(255, 0, 0, 0) };
                    Blend blend = new Blend();
                    blend.Positions = new float[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F };
                    blend.Factors = new float[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f };
                    brush.Blend = blend;
                    Region oldClip = g.Clip;
                    g.Clip = new Region(bounds);
                    g.FillRectangle(brush, ellipsebounds);
                    g.Clip = oldClip;
                }
            }
        }
开发者ID:michaelbehner96,项目名称:Xyzzxyz,代码行数:27,代码来源:Pure.cs


示例10: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            LinearGradientBrush linearGradientBrush1 = new LinearGradientBrush(//创建线性渐变画刷
            new Point(0, 0),new Point(20, 20),                  //渐变起始点和终止点
            Color.Yellow,Color.Blue);                           //渐变起始颜色和终止颜色
            G.FillRectangle(linearGradientBrush1, new Rectangle(0, 0, 150, 150));//绘制矩形
            LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(//创建线性渐变画刷
            new Rectangle(0, 0, 20, 20),                      //渐变所在矩形
            Color.Yellow, Color.Blue, 60f);                     //渐变起始颜色、终止颜色以及渐变方向
            linearGradientBrush2.WrapMode = WrapMode.TileFlipXY;
            G.FillRectangle(linearGradientBrush2, new Rectangle(150, 0, 150, 150));//绘制矩形

            GraphicsPath graphicsPath1 = new GraphicsPath();        //创建绘制路径
            graphicsPath1.AddArc(new Rectangle(0, 150, 100, 100), 90, 180);//向路径中添加半左圆弧
            graphicsPath1.AddArc(new Rectangle(150, 150, 100, 100), 270, 180);//向路径中添加半右圆弧
            graphicsPath1.CloseFigure();                            //闭合路径
            PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath1);//创建路径渐变画刷
            pathGradientBrush.CenterColor = Color.Yellow;           //指定画刷中心颜色
            pathGradientBrush.SurroundColors = new Color[] { Color.Blue };//指定画刷周边颜色
            pathGradientBrush.CenterPoint = new PointF(125, 200);   //指定画刷中心点坐标
            G.SmoothingMode = SmoothingMode.AntiAlias;              //消锯齿
            G.FillPath(pathGradientBrush, graphicsPath1);           //利用画刷填充路径
            G.DrawPath(new Pen(Color.Lime, 3f), graphicsPath1);     //绘制闭合路径曲线

            linearGradientBrush1.Dispose();
            linearGradientBrush2.Dispose();
            graphicsPath1.Dispose();
            pathGradientBrush.Dispose();
        }
开发者ID:dalinhuang,项目名称:wdeqawes-efrwserd-rgtedrtf,代码行数:32,代码来源:FormGradientBrush.cs


示例11: GetBrush

        public static System.Drawing.Brush GetBrush(this Brush brush, Rect frame)
        {
            var cb = brush as SolidBrush;
            if (cb != null) {
                return new System.Drawing.SolidBrush (cb.Color.GetColor ());
            }

            var lgb = brush as LinearGradientBrush;
            if (lgb != null) {
                var s = lgb.Absolute ? lgb.Start : frame.Position + lgb.Start * frame.Size;
                var e = lgb.Absolute ? lgb.End : frame.Position + lgb.End * frame.Size;
                var b = new System.Drawing.Drawing2D.LinearGradientBrush (GetPointF (s), GetPointF (e), System.Drawing.Color.Black, System.Drawing.Color.Black);
                var bb = BuildBlend (lgb.Stops);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            var rgb = brush as RadialGradientBrush;
            if (rgb != null) {
                var r = rgb.GetAbsoluteRadius (frame);
                var c = rgb.GetAbsoluteCenter (frame);
                var path = new GraphicsPath ();
                path.AddEllipse (GetRectangleF (new Rect (c - r, 2 * r)));
                var b = new PathGradientBrush (path);
                var bb = BuildBlend (rgb.Stops, true);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            throw new NotImplementedException ("Brush " + brush);
        }
开发者ID:sami1971,项目名称:NGraphics,代码行数:35,代码来源:SystemDrawingPlatform.cs


示例12: CreateGradientPalette

        private Color[] CreateGradientPalette()
        {
            Bitmap b = new Bitmap(100, 1);
            var g = Graphics.FromImage(b);

            Point[] points = { new Point(0, 0), new Point(50, 0), new Point(100, 0), new Point(100, 1) };
            Color[] colors = { Color.Red, Color.Yellow, Color.Green };
            //GraphicsPath path = new GraphicsPath();
            //path.AddLines(points);

            // Use the path to construct a path gradient brush.
            PathGradientBrush br = new PathGradientBrush(points);
            br.SurroundColors = colors;

            // var br = new LinearGradientBrush(new Point(0, 0), new Point(100, 0), Color.Red, Color.Green);
            g.FillRectangle(br, 0, 0, 100, 1);

            Color[] palette = new Color[b.Size.Width];
            for (int i = 0; i < palette.Length; i++)
            {
                palette[i] = b.GetPixel(i, 0);
            }

            b.Dispose();

            return palette;
        }
开发者ID:roberto-formulatrix,项目名称:test,代码行数:27,代码来源:Form1.cs


示例13: DrawButton

 protected virtual void DrawButton(Graphics g, Rectangle buttonRect)
 {
     this.BuildGraphicsPath(buttonRect);
     PathGradientBrush brush = new PathGradientBrush(this.bpath);
     brush.SurroundColors = new Color[] { this.buttonColor };
     buttonRect.Offset(this.buttonPressOffset, this.buttonPressOffset);
     if (this.bevelHeight > 0)
     {
         buttonRect.Inflate(1, 1);
         brush.CenterPoint = new PointF((float) ((buttonRect.X + (buttonRect.Width / 8)) + this.buttonPressOffset), (float) ((buttonRect.Y + (buttonRect.Height / 8)) + this.buttonPressOffset));
         brush.CenterColor = this.cColor;
         this.FillShape(g, brush, buttonRect);
         this.ShrinkShape(ref g, ref buttonRect, this.bevelHeight);
     }
     if (this.bevelDepth > 0)
     {
         this.DrawInnerBevel(g, buttonRect, this.bevelDepth, this.buttonColor);
         this.ShrinkShape(ref g, ref buttonRect, this.bevelDepth);
     }
     brush.CenterColor = this.buttonColor;
     if (this.dome)
     {
         brush.CenterColor = this.cColor;
         brush.CenterPoint = new PointF((float) ((buttonRect.X + (buttonRect.Width / 8)) + this.buttonPressOffset), (float) ((buttonRect.Y + (buttonRect.Height / 8)) + this.buttonPressOffset));
     }
     this.FillShape(g, brush, buttonRect);
     if (this.gotFocus)
     {
         this.DrawFocus(g, buttonRect);
     }
 }
开发者ID:JamesH001,项目名称:SX1231,代码行数:31,代码来源:PushBtn.cs


示例14: BothAlpha

 public static Bitmap BothAlpha(Bitmap p_Bitmap, bool p_CentralTransparent, bool p_Crossdirection)
 {
     Bitmap image = new Bitmap(p_Bitmap.Width, p_Bitmap.Height);
     Graphics graphics = Graphics.FromImage(image);
     graphics.DrawImage(p_Bitmap, new Rectangle(0, 0, p_Bitmap.Width, p_Bitmap.Height));
     graphics.Dispose();
     Bitmap bitmap2 = new Bitmap(image.Width, image.Height);
     Graphics graphics2 = Graphics.FromImage(bitmap2);
     System.Drawing.Point point = new System.Drawing.Point(0, 0);
     System.Drawing.Point point2 = new System.Drawing.Point(bitmap2.Width, 0);
     System.Drawing.Point point3 = new System.Drawing.Point(bitmap2.Width, bitmap2.Height / 2);
     System.Drawing.Point point4 = new System.Drawing.Point(0, bitmap2.Height / 2);
     if (p_Crossdirection)
     {
         point = new System.Drawing.Point(0, 0);
         point2 = new System.Drawing.Point(bitmap2.Width / 2, 0);
         point3 = new System.Drawing.Point(bitmap2.Width / 2, bitmap2.Height);
         point4 = new System.Drawing.Point(0, bitmap2.Height);
     }
     System.Drawing.Point[] points = new System.Drawing.Point[] { point, point2, point3, point4 };
     PathGradientBrush brush = new PathGradientBrush(points, WrapMode.TileFlipY) {
         CenterPoint = new PointF(0f, 0f),
         FocusScales = new PointF((float) (bitmap2.Width / 2), 0f),
         CenterColor = Color.FromArgb(0, 0xff, 0xff, 0xff)
     };
     brush.SurroundColors = new Color[] { Color.FromArgb(0xff, 0xff, 0xff, 0xff) };
     if (p_Crossdirection)
     {
         brush.FocusScales = new PointF(0f, (float) bitmap2.Height);
         brush.WrapMode = WrapMode.TileFlipX;
     }
     if (p_CentralTransparent)
     {
         brush.CenterColor = Color.FromArgb(0xff, 0xff, 0xff, 0xff);
         brush.SurroundColors = new Color[] { Color.FromArgb(0, 0xff, 0xff, 0xff) };
     }
     graphics2.FillRectangle(brush, new Rectangle(0, 0, bitmap2.Width, bitmap2.Height));
     graphics2.Dispose();
     BitmapData bitmapdata = bitmap2.LockBits(new Rectangle(0, 0, bitmap2.Width, bitmap2.Height), ImageLockMode.ReadOnly, bitmap2.PixelFormat);
     byte[] destination = new byte[bitmapdata.Stride * bitmapdata.Height];
     Marshal.Copy(bitmapdata.Scan0, destination, 0, destination.Length);
     bitmap2.UnlockBits(bitmapdata);
     BitmapData data2 = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, image.PixelFormat);
     byte[] buffer2 = new byte[data2.Stride * data2.Height];
     Marshal.Copy(data2.Scan0, buffer2, 0, buffer2.Length);
     int index = 0;
     for (int i = 0; i != data2.Height; i++)
     {
         index = (i * data2.Stride) + 3;
         for (int j = 0; j != data2.Width; j++)
         {
             buffer2[index] = destination[index];
             index += 4;
         }
     }
     Marshal.Copy(buffer2, 0, data2.Scan0, buffer2.Length);
     image.UnlockBits(data2);
     return image;
 }
开发者ID:jxdong1013,项目名称:archivems,代码行数:59,代码来源:UpdateForm.cs


示例15: BothAlpha

 public static Bitmap BothAlpha(Bitmap p_Bitmap, bool p_CentralTransparent, bool p_Crossdirection)
 {
     Bitmap _SetBitmap = new Bitmap(p_Bitmap.Width, p_Bitmap.Height);
     Graphics _GraphisSetBitmap = Graphics.FromImage(_SetBitmap);
     _GraphisSetBitmap.DrawImage(p_Bitmap, new Rectangle(0, 0, p_Bitmap.Width, p_Bitmap.Height));
     _GraphisSetBitmap.Dispose();
     Bitmap _Bitmap = new Bitmap(_SetBitmap.Width, _SetBitmap.Height);
     Graphics _Graphcis = Graphics.FromImage(_Bitmap);
     System.Drawing.Point _Left1 = new System.Drawing.Point(0, 0);
     System.Drawing.Point _Left2 = new System.Drawing.Point(_Bitmap.Width, 0);
     System.Drawing.Point _Left3 = new System.Drawing.Point(_Bitmap.Width, _Bitmap.Height / 2);
     System.Drawing.Point _Left4 = new System.Drawing.Point(0, _Bitmap.Height / 2);
     if (p_Crossdirection)
     {
         _Left1 = new System.Drawing.Point(0, 0);
         _Left2 = new System.Drawing.Point(_Bitmap.Width / 2, 0);
         _Left3 = new System.Drawing.Point(_Bitmap.Width / 2, _Bitmap.Height);
         _Left4 = new System.Drawing.Point(0, _Bitmap.Height);
     }
     System.Drawing.Point[] _Point = new System.Drawing.Point[] { _Left1, _Left2, _Left3, _Left4 };
     PathGradientBrush _SetBruhs = new PathGradientBrush(_Point, WrapMode.TileFlipY);
     _SetBruhs.CenterPoint = new PointF(0f, 0f);
     _SetBruhs.FocusScales = new PointF((float) (_Bitmap.Width / 2), 0f);
     _SetBruhs.CenterColor = Color.FromArgb(0, 0xff, 0xff, 0xff);
     _SetBruhs.SurroundColors = new Color[] { Color.FromArgb(0xff, 0xff, 0xff, 0xff) };
     if (p_Crossdirection)
     {
         _SetBruhs.FocusScales = new PointF(0f, (float) _Bitmap.Height);
         _SetBruhs.WrapMode = WrapMode.TileFlipX;
     }
     if (p_CentralTransparent)
     {
         _SetBruhs.CenterColor = Color.FromArgb(0xff, 0xff, 0xff, 0xff);
         _SetBruhs.SurroundColors = new Color[] { Color.FromArgb(0, 0xff, 0xff, 0xff) };
     }
     _Graphcis.FillRectangle(_SetBruhs, new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height));
     _Graphcis.Dispose();
     BitmapData _NewData = _Bitmap.LockBits(new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height), ImageLockMode.ReadOnly, _Bitmap.PixelFormat);
     byte[] _NewBytes = new byte[_NewData.Stride * _NewData.Height];
     Marshal.Copy(_NewData.Scan0, _NewBytes, 0, _NewBytes.Length);
     _Bitmap.UnlockBits(_NewData);
     BitmapData _SetData = _SetBitmap.LockBits(new Rectangle(0, 0, _SetBitmap.Width, _SetBitmap.Height), ImageLockMode.ReadWrite, _SetBitmap.PixelFormat);
     byte[] _SetBytes = new byte[_SetData.Stride * _SetData.Height];
     Marshal.Copy(_SetData.Scan0, _SetBytes, 0, _SetBytes.Length);
     int _WriteIndex = 0;
     for (int i = 0; i != _SetData.Height; i++)
     {
         _WriteIndex = (i * _SetData.Stride) + 3;
         for (int z = 0; z != _SetData.Width; z++)
         {
             _SetBytes[_WriteIndex] = _NewBytes[_WriteIndex];
             _WriteIndex += 4;
         }
     }
     Marshal.Copy(_SetBytes, 0, _SetData.Scan0, _SetBytes.Length);
     _SetBitmap.UnlockBits(_SetData);
     return _SetBitmap;
 }
开发者ID:zhushengwen,项目名称:example-zhushengwen,代码行数:58,代码来源:UpdateForm.cs


示例16: Form2_Paint

        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            //패스 그래디언트
            Point[] pts = { new Point(100, 0), new Point(0, 100), new Point(200, 100) };
            PathGradientBrush B = new PathGradientBrush(pts, WrapMode.Tile);
            e.Graphics.FillRectangle(B, ClientRectangle);

            //패스 그래디언트 끝
            //패스변형
            GraphicsPath Path = new GraphicsPath();
            Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat());
            //확장 후 외곽선 그리기
            Path.Widen(new Pen(Color.Black, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //확장 후 채우기
            Path.Widen(new Pen(Color.Blue, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //곡선 펴기
            Path.Flatten(new Matrix(), 12f);
            e.Graphics.DrawPath(Pens.Black, Path);

            //회전
            Matrix M = new Matrix();
            M.Rotate(-10);
            Path.Transform(M);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //휘기
            RectangleF R = Path.GetBounds();
            PointF[] arPoint = new PointF[4];
            arPoint[0] = new PointF(R.Left, R.Top + 30);
            arPoint[1] = new PointF(R.Right, R.Top - 10);
            arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10);
            arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30);

            Path.Warp(arPoint, R);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //클리핑

            //graphicspath path= new graphicspath();
            //path.fillmode = fillmode.winding;
            //path.addellipse(50, 10, 100, 80);
            //path.addellipse(20, 45, 160, 120);
            //e.graphics.fillpath(brushes.white, path);

            //e.graphics.setclip(path);

            //for (int y = 0; y < bottom; y+= 20)
            //{
            //    string str = "눈사람의 모양의클리핑 영역에 글자를 쓴것입니다";
            //    e.graphics.drawstring(str, font, brushes.blue, 0, y);
            //}

            //클리핑 끝
        }
开发者ID:sunnamkim,项目名称:doc,代码行数:58,代码来源:Form2.cs


示例17: Vignette

        /// <summary>
        /// Adds a vignette effect to the source image based on the given color.
        /// </summary>
        /// <param name="source">
        /// The <see cref="Image"/> source.
        /// </param>
        /// <param name="baseColor">
        /// <see cref="Color"/> to base the vignette on.
        /// </param>
        /// <param name="rectangle">
        /// The rectangle to define the bounds of the area to vignette. If null then the effect is applied
        /// to the entire image.
        /// </param>
        /// <param name="invert">
        /// Whether to invert the vignette.
        /// </param>
        /// <returns>
        /// The <see cref="Bitmap"/> with the vignette applied.
        /// </returns>
        public static Bitmap Vignette(Image source, Color baseColor, Rectangle? rectangle = null, bool invert = false)
        {
            using (Graphics graphics = Graphics.FromImage(source))
            {
                Rectangle bounds = rectangle ?? new Rectangle(0, 0, source.Width, source.Height);
                Rectangle ellipsebounds = bounds;

                // Increase the rectangle size by the difference between the rectangle dimensions and sqrt(2)/2 * the rectangle dimensions.
                // Why sqrt(2)/2? Because the point (sqrt(2)/2, sqrt(2)/2) is the 45 degree angle point on a unit circle. Scaling by the width 
                // and height gives the distance needed to inflate the rectangle to make sure it's fully covered.
                ellipsebounds.Offset(-ellipsebounds.X, -ellipsebounds.Y);
                int x = ellipsebounds.Width - (int)Math.Floor(.70712 * ellipsebounds.Width);
                int y = ellipsebounds.Height - (int)Math.Floor(.70712 * ellipsebounds.Height);
                ellipsebounds.Inflate(x, y);

                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(ellipsebounds);
                    using (PathGradientBrush brush = new PathGradientBrush(path))
                    {
                        // Fill a rectangle with an elliptical gradient brush that goes from transparent to opaque. 
                        // This has the effect of painting the far corners with the given color and shade less on the way in to the centre.
                        Color centerColor;
                        Color edgeColor;
                        if (invert)
                        {
                            centerColor = Color.FromArgb(50, baseColor.R, baseColor.G, baseColor.B);
                            edgeColor = Color.FromArgb(0, baseColor.R, baseColor.G, baseColor.B);
                        }
                        else
                        {
                            centerColor = Color.FromArgb(0, baseColor.R, baseColor.G, baseColor.B);
                            edgeColor = Color.FromArgb(255, baseColor.R, baseColor.G, baseColor.B);
                        }

                        brush.WrapMode = WrapMode.Tile;
                        brush.CenterColor = centerColor;
                        brush.SurroundColors = new[] { edgeColor };

                        Blend blend = new Blend
                        {
                            Positions = new[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F },
                            Factors = new[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f }
                        };

                        brush.Blend = blend;

                        Region oldClip = graphics.Clip;
                        graphics.Clip = new Region(bounds);
                        graphics.FillRectangle(brush, ellipsebounds);
                        graphics.Clip = oldClip;
                    }
                }
            }

            return (Bitmap)source;
        }
开发者ID:AlexSkarbo,项目名称:ImageProcessor,代码行数:76,代码来源:Effects.cs


示例18: Shape

 public Shape()
 {
     GraphicsPath p = new GraphicsPath();
     p.AddLine(new Point(0, 0), new Point(100, 100)); //memory error without this, unsure why
     PathGradientBrush brush = new PathGradientBrush(p);
     brush.CenterColor = fColor;
     brush.SurroundColors = eColor;
     gradient = brush;
 }
开发者ID:J-O-K-E-R,项目名称:3951,代码行数:9,代码来源:Shape.cs


示例19: panel1_Click

 private void panel1_Click(object sender, EventArgs e)
 {
     GraphicsPath gp = new GraphicsPath();
     gp.AddEllipse(20,20,50,50);
     PathGradientBrush pgb = new PathGradientBrush(gp);
     pgb.CenterColor = Color.Red;
     pgb.SurroundColors = new Color[] {Color.Yellow };
     Graphics g = panel1.CreateGraphics();
     g.FillEllipse(pgb,20,20,50,50);//creates like a 3d ball.
 }
开发者ID:ChrisPaine,项目名称:C-sharp,代码行数:10,代码来源:Form1.cs


示例20: createFluffyBrush

 public static Brush createFluffyBrush(GraphicsPath gp, float[] blendPositions, float[] blendFactors )
 {
     PathGradientBrush pgb = new PathGradientBrush( gp );
     Blend blend = new Blend();
     blend.Positions = blendPositions;
     blend.Factors = blendFactors;
     pgb.Blend = blend;
     pgb.CenterColor = Color.White;
     pgb.SurroundColors = new Color[] { Color.Black };
     return pgb;
 }
开发者ID:revenz,项目名称:iMeta,代码行数:11,代码来源:MetaNodeItem.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Html.CssBox类代码示例发布时间:2022-05-26
下一篇:
C# Drawing2D.Matrix类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap