Results 1 to 10 of 10

Thread: [RESOLVED] BitBlt issue smearing the image...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Resolved [RESOLVED] BitBlt issue smearing the image...

    VB6
    Windows 7

    Using BitBlt to move an image which is my map. The idea is to have my character centered (probably animated, but centered nonetheless) and have the map move so that it appears that the character is traveling. I have the character BitBlt covered. My issue is this...

    This is what it looks like at the start:
    Name:  good.jpg
Views: 394
Size:  24.2 KB

    And this is what it looks like when I move it using BitBlt:
    Name:  bad.jpg
Views: 333
Size:  18.5 KB

    I am adding 1 to the ByVal X As Long, ByVal Y As Long API call to move the map.

    I've attempted
    -----Refreshing the final PictureBox
    -----Loading the buffer image straight into the final PictureBox
    -------------This has resulted in flashing, which the entire purpose of BitBlt is to get rid of that
    -----Refreshing the final PictureBox
    -----Using PaintPicture
    -------------This results the same as the second image above

    All of my PictureBoxes have AutoRedraw set to True except my final PictureBox.

    Feel free to ask questions if you need help in helping me answer mine.

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: BitBlt issue smearing the image...

    I've had that problem using BitBlt and moving the object manually by mouse down on object and moving the mouse pointer but the smearing stops (picture returns to normal) when the movement stops. Also I don't think you should have AutoRedraw = True; that causes too much overhead. Try using False when you move the object. In my case if I remember it was because the picture was either too big and/or using wrong scale mode or I had AutoRedraw = True.
    Last edited by jmsrickland; Jan 15th, 2014 at 03:11 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: BitBlt issue smearing the image...

    Setting AutoRedraw to True blanks out the image. For BitBlt to work, all PictureBoxes need to have AutoRedraw set to True except the final PictureBox where everything ends up. Stopping the movement (I'm using a Timer) does nothing for the final image. The image is 240x144 pixels, so the size isn't the issue. And the scale I am using works for everything else, so I know that's not it.

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: BitBlt issue smearing the image...

    Quote Originally Posted by Conroy Vanderbluff View Post
    Setting AutoRedraw to True blanks out the image. For BitBlt to work, all PictureBoxes need to have AutoRedraw set to True except the final PictureBox where everything ends up. Stopping the movement (I'm using a Timer) does nothing for the final image. The image is 240x144 pixels, so the size isn't the issue. And the scale I am using works for everything else, so I know that's not it.
    So, set it to False

    EDIT: I think you need to save the rectangle where you are moving to. Then move to that. When you move away restore the area you saved and do this again. What's happening is you are leaving a trail behind you as you BitBlt to a new position
    Last edited by jmsrickland; Jan 15th, 2014 at 08:04 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: BitBlt issue smearing the image...

    Quote Originally Posted by Conroy Vanderbluff View Post
    All of my PictureBoxes have AutoRedraw set to True except my final PictureBox.
    It was originally.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: BitBlt issue smearing the image...

    Let me reiterate; whether the AutoRedraw is set to True or False, it doesn't work. One blanks out the image entirely, while the other smears it.

  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: BitBlt issue smearing the image...

    Assuming you're bitblting the map from some other source, if you don't clear the exposed area (the area that you are not bitblitting the map to), then of course you are going to see the one pixel band vertically and horizontally of the map left side and top line replicated as you move the map down to the right.
    Any part of the buffer you don't draw to is going to have the previous contents of the buffer unless you clear the buffer first.
    Last edited by passel; Jan 15th, 2014 at 07:11 PM.

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: BitBlt issue smearing the image...

    Quote Originally Posted by passel View Post
    Assuming you're bitblting the map from some other source, if you don't clear the exposed area (the area that you are not bitblitting the map to), then of course you are going to see the one pixel band vertically and horizontally of the map left side and top line replicated as you move the map down to the right.
    Any part of the buffer you don't draw to is going to have the previous contents of the buffer unless you clear the buffer first.
    This is exactly what is happening. He needs to find something to draw to the space it moved from. It looks like his tile is smaller than the actual map so he actually has nothing to draw. I think Jacob Roman may have done something like this since he writes a lot of game related stuff. Try PMing him to this thread. He might have some experience with this exact scenario.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: BitBlt issue smearing the image...

    Quote Originally Posted by Niya View Post
    It looks like his tile is smaller than the actual map so he actually has nothing to draw.
    Took me a second to understand what you meant by that, but now I get it. Nothing in the previous comments was making sense.
    If the character was moving Northwest, eventually the map would have to stop at 0, 0. Thanks for helping me.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: [RESOLVED] BitBlt issue smearing the image...


Tags for this Thread

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