包含vb.net显示图形的词条

VB.net该如何将图片圆形显示?

新建一个Winform,拖两个图片框。图片框1在设计器中选择一个图片(尺寸在图片框容纳为佳)。如下代码测试通过:

我们提供的服务有:网站制作、网站建设、微信公众号开发、网站优化、网站认证、隆尧ssl等。为上1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的隆尧网站制作公司

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;

}

用VB.NET绘制GDI图形

下面的例子通过重载Form 窗体的OnPaint()方法绘制GDI图形Protected Overrides Sub onpaint(ByVal e As System Windows Forms PaintEventArgs)注释 /////////////绘制任意直线Dim g As Graphics = e GraphicsDim mypen As Pen = New Pen(Color Red )g DrawLine(mypen )注释 /////////////绘制矩形(任意直线构成的封闭图形)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim curvepoints As PointF() = {point point point point }g DrawPolygon(New Pen(Color Blue ) curvepoints)注释 ////////////文本表示Dim FFamily As FontFamily = New FontFamily( Arial )Dim font As Font = New Font(FFamily FontStyle Bold FontStyle Italic GraphicsUnit Pixel)Dim text As String = I love you! Dim solidbrush As SolidBrush = New SolidBrush(Color Red)Dim pr As PointF = New PointF( )e Graphics DrawString(text font solidbrush pr)注释 ////////////平面绘制Dim rec As RectangleF = New RectangleF( )g DrawPie(mypen rec )注释 ///////////封闭图形 应该是个圆g DrawClosedCurve(mypen curvepoints Drawing Drawing D FillMode Alternate)注释 ///////////大家自己试试看吧g DrawArc(mypen )g DrawCurve(mypen curvepoints)g DrawBezier(mypen )g DrawBeziers(mypen curvepoints)注释 //////////这可是一个圆Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )注释 //////////这是一个椭圆Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )End Sub 这些是我自己试验出来的 当然了 还有好多 我只是开了一个头 大家要是发现什么好东东 别忘了通知一下 ) lishixinzhi/Article/program/net/201311/11800

怎样在vb,net中的窗口下显示图像

可以使用窗体BackgroundImage属性显示图像,

也可以使用PictureBox的BackgroundImage属性显示图像。


分享文章:包含vb.net显示图形的词条
文章URL:http://myzitong.com/article/hggiis.html