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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:35:11+00:00 2026-05-31T02:35:11+00:00

Well im rendering the same path 2 times one time with a white brush

  • 0

Well im rendering the same path 2 times one time with a white brush on a black background and one with a black brush on a white background.

Now the result should be the same image but inverted right?

Well wrong the one that’s drawn on the black background is a few pixels bigger..

enter image description here
enter image description here

Diff

enter image description here

Code i used to draw these

PointF[] points = LoadXml<PointF[]>(@"T:\Points.xml");
byte[] types = LoadXml<byte[]>(@"T:\Types.xml");
GraphicsPath path = new GraphicsPath(points, types, FillMode.Alternate);
using (Image image = new Bitmap(45, 45))
{
    using (Graphics g = Graphics.FromImage(image))
    {
        Render(g, Color.White, Color.Black, path);
    }
    image.Save(@"T:\White.bmp", ImageFormat.Bmp);
}
using (Image image = new Bitmap(45, 45))
{
    using (Graphics g = Graphics.FromImage(image))
    {
        Render(g, Color.Black, Color.White, path);
    }
    image.Save(@"T:\Black.bmp", ImageFormat.Bmp);
}

private static T LoadXml<T>(string file)
{
    System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
    using (Stream stream = File.OpenRead(file))
    {
        return (T)xmlSerializer.Deserialize(stream);
    }
}

private static void Render(Graphics g, Color mainColor, Color backColor, GraphicsPath graphicsPath)
{
    g.CompositingQuality = CompositingQuality.HighQuality;
    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
    g.SmoothingMode = SmoothingMode.HighQuality;
    g.InterpolationMode = InterpolationMode.HighQualityBilinear;

    g.Clear(backColor);
    using (SolidBrush mainBrush = new SolidBrush(mainColor))
    {
        g.FillPath(mainBrush, graphicsPath);
    }
}

Is there any way to make them render the same way without modifying the path?

  • 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-31T02:35:11+00:00Added an answer on May 31, 2026 at 2:35 am

    Atmittedly, I am just guessing, but:

    It could be the result of GDI+ attempting to do gamma-correct rendering. (I didn’t check that it does).

    Historically, display monitors are non-linear. So a pixel with a grayscale value of 255 is much more than twice as bright as a pixel with value 128. So, if you are trying to anti-alias a line, and want a draw a pixel that is 50% covered with white, a pixel with value 128 is too dark. It is more like 25% white. To get a 50% white pixel, you should take a value around 180 (I don’t remember exactly).

    This would cause the white image to be half a pixel larger than the black one, if you compare it to the inverse.

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

Sidebar

Related Questions

Well, after a long time writing .net programs in C# I started to feel
Well, what is one?
When I render to texture, and then draw the same image, it seems to
My pie chart is rendering pretty well (labels are smashed to the far right
I'm rendering 3 different polygons with the same smiley texture. The texture is a
I'm repeatedly rendering a UIView to an OpenGL texture. Things are working well on
Well the subject is the question basically. Are there any version control systems out
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed.
Well behaved windows programs need to allow users to save their work when they
Well, this is my first post here and really enjoying the site. I have

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.