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

  • Home
  • SEARCH
  • 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 9005757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:13:48+00:00 2026-06-16T01:13:48+00:00

I have a function that draw points on the screen. This function worked very

  • 0

I have a function that draw points on the screen. This function worked very well until I added the line with panelGraphics.RotateTransform. When this line is there, the process of doing one repaint is very long. My list of points contains about 5000 points and without the rotation, it’s done in a couple of milliseconds but with that line it could take up to 500 ms which is VERY slow. Do you have any idea why RotateTransform is so slow and also, what can I do to optimize this?

private void panel1_Paint(object sender, PaintEventArgs e)
{
    Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
    SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
    Graphics panelGraphics = panel1.CreateGraphics();

    panelGraphics.TranslateTransform((panel1.Width / 2) + _panW, (panel1.Height / 2) + _panH);

    //Problematic line...
    panelGraphics.RotateTransform(230 - Convert.ToInt32(_dPan), System.Drawing.Drawing2D.MatrixOrder.Prepend);

    PointF ptPrevious = new PointF(float.MaxValue, float.MaxValue);
    foreach (PointF pt in _listPoint)
    {
        panelGraphics.FillRectangle(myBrush, (pt.X / 25) * _fZoomFactor, (pt.Y / 25) * _fZoomFactor, 2, 2);
    }

    myBrush.Dispose();
    myPen.Dispose();
    panelGraphics.Dispose();
}
  • 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-06-16T01:13:49+00:00Added an answer on June 16, 2026 at 1:13 am

    The reason is that each rectangle has to be rotated. Rotation can be a slow operation, especially for none square angles.

    The better approach in this case is to first create a “hidden” bitmap which you draw the rectangles into. Then apply the rotation to your main graphics object and draw the hidden bitmap onto your main bitmap (control). Something like this –

    private void panel1_Paint(object sender, PaintEventArgs e)
    {
        Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
        SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
    
        Graphics panelGraphics = e.Graphics; //use the provided Graphics object
    
        // create an internal bitmap to draw rectangles to
        Bitmap bmp = new Bitmap(this.ClientSize.Width, _
                                this.ClientSize.Height, _
                                Imaging.PixelFormat.Format32bppPArgb);
    
        using (Graphics g = Graphics.FromImage(bmp)) {
    
            PointF ptPrevious = new PointF(float.MaxValue, float.MaxValue);
            foreach (PointF pt in _listPoint) {
                g.FillRectangle(myBrush, (pt.X / 25) * _fZoomFactor, _
                                         (pt.Y / 25) * _fZoomFactor, 2, 2);
            }   
        }
    
        panelGraphics.TranslateTransform((panel1.ClientSize.Width / 2) + _panW, _
                                         (panel1.ClientSize.Height / 2) + _panH);
    
        //Problematic line...
        panelGraphics.RotateTransform(230 - Convert.ToInt32(_dPan), _
                                      System.Drawing.Drawing2D.MatrixOrder.Prepend);
    
        panelGraphics.DrawImage(bmp, 0, 0); //adjust x/y as needed
        bmp.Dispose;
    
        myBrush.Dispose();
        myPen.Dispose();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that uses imagefilledellipse method (http://php.net/manual/en/function.imagefilledellipse.php) to draw plot points (circles)
I have a function that draw an image on graphics: private void DrawSmallImage(Graphics g)
I have some functions that use opengl to draw lines on the screen (health
So we have a function DrawPoint(x,y) that draws a point, we have to draw
I have a Line class composed of two Points of two ints each that
I have this very annoying issue, whenever i call a function: void renderGame::renderMovingBlock(movingBlock* blockToRender){
Inside my Controller i have function that runs after user clicks on item, which
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick

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.