Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3393610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:04:16+00:00 2026-05-18T04:04:16+00:00

I’m currently working on the user interface of a win forms application. The primary

  • 0

I’m currently working on the user interface of a win forms application. The primary window is a borderless form whose surface area is almost entirely rendered in the Form.Paint event. A back buffer is created and it’s drawn fairly conventionally:

private void form_Paint(object sender, PaintEventArgs e) {
  e.Graphics.DrawImage(BackBuffer, e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);
}

Certain regions of the back buffer get redrawn under various conditions; mouse-over effects are quite common. The class which does redrawing carefully invalidates only applicable areas. In spite of this, simply swiping the mouse across the form is enough to crank a high-end CPU to > 50% usage for several seconds.

I’ve profiled the application and well over 80% of the CPU time is being burnt on the call to DrawImage above. I knew that GDI+ is slow and employs no (little?) use of GPU… and the target platform for the application makes no guarantee that the GPU wont be integrated in the first place. But I had no idea that it was this bad.

Should I face the fact that GDI+ is just not fast enough for what we wish to do, or is there an opportunity for improvement in the code, still?

-edit-

BackBuffer represents a bitmap which is created during system startup. Its size matches the screen resolution. Various regions are drawn on it during a variety of events such as mouse overs and clicks. It is created rather simply:

this.BufferBmp = new Bitmap(screenWidth, screenHeight);
this.Gfx = Graphics.FromImage(BufferBmp);

Gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:04:17+00:00Added an answer on May 18, 2026 at 4:04 am

    Creating your own ‘back buffer’ instead of using the built-in support for double-buffering is very hard to get performant. What matters a great deal is the pixel format of the buffer. On most any modern machine, any I tried anyway, the 32bppPArgb format is ten times as fast as any other. Favor the built-in double-buffering support for its superior perf.

    Another possible loss is your attempt to keep the clipping region as small as possible. That can byte when the region gets complicated. It sounds like you’re close to that if you let fast mouse movement generate small rectangular update regions. When the painting falls behind, it almost always will since the mouse gets a higher priority, you could build up a pretty intricate chain of small rectangles. First test this by just invalidating the entire area. Next approach is to expand the area yourself, always keeping it a single rectangle. Reset that when OnPaint runs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.