|
Author |
Topic: setting an alpha pixel (remove image pixel) (Read 349 times) |
|
Andre_Michelle
|
setting an alpha pixel (remove image pixel)
« on: Jul 31st, 2004, 6:56pm » |
|
I believe, that is simple, but i don't get it. Code: BImage a; BImage b; void setup() { size( 100 , 100 ); a = loadImage( "blue.gif" ); b = loadImage( "green.gif" ); image( a , 0 , 0 ); image( b , 0 , 0 , 50 , 50 ); } void loop() { b.set( mouseX , mouseY , color( 0 , 0 , 0 , 0 ) ); image( a , 0 , 0 ); image( b , 0 , 0 ); } |
| Draw black Pixels, but want to set Pixels with Alpha = 0, so the upper image will be transparent. Any suggestions ? [edit] Oh, even a transparent pixel.gif draws white(!) pixel. [/edit]
|
« Last Edit: Jul 31st, 2004, 7:03pm by Andre_Michelle » |
|
|
|
|
Andre_Michelle
|
Re: setting an alpha pixel (remove image pixel)
« Reply #1 on: Aug 1st, 2004, 3:47pm » |
|
Thats curious. An alpha channel with 0 seems not transparent, when adding him x times onto itself. http://www.andre-michelle.com/processing/temp/ floating errors ? Are there practices to avoid them in such case ? Code: Vector particles; BImage pin; void setup () { size( 400 , 400 ); particles = new Vector(); imageMode( 2 ); pin = new BImage( 11 , 11 ); pin.set( 6 , 6 , color( 255 , 128 , 0 ) ); //pin = loadImage( "pin.gif" ); // transparant with 1 px set. } void loop () { background(133); particles.addElement( new Particle( pin.copy() , pmouseX , pmouseY , 0.1 , 50 ) ); Particle p; for ( Enumeration e = particles.elements() ; e.hasMoreElements(); ) { p = (Particle)(e.nextElement()); p.render(); } } void destroy( Particle p ) { particles.removeElement( p ); } class Particle { BImage img; int lifeTime; float falloff; int x, y; int timer; Particle( BImage img, int x, int y, float falloff, int lifeTime ) { this.img = img; this.x = x; this.y = y; this.falloff = falloff; this.lifeTime = lifeTime; timer = 0; } public void render() { if ( ++timer > lifeTime ) destroy( this ); image( img , x , y ); } } |
| This is a simple ParticleMouse. If you stay a second, the alpha channel goes gray.
|
« Last Edit: Aug 1st, 2004, 3:49pm by Andre_Michelle » |
|
|
|
|
JohnG
|
Re: setting an alpha pixel (remove image pixel)
« Reply #2 on: Aug 3rd, 2004, 5:49pm » |
|
The loadImage function doesn't load alpha channels, you have to put them into a seperate image, load them, then use them, e.g.: void setup() { size(200,200); BImage Image=loadImage("Image1.jpg"); //the image BImage Alpha=loadImage("Image1.gif"); //the alpha mask Image.alpha(Alpha); background(color(128,128,12); image(Image,32,32); } ( http://www.hardcorepawn.com/Alpha/ )
|
|
|
|
|