Jump to content

How do you make an image truly monochromatic, with no translucency?


Recommended Posts

I have various images that need to be made monochromatic (icons for an app).  The original image has anti-aliasing, so there are lots of translucent pixels on the borders of the lines.  It is very, very difficult to tell the difference visually between a pixel that is completely transparent and one that is 99% transparent.  The only values I can use for pixels in the image are #00000000 (completely transparent) and #FFFFFFFF (fully opaque white).  Any pixels of any other value causes the image to be rejected.

 

Is there any effect I can apply or process I can go through to make all pixels that are mostly transparent become completely transparent, while pixels above a threshold become completely opaque white?

Link to comment
Share on other sites

Edit: ...great... I didn't see the other thread... :/

 

Run this in CodeLab. Pixels that have an opacity of 50% or less will be made completely transparent. Pixels over 50% will be made solid (100% opacity) white.

void Render(Surface dst, Surface src, Rectangle rect)
{
    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];

            if (CurrentPixel.A < 128)
            {
                CurrentPixel.A = 0;
            }
            else
            {
                CurrentPixel = Color.White;
            }
            
            dst[x,y] = CurrentPixel;
        }
    }
}
Edited by toe_head2001
  • Upvote 1
Link to comment
Share on other sites

Another way to achieve a monochromatic effect is to use Adjustments -> Black & White followed by Adjustments -> Posterize, and set the sliders to the minimum value (2).

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

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.

 Share

×
×
  • Create New...