Jump to content

Change black to something else


Recommended Posts

I have an icon that has only colors between black and white and an alpha channel. I would like to replace the black part into, say, green, so that icon has color range from green to white, and retains its alpha channel. Adding one opaque green layer and fiddling with blend modes did not produce results, because then transparency is gone. Recolor tool is close, but does not recolor all pixels, even when tolerance is set to 100%. This task should be easy, but I gave up after two hours of trying. What should I do?

Link to comment
Share on other sites

I have an icon that has only colors between black and white and an alpha channel. I would like to replace the black part into, say, green, so that icon has color range from green to white, and retains its alpha channel. Adding one opaque green layer and fiddling with blend modes did not produce results, because then transparency is gone. Recolor tool is close, but does not recolor all pixels, even when tolerance is set to 100%. This task should be easy, but I gave up after two hours of trying. What should I do?

Look for a plugin called Grim Color Reaper.

Or, you could place an all green layer below your icon, invert the colors of your black and white icon, and change the layer property to multiply.

Or, if you are feeling adventurous, you could try this CodeLab script:

#region UICode
byte Amount1 = 0; // [1] Delete|White|Black 
#endregion

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

void Render(Surface dst, Surface src, Rectangle rect)
{
  ColorBgra CurrentPixel;
  for (int y = rect.Top; y < rect.Bottom; y++)
  {
     for (int x = rect.Left; x < rect.Right; x++)
     {
        CurrentPixel = desaturateOp.Apply(src[x,y]);
        switch(Amount1)
        {
           case 0: // White chosen
              CurrentPixel.A = (byte)(255-CurrentPixel.R);
              CurrentPixel.R = 0;
              CurrentPixel.G = 0;
              CurrentPixel.B = 0;
              break;
           case 1: // Black chosen
              CurrentPixel.A = CurrentPixel.R;
              CurrentPixel.R = 255;
              CurrentPixel.G = 255;
              CurrentPixel.B = 255;
              break;
        }
        dst[x,y] = CurrentPixel;
     }
  }
}

Link to comment
Share on other sites

I tried Grim Color Reaper plugin, and either I don't know how to use it or it does not do what I need. All I was able to manage was to remove black altogether.

I tried to fiddle with layers already, but then I lose alpha channel. Background becomes green where I want it to remain invisible.

I tried to save the script code above into .sls file and load it in script lab, but I get "Error loading script" message. Maybe I need to know more about scripts, so I'll investigate.

In the mean time, is there some other plugin that can help me here?

Link to comment
Share on other sites

1. Add a new layer underneath and fill it with the color you wish to replace the black with.

2. Run the Grim color reaper plugin on the top layer to remove the black.

3. Merge the layers.

No, Paint.NET is not spyware...but, installing it is an IQ test. ~BoltBait

Blend modes are like the filling in your sandwich. It's the filling that can change your experience of the sandwich. ~Ego Eram Reputo

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