Jump to content


Recommended Posts

Yes, the Magic Wand, but then it will look awful and unprofessional and defeat the purpose of an alpha mask in the first place. Sorry.

Have you checked out Crazy Man Dan's tutorial on alpha masking? It explains the method you have employed thus far but you never know, it might lead you down a new road or spark off an idea or two.

Link to comment
Share on other sites

There is an Alpha Mask Import Plugin by Illnab1024. How that compares to other alpha masking in alternate programs I do not know. Is this what you meant?

No, I know all plugins available. Long time ago there was a topic about masking. I can't find it at the moment, I believe it was in GD. Someone requested masking and then a discussion started (if I remeber right). Some users created rather a sketch of code (codelab). I pasted it into codelab and compiled a dll. It worked not that good (but it worked), and as I said, it was not developed further. Seems it died out.

Link to comment
Share on other sites

Perhaps this may put you at ease for the time being:

Over the lifetime of the 4.xx releases, these core design and architecture changes should enable such features as layer masks, adjustment layers, effect layers, composite layers, effect and adjustment chaining, soft selections, scripting and recorded actions, a completely new brush system, much more efficient memory usage, and better use of multiprocessor systems.

If you post the .dll you have some kind, coding soul could enhance it until the official implementation. Look at ScriptLab, scripting in PDN will come eventually but pyro has given us this functionality early.

Link to comment
Share on other sites

Thanks to all of you guys for replying. I'm actually referring off of Crazy Man Dan's tutorial, and that's a nice effect, Enormator. Problem is, I'm actually referring to extracting a person from a background and as you know, a person isn't one primary color. I can't imagine how a plugin for Alpha-Masking would work....though I know nothing about Alpha-Masking. :? Oh, and I'm really looking forward to the 4.xx releases (nevermind that they're 2 years away) because of the custom brushes. It really is a disadvantage for Paint.NET not to have that feature. :|

Link to comment
Share on other sites

Given the key sentence is:

I find it EXTREMELY hard to draw the mask by hand [...] Is there an easier method?

Yes, there is.

It's named the magnetic lasso.

Magnetic Lasso -- This is requested a lot. Tom wants to do this but we have no ETA.

No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio

Link to comment
Share on other sites

If you post the .dll you have some kind, coding soul could enhance it until the official implementation. Look at ScriptLab, scripting in PDN will come eventually but pyro has given us this functionality early.

I don't think I'm allowed to do this due to the plugin share rights. Maybe I could post the code. I think I pasted it into a rtf document, the question is if I would find it (assumed that I still have it).

What I don't know is if this is the right place to post it.

Link to comment
Share on other sites

OK, let's try. I searched my PC and found a doc (not rtf :wink: )called "chroma masking" and I believe this is it. I don't nkow about differences between alpha and chroma masking, but maybe the code will find usage in any case.

Don't get confused by the plugins listed on top of the code, I think the code is only based on these plugins.

The entire code is not my work. If any of the authors does not want to have it here, please write it or PM me or a mod, I will remove it as fast as possible.

* /! Warning, this is GPL code! 
* Color2Alpha Paint.NET plugin by Bibinou based on : 
* Color To Alpha plug-in v1.0 by Seth Burgess & others, 1999/05/14 
* The GIMP -- an image manipulation program 
* Copyright (C) 1995 Spencer Kimball and Peter Mattis 
* You should have received a copy of the GNU General Public License 
* along with this program; if not, write to the Free Software 
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 

void Render(Surface dst, Surface src, Rectangle rect) 
  PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
  Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); 

  long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); 
  long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); 
  ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; 

  ColorBgra CurrentPixel = new ColorBgra(); 
  double red, key_red, green, key_green, blue, key_blue, alpha, maxalpha; 
  int rnew, gnew, bnew; 

  for(int y = rect.Top; y < rect.Bottom; y++) 
     for (int x = rect.Left; x < rect.Right; x++) 
        if (selectionRegion.IsVisible(x, y)) 

           CurrentPixel = src[x,y]; 

           red = CurrentPixel.R ; 
           green = CurrentPixel.G ; 
           blue = CurrentPixel.B ; 

           key_red = PrimaryColor.R ; 
           key_green = PrimaryColor.G ; 
           key_blue = PrimaryColor.B ; 

           /* Store red alpha component */ 
           if (red   >= key_red  ) 
           alpha = (key_red   == 255 ? 0 : (red - key_red ) / (255 - key_red)  ); 
           alpha = (key_red   == 0 ? red  / 255 : 1.0 - red / key_red ); 
           maxalpha = alpha; 

           /* Store green alpha component, if greater */ 
           if (green >= key_green) 
           alpha = (key_green == 255 ? 0 : (green - key_green) / (255 - key_green)); 
           alpha = (key_green == 0 ? green/ 255 : 1.0 - green / key_green ); 
           if (alpha > maxalpha) maxalpha = alpha; 

           /* Store blue alpha component, if greater */ 
           if (blue  >= key_blue ) 
           alpha = (key_blue  == 255 ? 0 : (blue  - key_blue ) / (255 - key_blue )); 
           alpha = (key_blue  == 0 ?  blue / 255 : 1.0 - blue / key_blue  ); 
           if (alpha > maxalpha) maxalpha = alpha; 

           /* Threshold the alpha */ 
           //alpha = (maxalpha * 255) / pvals.threshold ; 

           /* Using int to Math.Round the values */ 
           if (alpha > 1) alpha = 1 ; 
           else if (alpha < 0) alpha = 0 ; 

           if (alpha > 0) { 
           rnew = (int) ( Math.Round( (red   - key_red  ) / alpha + key_red   ) ) ; 
           gnew = (int) ( Math.Round( (green - key_green) / alpha + key_green ) ) ; 
           bnew = (int) ( Math.Round( (blue  - key_blue ) / alpha + key_blue  ) ) ; 
           else { 
           rnew = (int) red; 
           gnew = (int) green; 
           bnew = (int) blue; 

           if ( rnew <=255 && gnew <=255 && bnew <=255 && rnew >=0 && gnew >=0 && bnew >= 0) 
           CurrentPixel.R = (byte)rnew ; 
           CurrentPixel.G = (byte)gnew ; 
           CurrentPixel.B = (byte)bnew ; 
           CurrentPixel.A = (byte)(alpha * 255) ; 

           dst[x,y] = CurrentPixel; 


              dst[x,y] = src[x,y]; 
/* EOF */

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