fix for #2439, set bounds on alpha

This commit is contained in:
Ben Fry
2014-04-11 13:47:57 -04:00
parent 16e972f674
commit f1cc624698
2 changed files with 7 additions and 7 deletions
+3 -2
View File
@@ -7287,14 +7287,15 @@ public class PGraphics extends PImage implements PConstants {
* Strangely the old version of this code ignored the alpha
* value. not sure if that was a bug or what.
* <P>
* Note, no need for a bounds check since it's a 32 bit number.
* Note, no need for a bounds check for 'argb' since it's a 32 bit number.
* Bounds now checked on alpha, however (rev 0225).
*/
protected void colorCalcARGB(int argb, float alpha) {
if (alpha == colorModeA) {
calcAi = (argb >> 24) & 0xff;
calcColor = argb;
} else {
calcAi = (int) (((argb >> 24) & 0xff) * (alpha / colorModeA));
calcAi = (int) (((argb >> 24) & 0xff) * PApplet.constrain((alpha / colorModeA), 0, 1));
calcColor = (calcAi << 24) | (argb & 0xFFFFFF);
}
calcRi = (argb >> 16) & 0xff;
+4 -5
View File
@@ -5,6 +5,10 @@ X call revalidate() via reflection
X text looks lousy compared to the Apple JVM
X mess with rendering hints? (notes in PGraphicsJava2D)
X improvements made, but still not amazing.. just at level of Windows/Linux
o XML.getChildren() throwing NPE when getInt() called on non-existent var
o https://github.com/processing/processing/issues/2367
X PGraphics.colorCalcARGB(int, float) doesn't cap alpha
X https://github.com/processing/processing/issues/2439
fixed in 2.1
X draw() called again before finishing on OS X (retina issue)
@@ -37,14 +41,9 @@ A https://github.com/processing/processing/issues/2416
A fix pixels[] array for video capture
A https://github.com/processing/processing/issues/2424
_ PGraphics.colorCalcARGB(int, float) doesn't cap alpha
_ https://github.com/processing/processing/issues/2439
_ tint() not working in PDF (regression from previous release)
_ https://github.com/processing/processing/issues/2428
_ XML.getChildren() fix
_ https://github.com/processing/processing/issues/2367
_ default font fixes
_ https://github.com/processing/processing/issues/2331
_ https://github.com/processing/processing/pull/2338