vb2010 怎么使用Graphics绘制PNG等格式的图形文件到Picturebox中???悬赏50分!!急!!!!!!!!!

vb2010 怎么使用Graphics绘制PNG等格式的图形文件到Picturebox中???悬赏50分!!急!!!!!!!!!,第1张

通常Graphics是要和Bitmap一起使用的,假如iWidth=300,iHeight=100,代码如下:

 Bitmap bmpOut = new Bitmap((int)iWidth, (int)iHeight, PixelFormat.Format24bppRgb)

 Graphics g = Graphics.FromImage(bmpOut)

 g.DrawImage(b, new Rectangle(0, 0, (int)iWidth, (int)iHeight), new Rectangle((int)S            tartX, (int)StartY, (int)iWidth, (int)iHeight), GraphicsUnit.Pixel)

 g.Dispose()

 return bmpOut

这样就会生成一个300 * 100的图片,然后PictureBox.BackgroundImage=这个把回来的bmpOut就可以了,例如:

this.pictureBox1.BackgroundImage = new Bitmap(300,100)//假设这个 new Bitmap(300,100)

就是上面的代码返回来的bmpOut

Private Sub Form_Load()

Command1.Visible = False

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Command1.Visible = True

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11664128.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存