-2

可能重复:
VB.NET 替换图片框图像的像素颜色

我想从全图
全图中提取正方形:

全图

我只想要这个:

预期的

4

1 回答 1

3

使用此功能应该可以工作:

Public Function GetPicturePart(ByVal SourceImage As Image, ByVal Region As Rectangle) As Bitmap
    Dim ImagePart As Bitmap = New Bitmap(Region.Width, Region.Height)
    Using G As Graphics = Graphics.FromImage(ImagePart)
        Dim TargetRect As Rectangle = New Rectangle(0, 0, Region.Width, Region.Height)
        Dim SourceRect As Rectangle = Region
        G.DrawImage(SourceImage, TargetRect, SourceRect, GraphicsUnit.Pixel)
    End Using
    Return ImagePart
End Function

我认为这个功能是自描述的。;)

来源:获取图片部分

于 2012-06-03T14:16:30.857 回答