troubleshooting Question

Visible redraw while scrolling with large background images

Avatar of Sandra-24
Sandra-24 asked on
C#
10 Comments1 Solution1911 ViewsLast Modified:
I have a large background image (3500x2400 3.5mb jpeg) that I placed as the background image for a panel

Then I sized the panel to 3500x2400 and placed it on a form with AutoScroll and ran the application.

The image displays, and I can scroll, but when I scroll I can see the image breakup as the screen is being redrawn.

IOW, it lags on my high performance pc. If you make a new windows forms project with the above mentioned setup and use a very large image and you'll see the same effect.

How can I scroll around the image smoothly? It doesn't have to be the same setup as above with a panel in a form, it just has to work.

I also tried just overriding the OnPaint method of the form, and drawing the portion of the image depending on the value of the scrollbars. I then called Invalidate() in the on scroll event handler. That was a terrible idea and is about ten times slower because now the entire form flashes when I try to draw the image, but at least I ruled it out as a viable alternative.

I even tried a directx implementation of the panel. It had no effect. I'm sure if I spend enough time playing with directx I can get the image scrolling smoothly, but I have a bad feeling I would have to abandon the whole windows forms interface altogether for a directx interface.
I really want to avoid that if I can.

I'm running out of ideas, can anybody think of a way to make the scrolling smooth without visible redraw effects (like when you scroll on a form with a solid color background)

Thanks,
-Sandra
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros