Jump to content

Simple Color Swap Plugin?


Vermiculus

Recommended Posts

Isn't there a plug-in that will simply swap the alpha channel with a grayscale value?

It would be simple to make...

RRGGBB-->AA

FFFFFF-->FF

ABABAB-->AB

161616-->16

000000-->00

and so on...

I found the Color to Alpha <http://paintdotnet.forumer.com/viewtopic.php?f=16&t=25155&hilit=advanced> plugin, but that is too complicated really.

CodeLab makes me giddy inside :)

EnisityLogo3_small.jpg

Link to comment
Share on other sites

I made a plugin that does exactly what you want.

Let me see if I can find it.

EDIT: Here it is...

// Author: BoltBait
// URL: http://www.BoltBait.com/pdn
// Name: Alpha to Gray
// Submenu: Object
#region UICode
byte Amount1 = 0; // Convert|Alpha to Gray|Gray to Alpha
bool Amount2 = false; // [0,1] Invert calculation
#endregion

private UnaryPixelOps.Desaturate desaturateOp = new UnaryPixelOps.Desaturate();

void Render(Surface dst, Surface src, Rectangle rect)
{
   ColorBgra CurrentPixel;
   for (int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           CurrentPixel = src[x,y];
           switch(Amount1)
           {
               case 0: // Alpha to Gray
                   CurrentPixel.R = CurrentPixel.A;
                   CurrentPixel.G = CurrentPixel.A;
                   CurrentPixel.B = CurrentPixel.A;
                   CurrentPixel.A = (byte)255;
                   if (Amount2)
                   {
                       CurrentPixel.R = (byte)(255-CurrentPixel.R);
                       CurrentPixel.G = (byte)(255-CurrentPixel.G);
                       CurrentPixel.B = (byte)(255-CurrentPixel.;
                   }
                   break;
               case 1: // Gray to Alpha
                   CurrentPixel.A = (byte)(255-(desaturateOp.Apply(CurrentPixel).R));
                   if (Amount2)
                   {
                       CurrentPixel.A = (byte)(255-CurrentPixel.A);
                   }
                   break;
           }
           dst[x,y] = CurrentPixel;
       }
   }
}

Are you familiar with CodeLab? If not, here is the effect DLL:

Alpha2Gray.zip

Place it into your C:\Program Files\Paint.NET\Effects folder and unzip the file.

If you have trouble installing this, post your troubles here: viewtopic.php?f=16&t=2023

By the way, did you know that this type of thing is really easy with pyrochild's Curves+ plugin? There is no need for this plugin if you are proficient with Curves+.

Link to comment
Share on other sites

CodeLab is awesome! Thanks for taking responsibility for it -- I'm sure I'm not the only one who feels this way :)

And excellent plugin! :)

CodeLab is making me giddy.... O.O

CodeLab makes me giddy inside :)

EnisityLogo3_small.jpg

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