PDA

Click to See Complete Forum and Search --> : bitblt


MPrestonf12
Aug 12th, 2000, 04:40 PM
Im having some trouble with bitblt. I got it to move the paddle smoothly, but, it leaves a trail of itself behind it. any suggestions? heres the code i used. I suspect I change the dwrop but I have no idea to what.

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
BitBlt Form1.hDC, X, Y, 51, 14, picpaddle.hDC, 0, 0, SRCCOPY
End Sub
thanks

HarryW
Aug 12th, 2000, 04:55 PM
If you only blit once then you're not going to remove the old picture. If I've understood right, and you're blitting a small picture onto a background then you need to either refresh the whole background before you blit again, or just refresh the area you last painted to. If you see what I mean.

parksie
Aug 12th, 2000, 04:56 PM
For smoothness, compile an image of the whole changed area in its new state, then blit that rather than the new paddle image. This way you won't get horrible flicker.

MPrestonf12
Aug 12th, 2000, 05:37 PM
I see what you mean, i works fine now. Thanks

Mad Compie
Aug 13th, 2000, 05:17 AM
It will even work MORE fine if you Blt the background to a memory DC!

HarryW
Aug 14th, 2000, 01:44 PM
yes it will look a heck of a lot better if you do as parksie says and paint the whole image to a back buffer (invisible) first, then blit that compiled image to the front buffer (the bit you see). You can do this with an invisible picture box (or is it image box - I can't remember now), or as Mad Compie says use a memory DC for the back buffer. Using a memory DC saves on resources.

Typically for this you would have 3 calls to BitBlt in a row (4 if you use a mask):

Blit background to back buffer
(Blit foreground mask to back buffer)
Blit foreground (small image) to back buffer
Blit back buffer to front buffer

MPrestonf12
Aug 14th, 2000, 02:26 PM
I don't really understand what your saying. Do you mean have a picture box that is the same as the backround and blit that everytime I move the padde unstead of using form1.refresh?

parksie
Aug 14th, 2000, 02:38 PM
To make life easier, I will sort out an example project with full comments...I will then post it here.

MPrestonf12
Aug 14th, 2000, 02:39 PM
im still new to this all but I know something is not right in the last line. Can anyone help me out

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-BitBlt Form1.hDC, X, Y, 51, 14, picpaddle.hDC, 0, 0, SRCCOPY
-buffer = BitBlt(Form1.hDC, 0, 0, Form1.Width, Form1.Height, Form1.hDC, 0, 0, SRCCOPY)
-BitBlt Form1.hDC, 0, 0, 0, 0, buffer?, 0, 0, SRCCOPY
End Sub
it also leaves a trail of the paddle when you move it. I've tried many things but to no success..

parksie
Aug 14th, 2000, 02:43 PM
I'll put this in my example, which will probably be finished by tomorrow morning (that is, in about 14 hours time).

MPrestonf12
Aug 14th, 2000, 06:12 PM
thanks for your help

parksie
Aug 15th, 2000, 05:57 AM
Here it is: http://www.parksie.uklinux.net/bitblt.zip

It demonstrates: Memory DCs + bitmaps. It basically demonstrates how to double-buffer.

Sastraxi
Aug 15th, 2000, 10:28 AM
Controls:
tmrGame - Timer: INTERVAL(100)
picBack - PictureBox: VISIBLE(FALSE),AUTOREDRAW(TRUE)
picBlt - PictureBox
picPaddle - PictureBox: VISIBLE(FALSE),AUTOREDRAW(TRUE)

PaddleX - X~Pos of Paddle
PaddleY - Y~Pos of Paddle

Private Sub TmrGame_Timer()
Dim RC
picBack.CLS
RC = BitBlt(picBack.hDC,PaddleX,PaddleY,picPaddle.ScaleWidth,picPaddle.ScaleHeight,picPaddle.hDC,0,0,SRCC OPY)

CopyBlt PicBack.hDC, PicBlt.hDC
End Sub

Sub CopyBlt(hSrcDC As Long,hDstDC As Long,W As Integer,H As Integer)
Dim Ret
Ret = Bitblt(hDstDC,0,0,W,H,hSrcDC,0,0,SRCCOPY)
End Sub


I believe that will work.

MPrestonf12
Aug 15th, 2000, 06:08 PM
Thanks everyone! I have a much better understanding now. The code examples were great