Private Sub cmdGo_Click()
' Make a temporary copy of the foreground picture.
picMaskedForeground.PaintPicture picForeground.Picture, _
0, 0
picMaskedForeground.Picture = picMaskedForeground.Image
' Copy the background to the result PictureBox.
picResult.PaintPicture picBackground.Picture, 0, 0
picResult.Picture = picResult.Image
' Copy the mask onto the result picture using
' the vbMergePaint opcode to erase pixels
' corresponding to black parts of the mask.
picResult.PaintPicture picMask.Picture, _
0, 0, , , , , , , vbMergePaint
picResult.Picture = picResult.Image
' Make a reversed mask. Copy the mask onto it
' using the vbNotSrcCopy opcode.
picReverseMask.PaintPicture picMask.Picture, _
0, 0, , , , , , , vbNotSrcCopy
picReverseMask.Picture = picReverseMask.Image
' Copy the reversed mask onto the foreground
' picture using the vbMergePaint opcode. That
' erases parts of the foreground image that
' correspond to the black parts of the reversed
' mask.
picMaskedForeground.PaintPicture _
picReverseMask.Picture, _
0, 0, , , , , , , vbMergePaint
picMaskedForeground.Picture = picMaskedForeground.Image
' Now we have a masked background that is white
' where we want the foreground image to go, and
' a reverse masked foreground image that is white
' where we want the background to show.
' Copy the reverse masked foreground image onto
' the masked background using the vbSrcAnd opcode.
picResult.PaintPicture picMaskedForeground.Picture, _
0, 0, , , , , , , vbSrcAnd
End Sub
|