h &gt; cSrc.Width) Then
         lDestWidth = cSrc.Width
         xEnd = cSrc.BytesPerScanLine
      Else
         xEnd = cDst.BytesPerScanLine
      End If
   End If
   If (lDestHeight = -1) Then
      lDestHeight = cDst.Height
      If (lDestHeight &gt; cSrc.Height) Then
         lDestHeight = cSrc.Height
         yEnd = cSrc.Height
      Else
         yEnd = cDst.Height
      End If
   End If
   
   For x = 0 To xEnd - 4 Step 4
      xDest = x + lDestLeft * 4
      For y = 0 To yEnd - 1
         yDest = 