读书人

怎样把图片中的一部分绘制到Pitureb

发布时间: 2012-02-11 09:51:35 作者: rapoo

怎样把图片中的一部分,绘制到Piturebox的制定区域?
怎样把图片中的一部分(圆形区域),绘制到Piturebox的制定区域?

[解决办法]
'设定要剪裁的矩形框
Dim recSource As New Rectangle( _
CInt(LeftValue), CInt(TopValue), _
CInt(WidthValue), CInt(HeightValue))
'设定剪裁后的存储位图
Dim bmpCropped As New Bitmap( _
CInt(WidthValue), CInt(HeightValue))

Dim grBitmap As Graphics = Graphics.FromImage(bmpCropped)
'Image为要剪裁的位图
grBitmap.DrawImage(Image, 0, 0, _
recSource, GraphicsUnit.Pixel)
'最后将bmpCropped导入PictureBox即可
[解决办法]
不好意思,没有看到是圆形,
圆形的话,也可以通过上面的方法获得举行图像,然后再利用下面的代码
Dim myTextureBrush As New TextureBrush(bmpCropped)
myGraphics.FillEllipse(myTextureBrush, LeftValue, TopValue, Width, Height)
将所剪裁的位图以画刷的方式绘制到一个圆形中,应该可以吧

读书人网 >VB Dotnet

热点推荐