Jump to content
How to Install Plugins ×

Primary Color Difference to Alpha


Enormator

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

example:

all9f9b7.png

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)
                dr=-dr;
               if (dg < 0)
                dg=-dg;
               if (db < 0)
                db=-db;
               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

Hmm...

WOOT! It's Curves+ alpha tweaking made simple, in some sort.

No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio

Link to comment
Share on other sites

You can use it always when you want to edit a picture. Use instead of a selection to get a better gradient without feathering.

You are the artist. I just wrote this plugin to use it for my self and because I'm a nice guy, I posted it here.

For creativity, ask god :P

Link to comment
Share on other sites

You can use it always when you want to edit a picture. Use instead of a selection to get a better gradient without feathering.

You are the artist. I just wrote this plugin to use it for my self and because I'm a nice guy, I posted it here.

For creativity, ask god :P

Thanks for answering Enormator. I'll give it a shot! :D

Link to comment
Share on other sites

It looks like it makes the image more vivid to me.

I likey!

[E to the d-it]Whoops, nevermind, I just read right after the pictures. My bad.

Asking god for creativity :oops:

Sig-1.png
Link to comment
Share on other sites

Hi Enormator,

I really don't know how you managed to use the curves+ plugin to change your second picture into the third with bleached buildings against a blue sky!

Must be more than just fine adjustments with curves and little fine-tuning with hues!!!

Link to comment
Share on other sites

Hi Enormator!

I'll take the risk of revealing my ignorance by telling you that I don't know how to change the second picture to the third, nor the third to the fourth in the example that you gave!!

Wonder if you could explain the steps but if it's too bothersome, it's alright.

Link to comment
Share on other sites

No of course it's not to bothersome :)

It's always good, when people ask because I tend to explain in a quite ununderstandable way.

EDIT: I redid the explanation of the example in first post. Is it understandable now? Please ask because I can't see your thoughts. :wink:

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

Nice idea. Thank you. I renamed the thread and the Effect. It's now in the Color Submenu.

I'm searching for a good 16x16 png icon for the Effect. If you have a good idea, pleas post here.

Redownload the dll to make the changes apply.

Link to comment
Share on other sites

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.

xZYt6wl.png

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.

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