pictureBox使用Region绘制后锯齿很明显 求助怎么能改成圆滑一些的?

weixin_38050892 2017-11-24 03:58:25

pictureBox使用Region绘制后锯齿很明显 求助怎么能改成圆滑一些的? 请先看一下我的代码  不要直接给我例子 例子百度一下很多 但是套用不上
private GraphicsPath GetRectPath(Rectangle rect, int radius)
{

int diameter = radius;
Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
GraphicsPath path = new GraphicsPath();

// 左上角
path.AddArc(arcRect, 180, 90);

// 右上角
arcRect.X = rect.Right - diameter;
path.AddArc(arcRect, 270, 90);

// 右下角
arcRect.Y = rect.Bottom - diameter;
path.AddArc(arcRect, 0, 90);

// 左下角
arcRect.X = rect.Left;
path.AddArc(arcRect, 90, 90);
path.CloseFigure();//闭合曲线
return path;

}

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
GraphicsPath formPath = new GraphicsPath();
Rectangle rect = new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height);

formPath = GetRectPath(rect,10);

pictureBox1.Region = new Region(formPath);

}
...全文
178 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38137880 2017-11-28
  • 打赏
  • 举报
回复
Hi,
根据
weixin_38135532 2017-11-28
  • 打赏
  • 举报
回复
Image
img =
new
Bitmap(@"C:\Users\8888\Desktop\Picture\13.jpg");

图片要是网络URL 的 http 地址怎么改呢?我试过提示我是不支持URL的 例如:
https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white.png
weixin_38061073 2017-11-27
  • 打赏
  • 举报
回复
Hi,
使用Bitmap 效果真的可以改善,你可以参考我的代码。  

private void button1_Click(object sender, EventArgs e) { pictureBox1.Image = GetRoundPic(2000); } public static Bitmap GetRoundPic(int size) { Image img = new Bitmap(@"C:\Users\8888\Desktop\Picture\13.jpg"); Bitmap bm = new Bitmap(size, size); Graphics g = Graphics.FromImage(bm); GraphicsPath gpath = new GraphicsPath(); gpath.AddEllipse(0, 0, size, size); g.SmoothingMode = SmoothingMode.AntiAlias;  g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality; g.SetClip(gpath); g.DrawImage(img, 0, 0); return bm; }
进过实际的测试过程中,我们发现图片的尺寸大小对显示的图片大小,有一定的影响。
你可以尝试修改 下面size 来达到你想要的效果。
GetRoundPic(int size)
weixin_38112805 2017-11-27
  • 打赏
  • 举报
回复
Hi,
使用Bitmap 效果真的可以改善,你可以参考我的代码。  

private void button1_Click(object sender, EventArgs e) { pictureBox1.Image = GetRoundPic(2000); } public static Bitmap GetRoundPic(int size) { Image img = new Bitmap(@"C:\Users\8888\Desktop\Picture\13.jpg"); Bitmap bm = new Bitmap(size, size); Graphics g = Graphics.FromImage(bm); GraphicsPath gpath = new GraphicsPath(); gpath.AddEllipse(0, 0, size, size); g.SmoothingMode = SmoothingMode.AntiAlias;  g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality; g.SetClip(gpath); g.DrawImage(img, 0, 0); return bm; }
进过实际的测试过程中,我们发现图片的尺寸大小对显示的图片大小,有一定的影响。
你可以尝试修改 下面size 来达到你想要的效果。
GetRoundPic(int size)
weixin_38072900 2017-11-24
  • 打赏
  • 举报
回复
求不吝赐教 指点一下改写方法
weixin_38066102 2017-11-24
  • 打赏
  • 举报
回复
Hi,
感谢在

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧