Jump to content

Extract Drop Shadow (Gradient-to-Color vs Gradient-to-Alpha)

Recommended Posts

Is there a way "Extract" a drop shadow in Paint.net?

For example:

I have a Gradient that is from Black to White. It represents a Drop Shadow on top of a White Background, (All in one layer. no transparency. kinda like if the Drop Shadow was "flattened", or you took a "Print Screen" of it). (left half of attached image)

How would you Convert that to a Gradient that is from Black to Transparent? Basically I want to replace White, and any level of "white" within the image, with that same level of Transparency. (right half of attached image)

Color Crosswalk:

Initial color -- post-extract color


000-000-000-255 -- 000-000-000-255 (black stays black)

093-093-093-255 -- 000-000-000-163 (black, but a little bit transparent)

212-212-212-255 -- 000-000-000-044 (black, a little more transparent)

255-255-255-255 -- 000-000-000-000 (white turns into black, fully transparent)



Thank You,


Link to comment
Share on other sites

Here is a CodeLab script to do what you want:

#region UICode
byte Amount1 = 0; // [1] Delete|White|Black

private UnaryPixelOps.Desaturate desaturateOp = new UnaryPixelOps.Desaturate();

void Render(Surface dst, Surface src, Rectangle rect)
   ColorBgra CurrentPixel;
   for (int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           CurrentPixel = desaturateOp.Apply(src[x,y]);
           switch (Amount1) {
           case 0:
               CurrentPixel.A = (byte)(255-CurrentPixel.R);
               CurrentPixel.R = 0;
               CurrentPixel.G = 0;
               CurrentPixel.B = 0;
           case 1:
               CurrentPixel.A = CurrentPixel.R;
               CurrentPixel.R = 255;
               CurrentPixel.G = 255;
               CurrentPixel.B = 255;
           dst[x,y] = CurrentPixel;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...