We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Blending Modes (Read 1702 times)
Blending Modes
Jul 27th, 2007, 10:53pm
 
Hey, I'm loving the new PImage blending modes!  I don't know how you got the equations and explanations for the Photoshop modes.. I looked for a long time trying to find those once..

I had an idea to add.  How about a blending mode that simply 'keys out' pure black?  So you can do sprites without having to create alpha masks.  

[Also the "color" blending mode in Photoshop is one of my favorites...But that's another suggestion altogether..]


Re: Blending Modes
Reply #1 - Jul 28th, 2007, 3:27pm
 
why not just read your image and for every black pixel set its alpha channel to transparent.. thats how i would do it

for the other wish of yours this should get you going:
http://www.simpelfilter.de/en/grundlagen/mixmods.html

thing is you would have to do it yourself, but its possible
Re: Blending Modes
Reply #2 - Aug 7th, 2007, 9:39pm
 
>why not just read your image and for every black pixel set
>its alpha channel to transparent.. thats how i would do it

OK fine, I guess you don't need to cater to my laziness.. Wink

Thx for the blending mode equations!
Re: Blending Modes
Reply #3 - Sep 10th, 2007, 10:02pm
 
V wrote on Jul 28th, 2007, 3:27pm:
why not just read your image and for every black pixel set its alpha channel to transparent.. thats how i would do it


how do you do that
Re: Blending Modes
Reply #4 - Sep 11th, 2007, 5:03pm
 
here's a example of how to do it:

it reads an image and searches for white pixels.. it there it one, it will just write a new color with alphachannel equal to 0, which would make it transparent..
hope it helps.


PImage img;
PImage imga;


void setup()
{
 img = loadImage( "grid.png" );
 imga = createImage( img.width, img.height, RGB );
 
 
 for( int j=0; j<img.height; j++ )
 {
   for( int i=0; i<img.width; i++ )
   {
       // index to each pixel in the image
       int pix = i + j * img.width;

       // if this pixel color white ?
       if( color(img.pixels[pix]) == color(255) )
       {
         // if yes, change alpha channel
         imga.pixels[pix] = color(255, 255, 255, 0);
       }
       else
         // if not just copy pixel from the image
         imga.pixels[pix] = img.pixels[pix];
   }
 }  
}


void draw()
{
 background( 0, 255, 0 );
 image( imga, 0, 0 );
}
Page Index Toggle Pages: 1