亲宝软件园·资讯

展开

C#图片加相框 C#实现图片加相框的方法

Microblue 人气:0
想了解C#实现图片加相框的方法的相关内容吗,Microblue在本文为您仔细讲解C#图片加相框的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:C#,图片,加相框,C#图片加相框,下面大家一起来学习吧。

本文实例讲述了C#实现图片加相框的方法。分享给大家供大家参考,具体如下:

//加边框
try
{
  Bitmap Backbmp = new Bitmap(@"" + Path);
  float w = (float)(Backbmp.Width * 0.2);
  using (Graphics g = Graphics.FromImage(Backbmp))
  {
    using (Brush brush = new SolidBrush(Color.FromArgb(0, 156, 255)))
    {
      using (Pen pen = new Pen(brush, w))
      {
        pen.DashStyle = DashStyle.Custom;
        g.DrawRectangle(pen, new Rectangle(0, 0, Math.Abs(Backbmp.Width), Math.Abs(Backbmp.Height)));
        g.Dispose();
        pic.BackgroundImage = Backbmp;
      }
    }
  }
}
catch (Exception)
{
}
//加椭圆
try
{
  Bitmap Backbmp = new Bitmap(@"" + Path);
  float w = (float)(Backbmp.Width * 0.2);
  using (Graphics g = Graphics.FromImage(Backbmp))
  {
    using (Brush brush = new SolidBrush(Color.FromArgb(0, 156, 255)))
    {
      using (Pen pen = new Pen(brush, w))
      {
        pen.DashStyle = DashStyle.Custom;
        g.DrawEllipse(pen, new Rectangle(0, 0, Math.Abs(Backbmp.Width), Math.Abs(Backbmp.Height)));
        g.Dispose();
        pic.BackgroundImage = Backbmp;
      }
    }
  }
}
catch (Exception)
{
}

希望本文所述对大家C#程序设计有所帮助。

加载全部内容

相关教程
猜你喜欢
用户评论