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 04:42 PM.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
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.......
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.
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.......
Bookmarks