I'm using gif files (with transparencies) and moving them around the form with a timer and the .Left and .Top properties. Can someone tell me why the image keeps flashing? Or better yet, how I can fix this
Thank ye
Printable View
I'm using gif files (with transparencies) and moving them around the form with a timer and the .Left and .Top properties. Can someone tell me why the image keeps flashing? Or better yet, how I can fix this
Thank ye
Coz GIFs are VERY slow!
If you want to code a game (or other graphical stuff) I'd recommand you to use at least BitBlt (better DDraw). The key to non-flickering movement is a buffer, where you draw everything into before showing it... short said ;)
That's great, but what's bitblt? and how do I use it? Where can I read about it? (I'm only new to VB) Would this mean that I actually have to render the images or can I just convert my gifs to work with this "bitblt"?
btw, the reason I'm using gifs is because I want to use transparencies. With this BitBlt thing, can I still use transparencies or would I have to set regions around images or whatever. (Forgive me if I make no sense, I rarely know what I'm talking about so there's very little chance that I'd know anything about VB)
[Edited by SOUL-JAH on 07-18-2000 at 08:07 AM]
BitBlt (Bit Block Transfer) is an API command from the Windows GDI (Graphics Device Interface) to draw pictures onto DCs (Device Context). Since BitBlt supports severals ROPs (Raster Operations) you can have transparency with BitBlt. There are some examples on my website (see signature) you can learn from, or ask me again (ICQ; I seek you *g*).
Hope this helps and sorry for all the terms ;)
For transparency, you have to copy the Mask down first with an OP Code of SRCAND and then the Sprite with an OP code of SRCPAINT.
TERMS
SRCAND: Copies all colours but white
SRCPAINT: Copies all colours but black
A Mask is like a black and white version of the Picture. The background is coloured white and the actual graphic is coloured black regardless of the original color.
A Sprite is your normal image. It must have a black background and. The reason is as follows: You to copy the Mask down with SRCAND, and all the colours but the white is copied, leaving us with a pure black version of our picture. Next we copy down the Sprite with SRCPAINT. This will copy all but black so it leaves us with our original Image with no background, therefor it has a transparent background. The reason we had to copy the Mask down first is because since we did not copy the black from our Image, it will appear "watered-down". The Mask mearly adds the orginal backness back to the image, without having a background.
Code:'Copy down the Mask
BitBlt BACK.hDC, 0, 0, 30, 30, picMask.hDC, 0, 0, SRCAND
'Copy down the Sprite
BitBlt BACK.hDC, 0, 0, 30, 30, picSprite.hDC, 0, 0, SRCPAINT
To complete this thing:
I prefer to invert the masks, meaning the original graphics have white BG while the mask has a black BG and all other pixels white. It works when you just swap the ROPS when drawing. (But I knew this method before and personally like white BGs more ;))