469,607 Members | 2,068 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

How to make a large image scroll smoothly

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.ClientR ectangle.Height);
g.Clip=r;

and using
Rectangle dr=new
Rectangle(0,0,this.ClientRectangle.Width,this.Clie ntRectangle.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


Jul 19 '05 #1
1 6232
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.

"delong" <me****@ehomad.com> wrote in message
news:be**********@mawar.singnet.com.sg...
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.ClientR ectangle.Height);
g.Clip=r;

and using
Rectangle dr=new
Rectangle(0,0,this.ClientRectangle.Width,this.Clie ntRectangle.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

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by CDB | last post: by
2 posts views Thread by tripathy.asish | last post: by
1 post views Thread by Corane | last post: by
2 posts views Thread by Corane | last post: by
3 posts views Thread by tictac | last post: by
36 posts views Thread by sh.vipin | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.