Results 1 to 14 of 14

Thread: bitblt

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    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

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  4. #4

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Smile

    I see what you mean, i works fine now. Thanks
    Matt

  5. #5
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    It will even work MORE fine if you Blt the background to a memory DC!

  6. #6
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  7. #7

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    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

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  9. #9

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Unhappy

    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

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  11. #11

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Thumbs up

    thanks for your help
    Matt

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  14. #14

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Thumbs up

    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
  •  



Click Here to Expand Forum to Full Width