How to make a large image scroll smoothly

D

delong

Hi

I am trying to display a large image on the form and make the form
scrollable.
My image is about 4200 x 7000 pixel.

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs
e)
{
Graphics g=e.Graphics;
g.DrawImage(Image,0,0,Image.Width,Image.Height);

}

The image display correctly and the scrolling works fine. However the
scrolling is not
smooth ( scrolling movement is jaggered ). Seems the image is not updated
fast enough.
I have tried with IE and photoshop to open the same image and both
application is able
to scroll the image quite smoothly. So far I have not seen any posted sample
that can scroll
large image smoothly.

I have even tried various method such as Clipping only the client region
using
Region r= new
Region(0,0,this.ClientRectangle.Width,this.ClientRectangle.Height);
g.Clip=r;

and using
Rectangle dr=new
Rectangle(0,0,this.ClientRectangle.Width,this.ClientRectangle.Height);
g.DrawImage(Image,dr,dr,GraphicsUnit.Pixel);

but it stills does not achieve what I want.


Anyone have any idea how scroll very large image smoothly ?

Thanks
Danial
 
L

Lee Gillie

Does this help?

SetStyle(ControlStyles.DoubleBuffer, True)

SetStyle(ControlStyles.AllPaintingInWmPaint, True)

Do this once, such as the New() of your Form. Maybe it won't
help with the size you are working with, but I'd be curious to know if
it helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top