-
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.
-
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.
-
Re: Floating a Bitmap
Use double buffering. That's the standard technique for this sort of flickering problem.
-
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 !!