Rainbow flower

Posted by Dan on Mar 20th, 2009
2009
Mar 20

RF500Sig

 

Lately I’ve been playing with Paint.Net, yet another paint program.  This one is free, but not open-source.  It allows people to write plug-ins in C#, my favorite language for image manipulation.  CodeLab is a plug-in that helps you write plug-ins.  CodeLab is free and open-source.

 

It’s hard to describe how enticing to a computer nerd the idea of “tools to build tools” is.  It’s Nerd Heaven!  The only thing better than tools to build tools would be tools to build tools to build tools.

 

But let’s put CodeLab to the test.  I want to shuffle the colors in an image.  I want to replace the reds with greens, the greens with blues and the blues with reds.  Here is the code inside CodeLab:

 

void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra CurrentPixel;
    ColorBgra NewPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            NewPixel = CurrentPixel;
            NewPixel.R = CurrentPixel.G;
            NewPixel.G = CurrentPixel.B;
            NewPixel.B = CurrentPixel.R;
            NewPixel.A = CurrentPixel.A;
            dst[x,y] = NewPixel;
        }
    }
}

 

This was so easy that I wrote a few more plug-ins.  Here is how they look in the Paint.Net menu:

 

PaintNet

 

The rest is anticlimactic. I took a digital photo of a flower, reduced it to six different sizes, and used my new plug-ins to color-shift each size in a different way. I stacked the flowers and flattened the layers.