VB.NET で BitBlt 関数を再構築しようとしましたが、それほど悪くはありませんが、私の画像は常に宛先ビットマップの 0,0 にブリット/描画されます。
誰かが私の間違いを見ますか?
ご覧のとおり、ソース ビットマップの rect (0, 0, 50, 50) をコピー先ビットマップのポイント (25,25) にコピーしようとしていますが、それは行われません。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Make a Bitmap to hold the result.
Dim bm As New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
CopyBitmap(Me.PictureBox1.Image, bm, 25, 25, 50, 50, 0, 0)
Me.PictureBox2.Image = bm
End Sub
Public Sub CopyBitmap(ByRef uSource As Bitmap, ByRef uTarget As Bitmap, ByVal uDestX As Integer, ByVal uDestY As Integer, ByVal uSrcWidth As Integer, ByVal uSrcHeight As Integer, ByVal uSrcX As Integer, ByVal uSrcY As Integer)
Dim nSrc As New Rectangle
nSrc = Rectangle.FromLTRB(uSrcX, uSrcY, uSrcX + uSrcWidth, uSrcY + uSrcHeight)
Dim nDst As New Rectangle
nDst = Rectangle.FromLTRB(uDestX, uDestY, uDestX + uSrcWidth, uDestY + uSrcHeight)
Using g As Graphics = Graphics.FromImage(uTarget)
' Draw the specified section of the source bitmap to the new one
g.DrawImage(uSource, nSrc, nDst, GraphicsUnit.Pixel)
End Using
End Sub