What's coming in Paint.NET v3.35

This next update to Paint.NET will fix the usual set of small bugs, introduce a new adjustment (Posterize), fix a major performance blemish related to selections, and add an Intersect selection mode.

As for the small bug fixes, turns out there’s the possibility that Paint.NET will crash if malformed data is in the clipboard from, of all things, certain WPF-based applications. For effects that use IndirectUI, there was a problem with "linked" sliders (using LinkValuesBasedOnBooleanRule). And, it was possible to get around some of the protections that IndirectUI put up to protect Paint.NET from certain types of plugin code. Currently this only seems to affect the Fern Fractal plugin. I’ve e-mailed the author and helped him to find a way to accomplish what he wanted without "breaking the rules," so to speak.

Posterize is an adjustment written by Ed Harvey. It allows you to restrict each of the red, green, and blue channels to only have between 2 to 64 discreet values. Normally each channel has up to 256 values … 0 through 255, which is the range for a byte. This can be useful to give your image a "faux-dithered" look, although of course there are many other creative ways to use it.

Selection performance has been a major sore point in Paint.NET over the last 3 years or so. The initial drawing of a selection is fine — it’s when you go to use union (add) or difference (subtract) combination modes that things get froggy. Really froggy. As in slow. Pathetically slow.

We’ve been using a very brute force algorithm that converts the selection to a bit-mask, then performs the boolean operations on each bit, and then traces the bitmask to recreate a selection path (selections in Paint.NET are stored as a a polygon list). This causes these operations to have performance that is proportional to the number of pixels in the area where the selection is located (its bounding rectangle, actually). On a large or even medium-sized image, these are immediately prohibitve to use. This algorithm was originally developed for use by the Magic Wand tool so that we could do per-pixel tolerance, and then convert back to the polygon representation that was required everywhere else in the application.

There are algorithms that have been developed with let you do boolean algebra operations on the polygons themselves, optimizing away this very hacky (albeit correct!) way of doing things. One such algorithm is detailed in a 1992 paper by Bala R. Vatti titled, "A Generic Solution to Polygon Clipping." This is the algorithm implemented in the GPC (General Polygon Clipper) library written by Alan Murta from the Computer Science department at the University of Manchester in England. There are other algorithms that have been developed since, such as the one described in a 1998 paper by Günther Greiner and Kai Hormann titled, "Efficient Clipping of Arbitrary Polygons".

I have read both papers and tried to implement both of the algorithms. I have tried this several times, and have come close to completion but never quite made the leap to full comprehension, nor a finished implementation. I never had more than an evening or two in a row to devote to this pursuit — by my estimate, I would need at least a full two or three weeks. Maybe even a full month. These papers are from the academic world, and I haven’t had much practice there for quite some time! As such, the papers are very dense (in a good way) and require many readthroughs to fully understand.

I was never able to find a good implementation of the second algorithm by Grenier and Hormann, which was desirable because it was simpler and supposedly more efficient. In the end, GPC by Alan Murta won out: like previously mentioned, it is an implementation of Vatti’s algorithm, in C. It has been around for quite awhile and has needed no major revisions in many years. So, from an integrator’s standpoint (me!), it is the simplest and safest solution. I am happy to say that I have just purchased a Commercial Use license from the University of Manchester and that the next update to Paint.NET will be using it to substantially increase performance for selections!

This is a simple case of pragmatism versus idealism: ideally, I would have the time, the patience, and the mental acuity to implement these. In practice, it would take so long to do this myself that the cost of a Commercial Use License is actually the cheaper alternative. So for everyone who has donated to Paint.NET, this is how I’m using your money 🙂 This does affect anyone interested in using the Paint.NET source code for their own commercial purposes: if you need any of the code related to selection stuff, you will have to purchase your own Commercial Use License from the University of Manchester.

The only way to get a feel for the performance increase is to cheat a little, with the current version of Paint.NET. Boot it up and create a 1024×768 image. Now, draw a circle selection that encompasses the whole image. Next, go to the toolbar and where it says "Selection Mode:", click on the down-arrow and choose "Subtract." Next, Draw another circle that is inside of the one you just draw. It’s very very slow. Next, undo this foolish thing you just did. Set the "Selection Mode:" to be "Invert (xor)" (this is the one mode that GDI+ gives you for free!). Now draw that second circle again and notice how smooth everything is. In the next update, this performance will also be there for Add (Union) and Subtract! The usability improvement is real and honest, and I think everyone will really like it.

Next, I’ve decided to add an Intersect selection mode. I’m not sure why I never did this before, to be honest. It was trivial to do, especially since GPC supports it right out of the box. Many other drawing programs offer this — it simply makes sure that the result of combining two selections is the area in which they overlap.

Last, I’m reassigning the keyboard shortcuts for the selection modes. Before, you would hold Control for Add/union, hold the right mouse button for Subtract/difference, and Control+Right for Invert/Xor. These are kind of weird, and non-standard, and plus I needed a key for Intersect. So, in the next update the shortcuts will be Control for Add/union, Alt for Subtract/difference, Control+Right mouse button for Invert/Xor, and Alt+Right mouse button for Intersect.

I’m hoping to have a beta of v3.35 out within a few weeks, and the final release in early-to-mid July.

Advertisements

41 thoughts on “What's coming in Paint.NET v3.35

  1. Mike says:

    Can’t wait to play with 3.35 🙂

    As always, keep up the good work. Seems like I had 3.31 for ages (though now I’m starting to wonder what’s up with the version number jumps (ie: 3.31 to 3.35)). Still, no complaints here (since the one feature I do want is in the “Frequently Asked for Features” possibly slated for v4.0 and yes I can wait patiently).

  2. Mike Ryan says:

    @Mike, in the past Rick would usually give a .02 bump if a new effect was released or anything like that. So, we have a +.02 for Posterize and a +.02 for Intersection.

  3. Rick Brewster says:

    The “bump amount” is admittedly arbitrary, to an extent — I try to find a number that I feel gives the right impression as to the amount of improvement. A +0.01 bump is strictly for bugfix releases, however. Right now I am doing small improvements to the 3.xx codebase so that I can “buy time” for working on 4.0.

  4. Johannes Rössel says:

    Nice to see an improvement coming there, I have to admit, I noticed the performance degradation there several times now, but one thing is also pretty ugly, performance-wise: The moving lines around the selection. Granted, they’re nice for a single rectangular or circular selection but for really large and/or complex selections things get much worse.

    As a quick test to try it out: Start with a fresh image, use Add Noise in default settings, use magic wand with 30 % tolerance and global flood mode.

    This is enough to slow down PDN to a crawl on my system (Core 2 Duo, 2 GHz) and it’s apparently done by the UI thread, so menus won’t come up immediately, reaction to mouse clicks and key presses are delayed severely, etc.

  5. Pat VanDusen says:

    For 4.0, do you think you plan on writing your own implementation of the selection algorithm at that point?

    I’m no evangelist, and I wouldn’t presume to tell you how to develop your program. I just know that if it were me, and I were the sole developer of such a popular and powerful tool, I’d probably want to depend on foreign code as little as possible.

  6. Mike Ryan says:

    @Pat VanDusen, to the extent of my knowledge, he isnt actually using ‘foreign code’ as much as he is actually using the math for it, and once you use the improved tools I think you will find that there isnt going to be much better 😉

  7. Pat VanDusen says:

    @Mike Ryan, I’m sure the code he’s using is of the best quality, otherwise he wouldn’t have used it.

    I just know how I would feel about resorting to something like that, and I just wondered if he was considering doing his own implementation for a major revision like 4.0.

  8. Rick Brewster says:

    Pat, using the GPC code is a good thing. It was developed by someone who thoroughly understands the algorithm. The code has been unchanged for awhile, because it has needed no fixes. The interface into the code is exactly what I need. So, in this case, it’s exactly what I should be doing. There’s no need to worry that it is “foreign code,” as I am compiling it and can maintain it myself going forward. I’m not “resorting” to using it. C’mon, should I be writing my own C# compiler too? 🙂

  9. Pat VanDusen says:

    Thanks Rick, I understand your position. It isn’t what I would do, but I don’t develop Paint.NET, now do I? =P

  10. Dark says:

    man, what about the
    “Ability to organize/manage effects”
    it’s really something needed

  11. Francis Scully says:

    What benefit is there to have text automatically rasterize? Is it difficult to keep the text layer as text rather than a raster image?

  12. Tori says:

    How about, in the next update, adding a blur tool? That would solve so many problems, for me.

    🙂

  13. PBnJ says:

    Can’t wait to try the update out! Thanks for supporting such a great piece of software AND offering it for free.

  14. frank says:

    i like it but u should add a remove backround tool in the next update plez i would be so thankful

  15. Ron Hollenbeck says:

    This is a great paint program. It would be nice to have a SMUDGE tool.
    The copy or clone tool could be improved. I have seen clone tools that you can use by placing the cuser in a source picture and then place the target curser in a diffrent picture all on the same layout.

    I will be happy to support this program thru Paypal.

    THANKS

  16. heather says:

    I was wondering if you could get a burn and a dodge feature like on Photoshop. I Prefer to use paint.net than photoshop but this is two of the features i miss.
    thanks in advance. thank you so much for providing a program like this for free. it helps those of us photographers who are just starting out!!

  17. Rick Brewster says:

    o_z — Yes, I found that implementation of the Grenier+Hormann algorith, but for various reasons (which I don’t remember right now), the code was not useful.

    GPC has the added benefit of being tried and tested — it is used in other significant software projects. So, I have faith in its stability and correctness, even if the performance potential of its algorithm is less than that of Genier+Hormann’s.

  18. leanne says:

    can you draw on this i am 14 and only just downloaded this and it is just a confuzzled part of me tht is asking can i draw japanese anime on this you know like the cartoons?

  19. Rick Case says:

    This selection fix is excellent, as are the new key-mappings. Thanks so much.

    I always appreciate the program so much, especially comparing it to Paint rather than to Photoshop. I love it. And these developments you continue to add only sweeten the package.

  20. Lauren T says:

    Hi Rick thank you so much for your hard work you have helped so many people and it is inspiring that you have advanced this FREE program into a great photoshop alternative. Thank you so much! Great additions, keep up the good work. I owe you much gratitude as I have created successful professional marketing tools for my business.
    -L

  21. Jeff says:

    This program would be perfect if you had the option to adjust shadows and high lites.

    Add this feature.

  22. erika says:

    Paint.net is great i was wondering if there is editing to cover up blemishes(redness on face, acne, dark circles etc…) Paint.net edited my pictures beautifully and great effects way better then paint! Thank you*

  23. Hector Estrella says:

    i wander if one of these days the tool guidelines or something like that will be part of paint.net like in wordperfect draw when you have the rulers on the top and side in either inches or centimeters and you can pull a horizontal line and a vertical line for dimensions guideline and draw on them or snap a line to them. again it is very helpful when you want to draw to scale. Just my two cents!

  24. Trevor Berrington says:

    it would be very nice to take the toolbars and attach them into the main toolbar at the top or side instead of having them “float” But besides that the program is wonderful im very surprized to see such a great program for free i would also like to see some more effects but im not gonna cry about it lol Good Job

  25. kevin says:

    Canvas size crops all layers to the input size… Thus making it kind of a useless feature.. Am I missing something? Other than that, thanks for a great program!

  26. Dan says:

    @kevin:
    Canvas Size doesn’t just crop all layers. I mostly use it to add whitespace around an image. It’s the best way to make a larger canvas without resizing the image.

  27. Mick says:

    Just downloaded the new version of paint.net. As I ama new to this can you remove text print conatined within a scanned picture using this software?

  28. Ethel Bennecoff says:

    I haven’t even used your softwear yet, and I want to say thank you for all the work you have done. I have absolutely no complaints or comments and never will. Thank you. Ethel

Comments are closed.