Skip to content

Instantly share code, notes, and snippets.

@diogotito
Created November 7, 2022 17:54
Show Gist options
  • Save diogotito/2854e8b4b23654511c55f3dba4a71193 to your computer and use it in GitHub Desktop.
Save diogotito/2854e8b4b23654511c55f3dba4a71193 to your computer and use it in GitHub Desktop.
Paint.NET CodeLab filter to calculate alpha for Windows tooltip shadow pixels in screenshots
// Name:
// Submenu:
// Author:
// Title:
// Version:
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
IntSliderControl Amount1 = 0; // [0,100] Slider 1 Description
IntSliderControl Amount2 = 0; // [0,100] Slider 2 Description
IntSliderControl Amount3 = 0; // [0,100] Slider 3 Description
#endregion
const byte TOOLTIP_GRAY = 118;
void Render(Surface dst, Surface src, Rectangle rect)
{
for (int y = rect.Top; y < rect.Bottom; y++)
{
for (int x = rect.Left; x < rect.Right; x++)
{
ColorBgra currentPixel = src[x,y];
float grayDist = (currentPixel.R - TOOLTIP_GRAY) * 256 / (256 - TOOLTIP_GRAY);
currentPixel.R = currentPixel.G = currentPixel.B = 118;
currentPixel.A = (byte)(255 - grayDist);
dst[x,y] = currentPixel;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment