I am trying to make a screen saver, a logo for a Band moves about the screen (with a space background thingy) bouncing off the walls. I have got all the other code working fine. However i dont like using vbsrcinvert or vbsrcinvert as these look weard when the logo crosses the earth of the moon. So i created this code so that it uses vbsrccopy and then writes each pixel manually from the background to create a transparent effect using a mask as a guide.

My problem is this code is way to slow, any ideas on how to fix this?


Sub MakeTrans()
Dim PixelX As Integer
Dim PixelY As Integer

Dim BackPixelColour
Dim MaskPixelColour

For PixelX = 0 To Form1.PicMask.ScaleWidth
For PixelY = 0 To Form1.PicMask.ScaleHeight

MaskPixelColour = GetPixel(Form1.PicMask.hdc, PixelX, PixelY) 'get colour from mask

If MaskPixelColour >= 0 And MaskPixelColour <= 500 Then 'if the pixel is black copy to the buffer the pixel from the background
BackPixelColour = GetPixel(Form1.PicBack.hdc, (Position.X + PixelX), (Position.Y + PixelY)) 'get background pixel colour
Call SetPixelV(Form1.PicBuf.hdc, (Position.X + PixelX), (Position.Y + PixelY), BackPixelColour) 'draw to buffer the pixel colour
End If

Next
Next

End Sub