C# GDI+ 如何根据画的椭圆,不是矩形,截取椭圆里的内容保存为图片?GDI+图片C#

解决方案 »

  1.   

    你说下吧,只要不要用到系统API调用就好了~—-—
      

  2.   


    Image img = new Bitmap(500, 400);
    Graphics g = Graphics.FromImage(img);
    g.FillEllipse(Brushes.SkyBlue, 50, 50, 400, 300);
    g.Save();
    g.Dispose();
    img.Save("d:\\abc.png");
      

  3.   


    Image img = new Bitmap(500, 400);
    Graphics g = Graphics.FromImage(img);
    Brush brush = new TextureBrush(bgImage);//bgImage是你的背景图片
    g.FillEllipse(brush, 50, 50, 400, 300);
    g.Save();
    g.Dispose();
    brush.Dispose();
    img.Save("d:\\abc.png");
      

  4.   


    那如果你由GraphicsPath组成的一个圆呢?因为是画笔在上面随便画的,如果画出的是一个圆就获取这部分
      

  5.   


    Image img = new Bitmap(500, 400);
    Graphics g = Graphics.FromImage(img);
    Brush brush = new TextureBrush(bgImage);//bgImage是你的背景图片
    g.FillPath(brush, path); //path 是你的GraphicsPath
    g.Save();
    g.Dispose();
    brush.Dispose();
    img.Save("d:\\abc.png");
      

  6.   


     Bitmap bp = new Bitmap((int)rf.Width,(int)rf.Height);
                    Graphics gs = Graphics.FromImage(bp);
                    Brush bs = new TextureBrush(this.pb_touch.BackgroundImage);
                    _clearRoundPath = ScaleTranform(pointfs, _clearPenSize);
                    gs.FillPath(bs,_clearRoundPath);
                    bp.Save(Initialize.Const.Screenpath+"\\aa.jpg");
    这样保存的图片什么都没有。。
      

  7.   


     _clearRoundPath = ScaleTranform(pointfs, _clearPenSize);这里的_clearRoundPath的区域会不会是Empty, 或者不包括this.pb_touch.BackgroundImage的任何部分!还有一点,最好在
      bp.Save(Initialize.Const.Screenpath+"\\aa.jpg");
    前面加上
      
    gs.Save();
      

  8.   


            private void pb_touch_Paint(object sender, PaintEventArgs e)
            {
                Graphics g = e.Graphics;
                if (_clearRoundPath != null)
                {                Bitmap bp = new Bitmap((int)rf.Width,(int)rf.Height);
                    Graphics gs = Graphics.FromImage(bp);
                    Brush bs = new TextureBrush(this.pb_touch.BackgroundImage);
                    g.DrawPath(new Pen(Brushes.Blue), _clearRoundPath);  //这里都能画出_clearRoundPath来
                    gs.FillPath(bs,_clearRoundPath);
                    gs.Save();
                    bp.Save(Initialize.Const.Screenpath+"\\aa.jpg");  //这里有保存一张图片,但图片内容什么都没有
                }
            }
    ”或者不包括this.pb_touch.BackgroundImage的任何部分!“这句话是什么意思?我就是在pb_touch这个控件上画的啊