-
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
-
This is an ongoing problem in the graphics world of programming: drawing things pixel by pixel.
I suggest using SrcAND for the mask and SrcPAINT for the sprite, it should work. (get 'em in the declaration explorer)
-
the rasterop constants can be found within the runtimes too:
VBRUN.RasterOpConstants.vbSrcPaint
VBRUN.RasterOpConstants.vbSrcAnd
-
Or you can just use them plain (without any reference to another object)
Code:
Print vbSrcPaint
Print vbSrcAnd
-
Thanks anyway Guys. Its a shame i liked that code.:(
-
Is it just me kedaman or do you change your signature every 2 seconds?
-
it's because of me, me changed my signature twice in 20 mins
-
Thanks Sastraxi that works great, but why didn't i think of that? Oh well.