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

(RRR-GGG-BBB-AAA) -- (RRR-GGG-BBB-AAA)

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)

file.php?mode=view&id=4584&sid=0e3997e800ff9bc5c35ce3e5abe9d3f4

31105_08ba7683e9043eb8407afbdc499c0fe1

Thank You,

Aaron

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
#endregion

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;
           break;
           case 1:
               CurrentPixel.A = CurrentPixel.R;
               CurrentPixel.R = 255;
               CurrentPixel.G = 255;
               CurrentPixel.B = 255;
           break;
           }
           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.

Guest
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...