how to avoid flicker when drawing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tetemke Gebre
    New Member
    • Feb 2016
    • 1

    how to avoid flicker when drawing

    I am working with C# graphics .I am drawing with elips.
    and I have timer that updates the cordinate of scanning line in every 27 milli second.when I start the timer the line starts sweeping the cirlce but at the same time the panal is also vibrating or flickering , which i don't want to do that.
    Code:
    void t_Tick(object sender, EventArgs e)
            {
                if (conobjcets.START == true)
                {
                    label5.Text = conobjcets.elapsedTime;
                    
                    
                    splitContainer2.Panel2.Invalidate();
                   
    
                }
    the obove cod is timer func
    Last edited by Rabbit; Feb 5 '16, 10:14 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    A coulple things to try, try DoubleBuffered on your panel like so

    Code:
    this.SetStyle(ControlStyles.AllPaintingInWmPaint |ControlStyles.UserPaint |ControlStyles.DoubleBuffer, true);
    Or BufferedGraphic s similar to this

    Code:
    System.Drawing.Graphics g = this.CreateGraphics();
            System.Drawing.BufferedGraphicsContext dc = new BufferedGraphicsContext();
            BufferedGraphics backbuffer = dc.Allocate(g, new Rectangle(new Point(0, 0), g.VisibleClipBounds.Size.ToSize()));
            backbuffer.Graphics.DrawImage(Image.FromFile(@"c:\test.jpg"), new Point(10, 10));
            backbuffer.Render(g

    Comment

    Working...