public static int interpolate(int v1, int v2, float f) { return clamp((int)(v1+f*(v2-v1))); }
public static int combinePixels(int rgb1, int rgb2, int op) { return combinePixels(rgb1, rgb2, op, 0xff); }
private void makeMap(int[] pixels, int[] map, int width, int height) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int offset = x + y * width; int b = useAlpha ? (pixels[offset] >> 24) & 0xff : PixelUtils.brightness(pixels[offset]); // map[offset] = b * one; map[offset] = b * one / 10; } } }
int offsetl = (int)(offset * 256 / levels); for ( int i = 0; i < 256; i++ ) table[i] = (short)PixelUtils.clamp( (int)(255 * Math.floor(levels*(i+offsetl) / 256) / (levels-1) - offsetl) ); r[1][x] = (short)PixelUtils.brightness( rgb ); for (int x = 0; x < width; x++) { int rgb = inPixels[nextRowIndex++]; r[2][x] = (short)PixelUtils.brightness( rgb ); outPixels[index] = PixelUtils.combinePixels( inPixels[index], contourColor, PixelUtils.NORMAL, v );
public int filterRGB(int x, int y, int rgb) { float nx = m00*x + m01*y; float ny = m10*x + m11*y; nx /= scale; ny /= scale * stretch; float f = fBm.evaluate(nx, ny); // Normalize to 0..1 f = (f-min)/(max-min); f = ImageMath.gain(f, gain); f = ImageMath.bias(f, bias); f *= amount; int a = rgb & 0xff000000; int v; if (colormap != null) v = colormap.getColor(f); else { v = PixelUtils.clamp((int)(f*255)); int r = v << 16; int g = v << 8; int b = v; v = a|r|g|b; } if (operation != PixelUtils.REPLACE) v = PixelUtils.combinePixels(rgb, v, operation); return v; }
dstPixels[index + i] = PixelUtils.addPixels(dstPixels[index + i], colors[k]); dstPixels[index + i] = PixelUtils.addPixels(dstPixels[index + i], colors[k]); dstPixels[j] = PixelUtils.addPixels(dstPixels[j], colors[k]); dstPixels[j] = PixelUtils.addPixels(dstPixels[j], colors[k]); dstPixels[j] = PixelUtils.addPixels(dstPixels[j], colors2[k]); dstPixels[j] = PixelUtils.addPixels(dstPixels[j], colors2[k]); dstPixels[j] = PixelUtils.addPixels(dstPixels[j], colors2[k]); dstPixels[j] = PixelUtils.addPixels(dstPixels[j], colors2[k]);
public int filterRGB(int x, int y, int rgb) { float nx = m00*x + m01*y; float ny = m10*x + m11*y; nx /= scale; ny /= scale * stretch; float f = turbulence == 1.0 ? Noise.noise2(nx, ny) : Noise.turbulence2(nx, ny, turbulence); f = (f * 0.5f) + 0.5f; f = ImageMath.gain(f, gain); f = ImageMath.bias(f, bias); f *= amount; int a = rgb & 0xff000000; int v; if (colormap != null) v = colormap.getColor(f); else { v = PixelUtils.clamp((int)(f*255)); int r = v << 16; int g = v << 8; int b = v; v = a|r|g|b; } if (operation != PixelUtils.REPLACE) v = PixelUtils.combinePixels(rgb, v, operation); return v; }
public int filterRGB(int x, int y, int rgb) { if ( randomNumbers.nextFloat() <= density ) { int a = rgb & 0xff000000; int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; if (monochrome) { int n = (int)(((distribution == GAUSSIAN ? randomNumbers.nextGaussian() : 2*randomNumbers.nextFloat() - 1)) * amount); r = PixelUtils.clamp(r+n); g = PixelUtils.clamp(g+n); b = PixelUtils.clamp(b+n); } else { r = random(r); g = random(g); b = random(b); } return a | (r << 16) | (g << 8) | b; } return rgb; }
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask) { return (rgb2 & ~channelMask) | combinePixels(rgb1 & channelMask, rgb2, op, extraAlpha); }
public int filterRGB( int x, int y, int rgb ) { return lut[ PixelUtils.brightness( rgb ) ]; }
break; case ADD: r1 = clamp(r1+r2); g1 = clamp(g1+g2); b1 = clamp(b1+b2); break; case SUBTRACT: r1 = clamp(r2-r1); g1 = clamp(g2-g1); b1 = clamp(b2-b1); break; case DIFFERENCE: r1 = clamp(Math.abs(r1-r2)); g1 = clamp(Math.abs(g1-g2)); b1 = clamp(Math.abs(b1-b2)); break; case MULTIPLY: r1 = clamp(r1*r2/255); g1 = clamp(g1*g2/255); b1 = clamp(b1*b2/255); break; case DISSOLVE: break; case DST_IN: r1 = clamp((r2*a1)/255); g1 = clamp((g2*a1)/255); b1 = clamp((b2*a1)/255); a1 = clamp((a2*a1)/255);
private int average(int rgb1, int rgb2) { return PixelUtils.combinePixels(rgb1, rgb2, PixelUtils.AVERAGE); }
@Override public int filterRGB( int x, int y, int rgb ) { return lut[ PixelUtils.brightness( rgb ) ]; }
public int filterRGB(int x, int y, int rgb) { int a = rgb & 0xff000000; int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; int nr = PixelUtils.clamp((intoR * (blueGreen*g+(255-blueGreen)*b)/255 + (255-intoR)*r)/255); int ng = PixelUtils.clamp((intoG * (redBlue*b+(255-redBlue)*r)/255 + (255-intoG)*g)/255); int nb = PixelUtils.clamp((intoB * (greenRed*r+(255-greenRed)*g)/255 + (255-intoB)*b)/255); return a | (nr << 16) | (ng << 8) | nb; }
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask) { return (rgb2 & ~channelMask) | combinePixels(rgb1 & channelMask, rgb2, op, extraAlpha); }
public int filterRGB(int x, int y, int rgb) { int v = PixelUtils.brightness( rgb ); float f = ImageMath.smoothStep( lowerThreshold, upperThreshold, v ); return (rgb & 0xff000000) | (ImageMath.mixColors( f, black, white ) & 0xffffff); }
public int filterRGB(int x, int y, int rgb) { int a = rgb & 0xff000000; int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; r = PixelUtils.clamp((int)(r * rFactor)); g = PixelUtils.clamp((int)(g * gFactor)); b = PixelUtils.clamp((int)(b * bFactor)); return a | (r << 16) | (g << 8) | b; }
public static int combinePixels(int rgb1, int rgb2, int op) { return combinePixels(rgb1, rgb2, op, 0xff); }