PImage.alpha tweaks

This commit is contained in:
benfry
2004-09-02 21:25:40 +00:00
parent 84694d833f
commit 6fee49422d
3 changed files with 30 additions and 8 deletions

View File

@@ -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);
}

View File

@@ -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);
}
/**

View File

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