Jump to content
How to Install Plugins ×

Primary Color Difference to Alpha

Recommended Posts

It calculates for every pixel the difference between the pixel and the primary color. The more they are equal, the more alpha will rest. Just duplicate your layer, do my effect with a Primary color selected, maybe some fine tuning with Curves+ alpha channel and there you go affecting only this specially colored part of the image without need of feathering or anything because it's always a smooth gradient from layer to change to the original image layer.

Download here: EffectDLL.zip

Unzip it into your Effects directory in the Paint.NET folder.

It will be listed under Effects -> Color



1 to 2: Here i first chose the sky's color as primary with the Color Picker :ColorPicker: then I ran my effect.

2 to 3: After that I did some alpha fine tuning with Curves+ :Curves: . And the only color effect I added to the sky was increasing saturation and a little hue adjustment :HueSaturation: .

3 to 4: I put the original image as a layer under the modified one.

Link to where you get Curves+

code (Codelab):

int dr,dg,db;

void Render(Surface dst, Surface src, Rectangle rect)
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);

   // Delete any of these lines you don't need
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;

   ColorBgra CurrentPixel;
   for(int y = rect.Top; y < rect.Bottom; y++)
       for (int x = rect.Left; x < rect.Right; x++)
           if (selectionRegion.IsVisible(x, y))
               CurrentPixel = src[x,y];
               dr = CurrentPixel.R - PrimaryColor.R;
               dg = CurrentPixel.G - PrimaryColor.G;
               db = CurrentPixel.B - PrimaryColor.B;
               if (dr < 0)
               if (dg < 0)
               if (db < 0)
               CurrentPixel.A = (byte)(255-((dr+dg+db)/3));
               dst[x,y] = CurrentPixel;

I'm currently searching for a good 16x16 png icon. Please tell me your ideas.

Link to comment
Share on other sites

Lol! I'm sorry but the revised pictures tell me what I already can do - run your plugin on the first picture.

But in your example there is a third picture: How do I get that effect from your second picture using the curves+ plugin? From what I can see, just using your plugin alone cannot get me the same end-result that you obtained using curves+ and the hue adjustment plugins.

Tried running the curves + plugin but could never get to the third picture.

Link to comment
Share on other sites

Your curves+ must be set to alpha mode. Then your curve should look something like that


Then when only the parts of the image which you want to modify are still visible, you can run any effect, in my case Hue/Saturation. But you could also do any other effect to the sky or the part of your image, which you selected.

Link to comment
Share on other sites

  • 2 weeks later...
Can you post the .dll file?

WinZip won't unzip anything anymore :|

Is there a free alternative to WinZip?

Windows has had built-in ZIP file support since XP. You don't need WinZip or any other program to open it... For other kinds of archives, though, try 7-zip.


ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Windows has had built-in ZIP file support since XP.

I think it has ZIP support even in ME, but you have to install it seperately from the cd. However, programmes for ZIP can just be found via web search. 7 Zip is good, but you should try to get a stable version. There are only betas released for a while.

Link to comment
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.

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...