Winform 绘制圆形的图片

string filename = "icon.png";//如果不是png类型,须转换
    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(filename);
    for (int y = 0; y < 100; y++)
    {
        for (int x = 0; x < 100; x++)
        {
            if ((x - 50) * (x - 50) + (y - 50) * (y - 50) > 50 * 50)
            {
                bitmap.SetPixel(x, y, System.Drawing.Color.FromArgb(0, 255, 255, 255));
            }
        }
    }
 
    Graphics g = CreateGraphics();
    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    g.DrawImage(bitmap, new Point(50, 50));
    g.DrawEllipse(new Pen(Color.LightGray), 50, 50, 100, 100);
    g.Dispose();

  

上一篇:struts jsp传值到action,乱码的解决方案


下一篇:.net MVC 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错,字符串的长度超过了为 maxJsonLength 属性设置的值