BoltBait.com

Effects Design Overview

How Paint.NET renders your effect


For the most basic scenario, that is when the selected effect doesn't have a user interface (UI), when you select an effect from Paint.NET's menu, it does two basic things: (1) it breaks up your current selection into rectangles of selected pixels, and (2) it calls that effect's main function once for each of those rectangles. Let's examine each of those things in turn:


Tiles

When Paint.NET gets ready to call an effect, it breaks up the current selection into convenient work units (rectangles, really). We call these rectangles Tiles. Here's how Paint.NET might break up a circular selection into individual Tiles:


Each color represents a different Tile. They are typically 128px wide by 128px tall. They can be different sizes.


Main Function

The reason Paint.NET breaks up the selection into Tiles and calls the main function with each individual Tile is for efficiency. Each call to the main function is done in it's own thread. Therefore, if your CPU has multiple cores, Paint.NET will take advantage of that by utilizing all of your cores to complete the effect as quickly as possible.

If all of this sounds very complicated and overwhelming, don't worry--you don't have to write the code that makes all of the muti-threading possible. That part is done for you. In order to create an effect, all you need to do is write the main function itself... and we have several templates to get you started!

There are three basic types of effects we can write using CodeLab:

Bitmap - This is the simplest type. It allows individual access to each pixel.
Image - This is the most common. It allows chaining GPU accelerated effects.
Drawing - This type allows rendering GPU accelerated lines, shapes, and text.

Each type of effect has a different main function name

Bitmap has a main function called OnRender() with color type SrgbColors
Image has a main function called OnCreateOutput() with color type LinearColors
Drawing has a main function called OnDraw() with color type LinearColors

You don't have to memorize this, CodeLab has a template for each type of effect to get you started.

NOTE: While it is possible to write Paint.NET plugins in different languages, most plugins are written in C#.NET and are developed using the CodeLab plugin. If you have not already done so, install the CodeLab plugin so that you can follow along with the lessons presented here.

I will not tell you that figuring out the algorithm for a desired effect is easy. But, once you complete all of the lessons here, you might find that it isn't as hard as you had imagined.


Let's Get Started!

Now that you have a basic understanding of how Paint.NET works with effects, I think you're ready to take a look at each of these effect types in turn:

How to write a Paint.NET Bitmap plugin ← start here!
How to write a Paint.NET GPU Image plugin
How to write a Paint.NET GPU Drawing plugin



Donate

The best way to say "Thanks" for teaching you something here, is to fill out this form. It uses PayPal to process your donation. You don't need a PayPal account, just a credit/debit card will do. If PayPal doesn't work for you, no need to worry--just enjoy the tutorials for free!

$
Thank you for your donation. I don't get many, so you can be sure I really appreciate yours!



 

 
 

News



CodeLab 6.12 Released
(February 11, 2024)
This latest release of CodeLab for Paint.NET includes the ability to write GPU accelerated plugins.
More...

Double-Six Dominoes 3.1
(May 10, 2021)
This long-awaited refresh of the most popular dominoes game on Download.com is now available!
More...

HTML Editor 1.5 Released
(March 31, 2016)
This latest release is a complete rewrite adding a wysiwyg editor mode and a much improved UI.
More...