Jump to content

Color my gray hair


Recommended Posts

I had an idea for making a plugin that would color my gray hair...

I'll just leave this code here in case I ever get bored again and try to fix it. (Also, someone smarter than me may have an idea to make it work.)

Needs work...


// Author: BoltBait
#region UICode

// Setup for using Difference blend op
private BinaryPixelOp differenceOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Difference);
private BinaryPixelOp darkenOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Darken);

// Here is the main render loop function
unsafe void Render(Surface dst, Surface src, Rectangle rect)
    for (int y = rect.Top; y < rect.Bottom; y++)
        if (IsCancelRequested) return;
        ColorBgra* srcPtr = src.GetPointAddressUnchecked(rect.Left, y);
        ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y);
        for (int x = rect.Left; x < rect.Right; x++)
            ColorBgra CurrentPixel = *srcPtr;
            ColorBgra SourcePixel = *srcPtr;

            HsvColor hsv = HsvColor.FromColor(CurrentPixel.ToColor());
            int H = hsv.Hue;
            int S = hsv.Saturation;
            int V = hsv.Value;
            byte A = CurrentPixel.A;

            V = 100-V;

            CurrentPixel = ColorBgra.FromColor(new HsvColor(H,S,V).ToColor());
            CurrentPixel.A = A;

            CurrentPixel = differenceOp.Apply(*srcPtr, CurrentPixel);
            CurrentPixel = darkenOp.Apply(CurrentPixel,SourcePixel);

            *dstPtr = CurrentPixel;

"Just for Men" is easier...



  • Upvote 2
Link to comment
Share on other sites

Awww, aye I hear the Can Am 3-wheelers are pretty good and safe as well! :D  Perhaps one of those would be a good substitute. :D

I was thinking about this plug in, you could also probably create a chrome reflective effect as opposed to using curves+ plug-in with a few other steps which always takes time to do. From your thumbnail images, it may be able to do it all at once.


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