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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:05:20+00:00 2026-05-23T14:05:20+00:00

This is a follow on to my question How To Handle Image as Background

  • 0

This is a follow on to my question How To Handle Image as Background to CAD Application

I applied the resizing/resampling code but it is not making any difference. I am sure I do not know enough about GDI+ etc so please excuse me if I seem muddled.

I am using a third party graphics library (Piccolo). I do not know enough to be sure what it is doing under the hood other than it evenually wraps GDI+.

My test is to rotate the display at different zoom levels – this is the process that causes the worst performance hit. I know I am rotating the camera view. At zoom levels up to 1.0 there is no performance degradation and rotation is smooth using the mouse wheel. The image has to be scaled to the CAD units of 1m per pixel at a zoom level of 1.0. I have resized/ resampled the image to match that. I have tried different ways to speed this up based on the code given me in the last question:

public static Bitmap ResampleImage(Image img, Size size) {
            using (logger.VerboseCall()) {

                var bmp = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppPArgb);
                using (var gr = Graphics.FromImage(bmp)) {
                    gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
                    gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                    gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;                 

                    gr.DrawImage(img, new Rectangle(Point.Empty, size));
                }
                return bmp;
            }
        }

I guess this speeds up the resample but as far as I can tell has no effect on the performance when trying to rotate the display at high zoom levels. User a performance profiler (ANTS) I am able to find the code that is causing the performance hit:

 protected override void Paint(PPaintContext paintContext) {
            using (PUtil.logger.DebugCall()) {
                try {
                    if (Image != null) {
                        RectangleF b = Bounds;

                        Graphics g = paintContext.Graphics;

                        g.DrawImage(image, b);
                    }
                }
                catch (Exception ex) {
                    PUtil.logger.Error(string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace));
                    //----catch GDI OOM exceptions
                }
            }
        }

The performance hit is entirely in g.DrawImage(image, b);

Bounds is the bounds of the image of course. The catch block is there to catch GDI+ OOM exceptions which seem worse at high zoom levels also.

The number of times this is called seems to increase as the zoom level increases….

There is another hit in the code painting the camera view but I have not enough information to explain that yet except that this seems to paint all the layers attached to the camera – and all the objects on them I assume – when when the cameras view matrix and clip are applied to the paintContext (whatever that means).

So is there some other call to g.DrawImage(image, b); that I could use? Or am I at the mercy of the graphics engine? Unfortunately it is so embedded that it would be very hard to change for me

Thanks again

  • 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-23T14:05:20+00:00Added an answer on May 23, 2026 at 2:05 pm

    I think you you use,if I’m not mistake, PImageNode object form Piccolo. The quantity of calls to that method could increase because Piccolo engine traces “real” drawing area on the user screen, based on zoom level (kind of Culling) and draws only the nodes which are Visible ones. If you have a lot of PImageNode objects on your scene and make ZoomOut it will increase the quantity of PImageNode objects need to be drawn, so the calls to that method.

    What about the performance:

    1) Try to use SetStyle(ControlStyles.DoubleBuffer,true); of the PCanvas (if it’s not yet setted up)

    2) look here CodeProject

    Regards.

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

Sidebar

Related Questions

Background: This is a follow-up question to this thread about handling EINTR for system
I know this may not be exactly a coder question, but I feel it
This is a follow up question to a previous question I asked about calculating
This is a follow-on question from the one I asked here . Can constraints
This is a follow-up question to ASP.NET How to pass container value as javascript
This is a follow-up question to this question I asked earlier. Btw thanks Neil
this is a follow-up question of mine. Suppose now I have a URL :
This is a follow-up question to the following if you would like to see:
This is a follow-up question related to my previous post . Below is a
This is a follow-up question to this one . Consider this example: #include <iostream>

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.