Public Sub FillMap(hDCOut As Long, _
x As Long, y As Long, _
Width As Long, Height As Long, _
hSrcDC As Long, _
SrcX As Long, SrcY As Long, _
SrcWidth As Long, SrcHeight As Long, _
Optional dwRop As RasterOpConstants = vbSrcCopy, _
Optional ByVal StepX As Long = &H80000000, _
Optional ByVal StepY As Long = &H80000000)
Dim I As Long, J As Long
Dim StartX As Long, StartY As Long
Dim PutX As Long, PutY As Long
Dim PutWi As Long, PutHe As Long
Dim TempNum As Long
If StepX = &H80000000 Then StepX = x
If StepY = &H80000000 Then StepY = y
'Debug.Print "Step "; StepX; StepY;
Do While StepX > 0
StepX = StepX - SrcWidth
Loop
Do While StepX <= 0
StepX = StepX + SrcWidth
Loop
StepX = StepX - SrcWidth
Do While StepY > 0
StepY = StepY - SrcHeight
Loop
Do While StepY <= 0
StepY = StepY + SrcHeight
Loop
StepY = StepY - SrcHeight
'Debug.Print StepX; StepY
'Debug.Print SrcWidth
StartX = StepX
Do While StartX < x
StartX = StartX + SrcWidth
Loop
StartX = StartX - SrcWidth
StartY = StepY
Do While StartY < y
StartY = StartY + SrcHeight
Loop
StartY = StartY - SrcHeight
For I = StartY To y + Height - 1 Step SrcHeight
For J = StartX To x + Width - 1 Step SrcWidth
PutWi = SrcWidth
PutHe = SrcHeight
PutX = 0
PutY = 0
If I < y Then
PutY = y - I
PutHe = PutHe - PutY
End If
If I + SrcHeight - 1 > y + Height - 1 Then
PutHe = PutHe + ((y + Height - 1) - (I + SrcHeight - 1))
End If
If J < x Then
PutX = x - J
PutWi = PutWi - PutX
End If
If J + SrcWidth - 1 > x + Width - 1 Then
PutWi = PutWi + ((x + Width - 1) - (J + SrcWidth - 1))
End If