十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Dim myGraphics As Graphics = Me.CreateGraphics '声明并创建一个Graphics对象
10年积累的成都网站设计、成都网站制作、外贸网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有临漳免费网站建设让你可以放心的选择与我们合作。
Dim myPen As Pen = New Pen(Drawing.Color.Black, 3) '声明一个画笔,并设定颜色和粗细
myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid '线型,Solid是实线
myGraphics.DrawEllipse(myPen, 200, 200, 100, 100) '画圆,数值依次是:横坐标、纵坐标、宽度和高度(宽高相同为正圆,否则为椭圆)
myGraphics.Dispose() '释放Graphics占用的资源
新建一个Winform,拖两个图片框。图片框1在设计器中选择一个图片(尺寸在图片框容纳为佳)。如下代码测试通过:
private void button1_Click(object sender, EventArgs e)
{
Image img1 = this.pictureBox1.Image;
Image img2 = CropToCircle(img1);
this.pictureBox2.Image = img2;
}
public Image CropToCircle(Image img1)
{
Image img2 = new Bitmap(img1.Width, img1.Height,
img1.PixelFormat);
Graphics g = Graphics.FromImage(img2);
using (Brush br =
new SolidBrush(SystemColors.Control))//背景色
{
g.FillRectangle(br, 0, 0,
img2.Width, img2.Height);
}
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, img2.Width, img2.Height);
g.SetClip(path);
g.DrawImage(img1, 0, 0);
return img2;
}
Public a(8) As OvalShape
Dim canvas= New Microsoft.VisualBasic.PowerPacks.ShapeContainer
ConstCircleSize As Integer= 20
Const Dist As Integer = 10
Const Gap As Integer = 50
Dim i As Integer
canvas.Parent = Me.Panel1
For i =0 To 8
a(i) = NewOvalShape
a(i).Size = New Size(CircleSize,CircleSize)
a(i).Location = New Point(Dist +Gap * (i Mod 3), Dist + Gap * (i \ 3))
a(i).BorderWidth = 3
a(i).Enabled = True
a(i).Visible = True
a(i).Parent = canvas
Next