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 729681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:49:29+00:00 2026-05-14T06:49:29+00:00

I have problems with WPF drawing performance. There are a lot of small EllipseGeometry

  • 0

I have problems with WPF drawing performance. There are a lot of small EllipseGeometry objects (1024 ellipses, for example), which are added to three separate GeometryGroups with different foreground brushes. After, I render it all on simple Image control. Code:

DrawingGroup tmpDrawing = new DrawingGroup();
GeometryGroup onGroup = new GeometryGroup();
GeometryGroup offGroup = new GeometryGroup();
GeometryGroup disabledGroup = new GeometryGroup();

for (int x = 0; x < DisplayWidth; ++x)
{
    for (int y = 0; y < DisplayHeight; ++y)
    {
        if (States[x, y] == true) onGroup.Children.Add(new EllipseGeometry(new Rect((double)x * EDGE, (double)y * EDGE, EDGE, EDGE)));
        else if (States[x, y] == false) offGroup.Children.Add(new EllipseGeometry(new Rect((double)x * EDGE, (double)y * EDGE, EDGE, EDGE)));
        else disabledGroup.Children.Add(new EllipseGeometry(new Rect((double)x * EDGE, (double)y * EDGE, EDGE, EDGE)));
    }
}

tmpDrawing.Children.Add(new GeometryDrawing(OnBrush, null, onGroup));
tmpDrawing.Children.Add(new GeometryDrawing(OffBrush, null, offGroup));
tmpDrawing.Children.Add(new GeometryDrawing(DisabledBrush, null, disabledGroup));
DisplayImage.Source = new DrawingImage(tmpDrawing);

It works fine, but takes too much time – >0.5s on Core 2 Quad, >2s on Pentium 4. I need <0.1s everywhere. All Ellipses, how you can see, are equal. Background of control, where is my DisplayImage, is solid (black, for example), so we can use this fact. I tried to use 1024 Ellipse elements instead of Image with EllipseGeometries, and it was working much faster (~0.5s), but not enough. How to speed up it?

Regards,
Oleg Eremeev

P.S. Sorry for my English.

  • 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-14T06:49:29+00:00Added an answer on May 14, 2026 at 6:49 am

    I left my old rendering method, but creating new EllipseGeometry object each time was bad idea, so I optimized it in this way:

    for (int x = 0; x < newWidth; ++x)
    {
        for (int y = 0; y < newHeight; ++y)
        {
            States[x, y] = null;
            OnEllipses[x, y] = new EllipseGeometry(new Rect((double)x * EDGE + 0.5f, (double)y * EDGE + 0.5f, EDGE - 1f, EDGE - 1f));
            OffEllipses[x, y] = new EllipseGeometry(new Rect((double)x * EDGE + 0.5f, (double)y * EDGE + 0.5f, EDGE - 1f, EDGE - 1f));
            DisabledEllipses[x, y] = new EllipseGeometry(new Rect((double)x * EDGE + 0.5f, (double)y * EDGE + 0.5f, EDGE - 1f, EDGE - 1f));
        }
    }
    
    // . . .
    
    DrawingGroup tmpDrawing = new DrawingGroup();
    GeometryGroup onGroup = new GeometryGroup();
    GeometryGroup offGroup = new GeometryGroup();
    GeometryGroup disabledGroup = new GeometryGroup();
    
    for (int x = 0; x < DisplayWidth; ++x)
    {
        for (int y = 0; y < DisplayHeight; ++y)
        {
            if (States[x, y] == true) onGroup.Children.Add(OnEllipses[x, y]);
            else if (States[x, y] == false) offGroup.Children.Add(OffEllipses[x, y]);
            else disabledGroup.Children.Add(DisabledEllipses[x, y]);
        }
    }
    
    tmpDrawing.Children.Add(new GeometryDrawing(OnBrush, null, onGroup));
    tmpDrawing.Children.Add(new GeometryDrawing(OffBrush, null, offGroup));
    tmpDrawing.Children.Add(new GeometryDrawing(DisabledBrush, null, disabledGroup));
    DisplayImage.Source = new DrawingImage(tmpDrawing);
    

    For x = 128 and y = 8 it works really fast, even on Pentium III systems.

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

Sidebar

Related Questions

If I have problems with WPF, then it always concerns the Focus-Management. There are
I'm writting a WPF program.And now i have some problems. There is a Window
I have problems with the performance of the UI of my WPF application on
I have problems with my current application which is developed in C# with WPF.
I have been creating a drawing app as a test for WPF, and have
I have a WPF data grid and an xmlString and am having problems binding
I work with the MAF in WPF and I have problems with the UI
I'm fairly new to WPF and I have some problems getting databinding to work
I have been using WPF for a new project which is far from done.
I have been having real problems getting the WPF designer to work in VS

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.