Jump to content

Recommended Posts

This effect allows you to change the color transparency separately in the R, G, and B channels.

 

TransparencyRGB.zip

 

You can find this effect in Adjustments menu.

 

This effect has a simple intuitive interface.

Trans-Rgb-Ui-En.png

 

The English or Russian interface of the effect is detected automatically.

 

Original image:

colormode.png

 

Result of applying the effect with default settings:

TransRgb.png

 

The result of applying the effect with the Invert checkbox checked:

Trans-Rgb-Inv.png

 

CodeLab source code:

Spoiler

// Name:Transparency RGB
// Submenu:
// Author:ReMake
// Title:Transparency RGB
// Version:1.0
// Desc:Adjustment of RGB channels transparency
// Keywords:paint.net|effect|transparency|rgb
// URL:https://www.getpaint.net/redirect/plugins.html
#region UICode
IntSliderControl Amount1 = 255; // [0,255,10] Red
IntSliderControl Amount2 = 128; // [0,255,11] Green
IntSliderControl Amount3 = 0; // [0,255,12] Blue
CheckboxControl Amount4 = false; // Invert
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    int R,G,B,A,color;
    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];
            R = CurrentPixel.R*(255 - Amount1)/255;
            G = CurrentPixel.G*(255 - Amount2)/255;
            B = CurrentPixel.B*(255 - Amount3)/255;

            color = R + G + B;
            A = 255 - color;

            if (Amount4) { A = 255 - A; }
            if (CurrentPixel.A == 0) {A = 0;}

            CurrentPixel.A = Int32Util.ClampToByte(A);

            dst[x,y] = CurrentPixel;
        }
    }
}

private void OnWindowHelpButtonClicked(IWin32Window owner, string helpContent)
{
    MessageBox.Show(owner, "Transparency RGB v1.0\n\nSeparate transparency adjustment for red,green, and blue channels.\n\nCopyright ©2020 by ReMake\nAll rights reserved.", "Transparency RGB", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

and icon icon.png

 

If the original image had transparent sections, they will be keep.

 

I hope you will find a use for this effect.

Edited by ReMake
Text editing.
  • Like 4
  • Upvote 2
Link to post
Share on other sites
  • 2 weeks later...

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