Skip to content

Instantly share code, notes, and snippets.

@Banane9
Created May 19, 2017 20:01
Show Gist options
  • Save Banane9/c32c3997448d8da884312368b6c2872d to your computer and use it in GitHub Desktop.
Save Banane9/c32c3997448d8da884312368b6c2872d to your computer and use it in GitHub Desktop.
Paint.Net plugin that makes all completely transparent pixels have the same RGB values.
// Name: Monochromatic Alpha
// Submenu:
// Author: Banane9
// Title: Monochromatic Alpha
// Version: 1.0.0
// Desc: Makes all completely transparent pixels have the same RGB values.
// Keywords: adjustment, alpha channel, monochromatic, color, correction, fix
// URL: http://github.com/Banane9
// Help:
void Render(Surface dst, Surface src, Rectangle rect)
{
ColorBgra primaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
ColorBgra currentPixel;
for (int y = rect.Top; y < rect.Bottom; ++y)
{
if (IsCancelRequested)
return;
for (int x = rect.Left; x < rect.Right; ++x)
{
currentPixel = src[x,y];
if (currentPixel.A == 0)
{
currentPixel.R = primaryColor.R;
currentPixel.G = primaryColor.G;
currentPixel.B = primaryColor.B;
}
dst[x,y] = currentPixel;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment