Jump to content

Recommended Posts

                int maxArea = GetMaxAreaForRadius(rad);

Hi! What is the point of this line???

If it's not used then it's either there from past or for future use.

And, BTW, what is minus in:

                int top = -Math.Min(rad, y);

-1 * Math.Min ?

Just a plain old negative sign...

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to post
Share on other sites

        public static byte ClampToByte(double x) 
       {
           if (x > 255)
           {
               return 255;
           }
           else if (x < 0)
           {
               return 0;
           }
           else
           {
               return (byte)x;
           }
       }

another thing. i think the next code is some better :D :wink:

public static byte ClampToByte(double x) 
{
       return (byte)Math.Min(Math.Max(x, 0), 255);
}

That line of code does impact performance, but otherwise causes no harm.

Why this line was there? Is it a part of the algorithm ?

ANd, where i can read about used algoritm for Reduce Noise Effect. Thanks :wink:

Link to post
Share on other sites

Regarding ClampToByte, correct. There is really no benefit to nesting calls to Math.Min/Math.Max, although it may be more succinct that way. The benefit is in having the ClampToByte method in the first place, and there isn't much to be had by changing the way it's implemented.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to post
Share on other sites

Right but those are function calls, which may or may not be inlined.

The performance will be "the same or worse." In any case it doesn't really matter, we could creatively debate this all day :)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to post
Share on other sites
we could creatively debate this all day :)

my time is over midnight already (1:18 am) :)

                    if (intensity + this.brightness < 128)
                   {
                       this.rgbTable[intensity] = 0;
                   }
                   else
                   {
                       this.rgbTable[intensity] = 255;
                   }

into

this.rgbTable[intensity] = (intensity + this.brightness < 128) ? 0 : 255;

:P:D

p.s. i like simplicity very match :D

Link to post
Share on other sites

I'm not sure if that applies to something like Int32 or Byte though.

In any case, w/ .NET 3.5 SP1 + .NET 2.0 SP2 it will all be fixed. Should provide a very healthy performance boost for Paint.NET, as just inlining methods involving the ColorBgra class will be a huge benefit.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to post
Share on other sites
I'm not sure if that applies to something like Int32 or Byte though.
No, 'built-in' types such as integer and floating point numbers are exempt from this limitation. Interestingly however, the System.Math methods are not inlined. I'm not 100% sure why, perhaps because they are ngen'd or in the CAG ?
In any case, w/ .NET 3.5 SP1 + .NET 2.0 SP2 it will all be fixed.
Cool. Last I heard they weren't due to fix that until the next version bump, so if it'll get into the SP that will be excellent... 8)
Should provide a very healthy performance boost for Paint.NET, as just inlining methods involving the ColorBgra class will be a huge benefit.
Certainly will help :D (at least for the smaller, more commonly used, methods)

ed-sig2.png.3c040e8f8a7b22d05fbfbad8e5ea6994.png

Link to post
Share on other sites
I'm not sure if that applies to something like Int32 or Byte though.
No, 'built-in' types such as integer and floating point numbers are exempt from this limitation. Interestingly however, the System.Math methods are not inlined. I'm not 100% sure why, perhaps because they are ngen'd or in the CAG ?

(I assume by CAG that you mean GAC :))

I know that, at least for 64-bit, there was an issue with some of the Math methods where performance was grossly lower than it should have been. I'm not sure if that's been fixed or if it's slated for the 3.5 SP1 / 2.0 SP2 release.

I've always meant to experiment with isolating some of the Render() functions into a C DLL and P/Invoking them, but I just never get around to it. Would be fun to try out SSE4.2 optimization as well; I guess I've bet more on multithreading for performance than on assembly language. I think I made the right cost trade-off... here comes Intel's Nehalem with 8-cores on the desktop for Q4 2008 :)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...