CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Floating a Bitmap

    Part of the application I am working on requires a 128x64 32Bit Bitmap to me moved smoothly across the top of my form. It may involve the Bitmap being rotated during the move.

    I understand the maths etc for moving/rotating it. I want it to move smoothly and not flicker. There will be a tiled background image covering the area of the form over which the bitmap will be moved.

    I'm just starting a seperate test project to experiment.

    Has anyone had any experience with this before, maybe point out a nice technique they found or pitfall they avoided?

    Thanks
    Rob.
    Last edited by rliq; March 11th, 2010 at 05:42 PM.
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  2. #2
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: Floating a Bitmap

    OK, I got this working already. I used the standard Timer control and each time it fired I used the number of DateTime Ticks passed since the previous time it fired, to determine how far to move the PictureBox containing the Bitmap. I tiled a background too and it worked just as well.

    I do think though that it could be ultra-smooth, if I used a Bitmap directly and not a PictureBox container. However, I then have to be clever enough to know which parts of the form to Invalidate() each time I move the Bitmap. I know in C++ there were "Regions", I'm about to check if there are equivelents in .NET...

    I'm aiming this App at .NET 4.0.
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  3. #3
    Join Date
    May 2007
    Posts
    1,546

    Re: Floating a Bitmap

    Use double buffering. That's the standard technique for this sort of flickering problem.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  4. #4
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: Floating a Bitmap

    Jeez, don't you just hate it when somebody points out something you already knew but had forgotten!

    Yep, made the form double buffered, used a Bitmap on it's own, used Regions to minimise invalidate() 'ions and now it is as 'smooth as!".... Australian term for "couldn't be smoother"

    Thanks Mutant !!
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

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

Featured