How to make a large image scroll smoothly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • delong

    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(obj ect sender, System.Windows. Forms.PaintEven tArgs
    e)
    {
    Graphics g=e.Graphics;
    g.DrawImage(Ima ge,0,0,Image.Wi dth,Image.Heigh t);

    }

    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 .ClientRectangl e.Width,this.Cl ientRectangle.H eight);
    g.Clip=r;

    and using
    Rectangle dr=new
    Rectangle(0,0,t his.ClientRecta ngle.Width,this .ClientRectangl e.Height);
    g.DrawImage(Ima ge,dr,dr,Graphi csUnit.Pixel);

    but it stills does not achieve what I want.


    Anyone have any idea how scroll very large image smoothly ?

    Thanks
    Danial




  • Lee Gillie

    #2
    Re: How to make a large image scroll smoothly

    Does this help?

    SetStyle(Contro lStyles.DoubleB uffer, True)

    SetStyle(Contro lStyles.AllPain tingInWmPaint, 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" <member@ehomad. com> wrote in message
    news:behl7f$uap $1@mawar.singne t.com.sg...[color=blue]
    > 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(obj ect sender,[/color]
    System.Windows. Forms.PaintEven tArgs[color=blue]
    > e)
    > {
    > Graphics g=e.Graphics;
    > g.DrawImage(Ima ge,0,0,Image.Wi dth,Image.Heigh t);
    >
    > }
    >
    > The image display correctly and the scrolling works fine. However[/color]
    the[color=blue]
    > scrolling is not
    > smooth ( scrolling movement is jaggered ). Seems the image is not[/color]
    updated[color=blue]
    > 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[/color]
    posted sample[color=blue]
    > that can scroll
    > large image smoothly.
    >
    > I have even tried various method such as Clipping only the client[/color]
    region[color=blue]
    > using
    > Region r= new
    > Region(0,0,this .ClientRectangl e.Width,this.Cl ientRectangle.H eight);
    > g.Clip=r;
    >
    > and using
    > Rectangle dr=new
    >[/color]
    Rectangle(0,0,t his.ClientRecta ngle.Width,this .ClientRectangl e.Height);[color=blue]
    > g.DrawImage(Ima ge,dr,dr,Graphi csUnit.Pixel);
    >
    > but it stills does not achieve what I want.
    >
    >
    > Anyone have any idea how scroll very large image smoothly ?
    >
    > Thanks
    > Danial
    >
    >
    >
    >[/color]


    Comment

    Working...