1 Replies - 4963 Views - Last Post: 11 May 2012 - 02:33 AM

#1 JohnBoyMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 24-February 12

double buffereing code help

Posted 05 May 2012 - 07:38 PM





Hello all . I used to problems with my program shaking when i mioved it off screen. I found code thats supposed to fix it . It came from some program i was tinkering with. Its had many complex textures and all added to its form and the form didnt shake when i move it off screen. I cant seem to find any good explanations or working code for double buffering anywhere i was wondering if somone could help me with what i have found so far ont he topic.

This is the code i dont udnerstand but seems to work for a program.


protected override void OnPaint(PaintEventArgs e){
			// Create an offscreen graphics object for double buffering
			Bitmap offScreenBmp = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
			using (System.Drawing.Graphics g = Graphics.FromImage(offScreenBmp)) {
				g.SmoothingMode = SmoothingMode.HighQuality;
				// Draw the control
			//	drawControl(g);                                         
				// Draw the image to the screen
				e.Graphics.DrawImageUnscaled(offScreenBmp, 0, 0);
			}
		}




Its in c but my main project is cli, so ill rewrite it in a minute if need be. The function draw control draws an led light with the g->drawline and other draw functions. In my main form in the InitializeComponent() function at the end i wrote this too.

this->DoubleBuffered = true;



Now that first chunk of code is supposed to work with this->DoubleBuffered = true; it says in the code. I can understanding how to draw an offscreen shape but i dont understand how i would apply this to somthing like a panel instead of drawing that led. Would i create an offscreen image of the texture i want to use in my form then add it to the panel?

thanks for any advice this topic is confusing and undocumented, it required another level of forms understand that i dont have yet, thanks for any tips.

Is This A Good Question/Topic? 0
  • +

Replies To: double buffereing code help

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3169
  • View blog
  • Posts: 9,595
  • Joined: 05-May 12

Re: double buffereing code help

Posted 11 May 2012 - 02:33 AM

This article may help you out more: http://www.switchont...ouble-buffering
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1