Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. 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

3 Answers 3

up vote 7 down vote accepted

This is something I was looking for as well. The code was almost identical to the sample code of the CodeLab Tutorial Part 1 - Simple plugins walkthrough. So after a couple minutes, there is now a simple plugin to do this job right from Paint.NET.

https://dl.dropboxusercontent.com/u/90776664/Paint.NET/AlphaColor.dll

share|improve this answer
    
Works pretty well, thank you :) –  Gene Aug 20 '13 at 6:42
    
@Joel That's great if you are hosting it. I just cleaned the comments, thanks! –  Yisela Aug 20 '13 at 20:24
    
Awesome.. Thank you very much for this. Easy and simple and exactly what I needed!! –  user959729 Sep 23 '13 at 21:33
    
This works awesome. For Paint.NET noobs like me, how to install plugins: forums.getpaint.net/index.php?/topic/… The plugin shows up under Effects > Color, and applies whatever the current primary color is while preserving Alpha values. Thanks Joel! –  Ted A. Sep 24 '13 at 18:04

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.