diff --git a/core/PApplet.java b/core/PApplet.java index 044a21df8..66cd4c6c4 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -3610,11 +3610,21 @@ public class PApplet extends Applet } + static public void alpha(PImage image, int alpha[]) { + PGraphics.alpha(image, alpha); + } + + public void alpha(PImage alpha) { g.alpha(alpha); } + static public void alpha(PImage image, PImage alpha) { + PGraphics.alpha(image, alpha); + } + + public void filter(int kind) { g.filter(kind); } diff --git a/core/PImage.java b/core/PImage.java index 11172e16f..015c48c50 100644 --- a/core/PImage.java +++ b/core/PImage.java @@ -172,13 +172,22 @@ public class PImage implements PConstants, Cloneable { * Set alpha channel for an image. */ public void alpha(int alpha[]) { + alpha(this, alpha); + } + + /** + * Set alpha channel for an image. + */ + static public void alpha(PImage image, int alpha[]) { // don't execute if mask image is different size - if (alpha.length != pixels.length) { + if (alpha.length != image.pixels.length) { System.err.println("alpha(): the mask image must be the same size"); return; } - for (int i = 0; i < pixels.length; i++) { - pixels[i] = pixels[i] & 0xffffff | ((alpha[i] & 0xff) << 24); + for (int i = 0; i < image.pixels.length; i++) { + image.pixels[i] = + ((alpha[i] & 0xff) << 24) | + (image.pixels[i] & 0xffffff); } /* if (highbits) { // grab alpha from the high 8 bits (RGBA style) @@ -191,7 +200,7 @@ public class PImage implements PConstants, Cloneable { } } */ - format = RGBA; + image.format = RGBA; } @@ -202,6 +211,10 @@ public class PImage implements PConstants, Cloneable { alpha(alpha.pixels); } + static public void alpha(PImage image, PImage alpha) { + alpha(image, alpha.pixels); + } + /** diff --git a/core/todo.txt b/core/todo.txt index 4a723ff30..7b53b93c2 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -136,8 +136,9 @@ X incorporated NO_FLYING_POO line/poly hack developed for axel X sort() should return an array, rather than sort in place X fix binary function, had wrong offset number X casey: i wan't able to get binary() to work at all: - -_ standalone 'alpha' function for PImage +o Typography: Helix won't compile +o works fine, just needs BFont -> PFont +X standalone 'alpha' function for PImage (static methods for alpha fxns) The biggest problem was the key and mouse functions not working. For example: Input: Mouse_Functions @@ -145,8 +146,6 @@ Input: Keyboard_Functions Image: Edge, Image: Blur: Alpha not set? The error is easier to see on Blur -Typography: Helix won't compile - .... _ processing.net -> PClient, PServer