diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index 5b4cc5ba9..9ea1f956e 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -594,18 +594,14 @@ public class PImage implements PConstants, Cloneable { throw new RuntimeException("Levels must be between 2 and 255 for " + "filter(POSTERIZE, levels)"); } - // TODO not optimized - int levels256 = 256 / levels; int levels1 = levels - 1; for (int i = 0; i < pixels.length; i++) { - int rlevel = ((pixels[i] >> 16) & 0xff) / levels256; - int glevel = ((pixels[i] >> 8) & 0xff) / levels256; - int blevel = (pixels[i] & 0xff) / levels256; - - rlevel = (rlevel * 255 / levels1) & 0xff; - glevel = (glevel * 255 / levels1) & 0xff; - blevel = (blevel * 255 / levels1) & 0xff; - + int rlevel = (pixels[i] >> 16) & 0xff; + int glevel = (pixels[i] >> 8) & 0xff; + int blevel = pixels[i] & 0xff; + rlevel = (((rlevel * levels) >> 8) * 255) / levels1; + glevel = (((glevel * levels) >> 8) * 255) / levels1; + blevel = (((blevel * levels) >> 8) * 255) / levels1; pixels[i] = ((0xff000000 & pixels[i]) | (rlevel << 16) | (glevel << 8) | @@ -1073,7 +1069,7 @@ public class PImage implements PConstants, Cloneable { /** - * Blend a two colors based on a particular mode. + * Blend two colors based on a particular mode. *
* BLEND - linear interpolation of colours: C = A*factor + B
* ADD - additive blending with white clip: C = min(A*factor + B, 255)
diff --git a/core/todo.txt b/core/todo.txt
index e19465fe9..395093628 100644
--- a/core/todo.txt
+++ b/core/todo.txt
@@ -10,6 +10,18 @@ X opengl doesn't draw a background for the raw recorder
X change P3D to smooth images nicely (bilinear was disabled)
X ambientLight(r,g,b) was still ambientLight(r,g,r)
X http://dev.processing.org/bugs/show_bug.cgi?id=465
+X fix from dave bollinger for the POSTERIZE filter
+X http://dev.processing.org/bugs/show_bug.cgi?id=399
+
+_ make sure the docs include "beginShape() cannot be nested"
+
+_ for PShape, need to be able to set the origin (flash people)
+
+_ look into anti-aliasing on osx
+_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1164236069
+
+_ 1.5.0_07 and 1.4.2_12 contain the -XX:+HeapDumpOnOutOfMemoryError switch
+_ invaluable for tracking down memory leaks
_ an offscreen JAVA2D graphics needs loadPixels() before being drawn
_ i.e. offscreen JAVA2D, then image() with OPENGL renderer as main