Mobile app version of vmapp.org
Login or Join
Ann6370331

: Fill an area while keeping transparency 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

@Ann6370331

Posted in: #PaintNet #Transparency

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:



After fill:



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

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann6370331

3 Comments

Sorted by latest first Latest Oldest Best

 

@RJPawlick971

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.
www.dropbox.com/s/pxrjmieg19k9x8r/AlphaColor.dll?dl=0

10% popularity Vote Up Vote Down


 

@Shanna688

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);
}
}
}

}

10% popularity Vote Up Vote Down


 

@Sims5801359

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!

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme