Sign in to follow this  
MJW

Transparent to Transparent Black

Recommended Posts

Transparent to Transparent Black is an utterly trivial Adjustment that changes all the transparent pixels to transparent black (0, 0, 0, 0). It can sometimes be useful, particularly when using the Texture Merger.

 

DLL, Version 1.0: TransparentToTransparentBlack.zip


The code:
 

Spoiler

 


// Name: Transparent to Transparent Black
// Submenu:
// Author: MJW
// Title: Transparent to Transparent Black
// Version: 1.0
// Desc: Change color transparent pixels to black.
// Keywords: transparent black
// URL:
// Help:
#region UICode
#endregion

ColorBgra TransparentBlack = ColorBgra.FromBgra(0, 0, 0, 0);
void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra pixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            pixel = src[x, y];
            if (pixel.A == 0)
                pixel = TransparentBlack;           
            dst[x, y] = pixel;
        }
    }
}


 

 

  • Like 1
  • Upvote 2

Share this post


Link to post
Share on other sites

No example I post would tell you much, since the only affected pixels are transparent.

 

When you clear a selection with Erase Selection, PDN fills the region with pixels with 0 for alpha, and (255, 255, 255) for the RGB values. Some plugins will make pixels transparent by setting alpha to 0, but leaving the RGB values unchanged. The RGB values can be anything, since if alpha is 0, the pixel will be transparent. Sometimes the RGB value matters, though. For example, when using the Maximum merge mode in the Texture Merger, it's almost always best to have the RGB of transparent canvas pixels set to 0, which represents the minimum height-map height. (Transparent pixels with RGBs of (255, 255, 255) are at the maximum height, so they will always win out in the Maximum comparison over clipboard pixels.) This plugin just sets all the transparent pixel RGBs to the same value, (0, 0, 0).

 

This is a really boring plugin that I wrote in response to the thread Setting and maintaining RGB values for zero-alpha pixels. Most people will have no need for it, but I decided to release it for those who might.

  • Like 1

Share this post


Link to post
Share on other sites

Sometimes I use the eraser on a layer; then I apply a plugin effect and can see where I erased.

Your plugin would remove traces of that?  Am I understanding correctly?

Share this post


Link to post
Share on other sites

Unfortunately, I don't think it would help with that. If you can describe what happens in more detail (or provide an example), maybe I or someone else can figure out the cause. I suppose it could be due to the color values in the transparent pixels, depending on what plugins were used.

Share this post


Link to post
Share on other sites

No, that's okay MJW.  It hasn't happened in a while and I would never remember what plugin I was using.

Thanks, though!  :)

Share this post


Link to post
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.

Sign in to follow this