|
-
Aug 12th, 2000, 04:40 PM
#1
Thread Starter
Hyperactive Member
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
Matt 
-
Aug 12th, 2000, 04:55 PM
#2
Frenzied Member
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.
Harry.
"From one thing, know ten thousand things."
-
Aug 12th, 2000, 04:56 PM
#3
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 12th, 2000, 05:37 PM
#4
Thread Starter
Hyperactive Member
I see what you mean, i works fine now. Thanks
Matt 
-
Aug 13th, 2000, 05:17 AM
#5
Fanatic Member
It will even work MORE fine if you Blt the background to a memory DC!
-
Aug 14th, 2000, 01:44 PM
#6
Frenzied Member
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
Harry.
"From one thing, know ten thousand things."
-
Aug 14th, 2000, 02:26 PM
#7
Thread Starter
Hyperactive Member
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?
Matt 
-
Aug 14th, 2000, 02:38 PM
#8
Monday Morning Lunatic
To make life easier, I will sort out an example project with full comments...I will then post it here.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 14th, 2000, 02:39 PM
#9
Thread Starter
Hyperactive Member
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..
Matt 
-
Aug 14th, 2000, 02:43 PM
#10
Monday Morning Lunatic
I'll put this in my example, which will probably be finished by tomorrow morning (that is, in about 14 hours time).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 14th, 2000, 06:12 PM
#11
Thread Starter
Hyperactive Member
Matt 
-
Aug 15th, 2000, 05:57 AM
#12
Monday Morning Lunatic
Here it is: http://www.parksie.uklinux.net/bitblt.zip
It demonstrates: Memory DCs + bitmaps. It basically demonstrates how to double-buffer.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 15th, 2000, 10:28 AM
#13
Good Ol' Platypus
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
Code:
Private Sub TmrGame_Timer()
Dim RC
picBack.CLS
RC = BitBlt(picBack.hDC,PaddleX,PaddleY,picPaddle.ScaleWidth,picPaddle.ScaleHeight,picPaddle.hDC,0,0,SRCCOPY)
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.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 15th, 2000, 06:08 PM
#14
Thread Starter
Hyperactive Member
Thanks everyone! I have a much better understanding now. The code examples were great
Matt 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|