Tell me more ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

In Paint.NET I'd like to change the color of an icon by using the fill tool, but I want to preserve the alpha-channel of the pixels. There's the same question for Photoshop, but I can't find a solution for Paint.NET.

Before fill:

Pixels with alpha channel

After fill:

Pixels without alpha channel

As you can see, the semi-transparent pixels lose their alpha-cannel value. Is there a way to achieve this in Paint.NET?

share|improve this question

2 Answers

up vote 1 down vote accepted

I have tried and failed to find a way to do this directly in Paint.NET 3.36.

You can't do it by filling a selection, as selections comprise whole pixels only, not alpha. The Tolerance setting on the Magic Wand tool just determines the colour threshold for selection of whole pixels.

Neither can you fake it with a "fill" layer above, as you can't use the original layer as a mask.

I think the closest thing you can do is use Adjustments > Curves to shift the hue of the pixels, but this is an indirect way of doing it, and it will be very difficult to hit a given target colour (although perhaps not impossible with a bit of maths).

However, you can render Mandelbrot and Julia fractals!

share|improve this answer
I played with the curves, but gave up on getting the exact color. Maybe I'll use Oil Painting instead :P – Gene Aug 15 '12 at 11:05

As a developer, I just wrote a small C# program to perform this task for me:

public class Program
{
  public const string IMAGE = @"logo.png";

  public static void Main(string[] args)
  {
    Color targetColor = Color.FromArgb(0, 3, 143, 106);

    using (var image = Bitmap.FromFile(IMAGE))
    {
      using (var bmp = new Bitmap(image))
      {
        for (int x = 0; x < image.Width; x++)
        {
          for (int y = 0; y < image.Height; y++)
          {
            var alpha = bmp.GetPixel(x, y).A;
            bmp.SetPixel(x, y, Color.FromArgb(alpha, targetColor.R, targetColor.G, targetColor.B));
          }
        }

        bmp.Save("icon.png", ImageFormat.Png);
      }
    }
  }

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.