效果:

        private void Form1_Load(object sender, EventArgs e)
{
string file =System.IO.Path.Combine(Environment.CurrentDirectory, @"11.jpg");
try
{
Image i = new Bitmap(file);
pbO.Image = i; pbD1.Image = WayOne(file);
pbD2.Image = WayTwo(file); pbS1.Image = WaySOne(file);
pbS2.Image = WaySTwo(file); }
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private Bitmap WayOne(string file)
{
using (Image i = new Bitmap(file))
{
Bitmap b = new Bitmap(i.Width, i.Height);
using (Graphics g = Graphics.FromImage(b))
{
g.FillEllipse(new TextureBrush(i), , , i.Width, i.Height);
}
return b;
}
}
private Bitmap WayTwo(string file)
{
using (Image i = new Bitmap(file))
{
Bitmap b = new Bitmap(i.Width, i.Height);
using (Graphics g = Graphics.FromImage(b))
{
g.DrawImage(i, , , b.Width, b.Height);
int r = Math.Min(b.Width, b.Height) / ;
PointF c = new PointF(b.Width / 2.0F, b.Height / 2.0F);
for (int h = ; h < b.Height; h++)
for (int w = ; w < b.Width; w++)
if ((int)Math.Pow(r, ) < ((int)Math.Pow(w * 1.0 - c.X, ) + (int)Math.Pow(h * 1.0 - c.Y, )))
{
b.SetPixel(w, h, Color.Transparent);
}
}
return b;
}
} private Bitmap WaySOne(string file)
{
using (Image i = new Bitmap(file))
{
Bitmap b = new Bitmap(i.Width, i.Height);
using (Graphics g = Graphics.FromImage(b))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
using (System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Alternate))
{
p.AddEllipse(, , i.Width, i.Height);
g.FillPath(new TextureBrush(i), p);
}
//g.FillEllipse(new TextureBrush(i), 0, 0, i.Width, i.Height);
}
return b;
}
}
private Bitmap WaySTwo(string file)
{
using (Image i = new Bitmap(file))
{
Bitmap b = new Bitmap(i.Width, i.Height);
using (Graphics g = Graphics.FromImage(b))
{
g.DrawImage(i, , , b.Width, b.Height);
int r = Math.Min(b.Width, b.Height) / ;
PointF c = new PointF(b.Width / 2.0F, b.Height / 2.0F);
for (int h = ; h < b.Height; h++)
for (int w = ; w < b.Width; w++)
if ((int)Math.Pow(r, ) < ((int)Math.Pow(w * 1.0 - c.X, ) + (int)Math.Pow(h * 1.0 - c.Y, )))
{
b.SetPixel(w, h, Color.Transparent);
}
//画背景色圆
using (Pen p = new Pen(System.Drawing.SystemColors.Control))
g.DrawEllipse(p, , , b.Width, b.Height);
}
return b;
}
}

最新文章

  1. 【原创】轻量级即时通讯技术MobileIMSDK:Android客户端开发指南
  2. Unity Standard Assets 简介之 Cameras
  3. HDU 3743 Frosh Week(归并排序求逆序对)
  4. mysql优化思路
  5. vsftp快速配置
  6. 发布阿里云OSS for phpcmsV9整合教程
  7. $(&#39;li&#39;,&#39;div&#39;) $(&#39;div li&#39;) $(&#39;div li&#39;)
  8. 特效TD 的工作准则
  9. linux 在终端中打开图形化文件管理器
  10. SQLMap简单尝试
  11. Mysql的硬件优化和配置优化
  12. SpringBoot: 配置加载顺序
  13. ACM Meteor Shower
  14. 微信小程序基础之新建的项目文件图解
  15. SQL进阶1:case表达式的用法示例
  16. javascript——10章 DOM
  17. 第一个Sprint
  18. NOIP2012题解
  19. Fraunhofer音频技术为MPEG未来高品质3D音频内容传输的标准依据
  20. 深入理解Connector

热门文章

  1. Model Validation in ASP.NET Web API
  2. CodeForces 515B. Drazil and His Happy Friends
  3. Dijkstra算法初步 - 迷宫问题
  4. js 无缝滚动效果学习
  5. css疑难汇总
  6. msql数据迁移,myisam及innoDB
  7. SQLite的原子提交原理
  8. 常用Jquery插件整理
  9. js 打印
  10. PHP (sendmail / PHPMailer / ezcMailComposer)发送邮件