2013-08-18 51 views
0

裁剪所需的代码是什么(从图片中获取图像)?在Visual Basic Express 2010中获取位图图像的一部分

+0

这不是回答问题的最佳方法,但是您是新手,并尝试使用最合适的级别。也许你应该重新对问题进行一些格式化,以使这些想法更清晰,并且可能对其他人更有帮助。我写这篇评论是对我们在这里讨论的所有内容的总结。 – varocarbas

回答

1

此代码通过从(矩形)输入图像创建具有所需尺寸的较小矩形并将其加载到PictureBoxPictureBox1)中来工作。这对卡片游戏软件很有用。

Private Function CropBitmap(ByRef bmp As Bitmap, ByVal cropX As Integer, ByVal cropY As Integer, ByVal cropWidth As Integer, ByVal cropHeight As Integer) As Bitmap 
    Dim rect As New Rectangle(cropX, cropY, cropWidth, cropHeight) 
    Dim cropped As Bitmap = bmp.Clone(rect, bmp.PixelFormat) 
    Return cropped 
End Function 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    Dim FN = "full path of the image file" 
    Dim bmp As Bitmap bmp = Bitmap.FromFile(FN) 
    PictureBox1.Image = CropBitmap(bmp, 4, 4, 13, 16) 
End Sub 
+1

+1为了努力让自己适应这个网站。 – varocarbas