: 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
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?
More posts by @Ann6370331
3 Comments
Sorted by latest first Latest Oldest Best
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
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);
}
}
}
}
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!
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.