public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask) { return (rgb2 & ~channelMask) | combinePixels(rgb1 & channelMask, rgb2, op, extraAlpha); }
public static int combinePixels(int rgb1, int rgb2, int op) { return combinePixels(rgb1, rgb2, op, 0xff); }
private int average(int rgb1, int rgb2) { return PixelUtils.combinePixels(rgb1, rgb2, PixelUtils.AVERAGE); }
public static int combinePixels(int rgb1, int rgb2, int op) { return combinePixels(rgb1, rgb2, op, 0xff); }
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask) { return (rgb2 & ~channelMask) | combinePixels(rgb1 & channelMask, rgb2, op, extraAlpha); }
public static int combinePixels(int rgb1, int rgb2, int op) { return combinePixels(rgb1, rgb2, op, 0xff); }
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask) { return (rgb2 & ~channelMask) | combinePixels(rgb1 & channelMask, rgb2, op, extraAlpha); }
protected int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace ) { int index = 0; int[] outPixels = new int[width * height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int pixel = 0xffffffff; for (int dy = -1; dy <= 1; dy++) { int iy = y+dy; int ioffset; if (0 <= iy && iy < height) { ioffset = iy*width; for (int dx = -1; dx <= 1; dx++) { int ix = x+dx; if (0 <= ix && ix < width) { pixel = PixelUtils.combinePixels(pixel, inPixels[ioffset+ix], PixelUtils.MIN); } } } } outPixels[index++] = pixel; } } return outPixels; }
protected int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace ) { int index = 0; int[] outPixels = new int[width * height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int pixel = 0xff000000; for (int dy = -1; dy <= 1; dy++) { int iy = y+dy; int ioffset; if (0 <= iy && iy < height) { ioffset = iy*width; for (int dx = -1; dx <= 1; dx++) { int ix = x+dx; if (0 <= ix && ix < width) { pixel = PixelUtils.combinePixels(pixel, inPixels[ioffset+ix], PixelUtils.MAX); } } } } outPixels[index++] = pixel; } } return outPixels; }
private void squareGradient(int[] pixels, int y, int w, int h) { int off = 0; float radius = Math.max(Math.abs(p2.x-p1.x), Math.abs(p2.y-p1.y)); for (int x = 0; x < w; x++) { float distance = Math.max(Math.abs(x-p1.x), Math.abs(y-p1.y)); float ratio = distance / radius; if (repeat) ratio = ratio % 2; else if (ratio > 1.0) ratio = 1.0f; int rgb = colormap.getColor(map(ratio)); pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; } }
private void conicalGradient(int[] pixels, int y, int w, int h) { int off = 0; float angle0 = (float)Math.atan2(p2.x-p1.x, p2.y-p1.y); for (int x = 0; x < w; x++) { float angle = (float)(Math.atan2(x-p1.x, y-p1.y) - angle0) / (ImageMath.TWO_PI); angle += 1.0f; angle %= 1.0f; if (type == BICONICAL) angle = ImageMath.triangle(angle); int rgb = colormap.getColor(map(angle)); pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; } }
dstPixels[index+i] = PixelUtils.combinePixels( dstPixels[index+i], colors[k], PixelUtils.ADD ); for ( int i = -1, k = 1; i >= xmin; i--, k++ ) dstPixels[index+i] = PixelUtils.combinePixels( dstPixels[index+i], colors[k], PixelUtils.ADD ); dstPixels[j] = PixelUtils.combinePixels( dstPixels[j], colors[k], PixelUtils.ADD ); for ( int i = -1, j = index-width, k = 0; i >= ymin; i--, j -= width, k++ ) dstPixels[j] = PixelUtils.combinePixels( dstPixels[j], colors[k], PixelUtils.ADD ); dstPixels[j] = PixelUtils.combinePixels( dstPixels[j], colors2[k], PixelUtils.ADD ); dstPixels[j] = PixelUtils.combinePixels( dstPixels[j], colors2[k], PixelUtils.ADD ); dstPixels[j] = PixelUtils.combinePixels( dstPixels[j], colors2[k], PixelUtils.ADD ); dstPixels[j] = PixelUtils.combinePixels( dstPixels[j], colors2[k], PixelUtils.ADD );
outPixels[index] = PixelUtils.combinePixels( inPixels[index], contourColor, PixelUtils.NORMAL, v );
private void radialGradient(int[] pixels, int y, int w, int h) { int off = 0; float radius = distance(p2.x-p1.x, p2.y-p1.y); for (int x = 0; x < w; x++) { float distance = distance(x-p1.x, y-p1.y); float ratio = distance / radius; if (repeat) ratio = ratio % 2; else if (ratio > 1.0) ratio = 1.0f; int rgb = colormap.getColor(map(ratio)); pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; } }
rgb = colormap.getColor(0); do { pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; colrel += dx; else rgb = colormap.getColor(map(colrel)); pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; colrel += dx; rgb = colormap.getColor(1.0f); do { pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; } while (--j > 0);
rgb = (rgb & 0xff000000) | (r << 16) | (g << 8) | b; if ( out[3] != 0 ) outPixels[x] = PixelUtils.combinePixels( rgb, inPixels[srcWidth*y + x], PixelUtils.NORMAL ); else outPixels[x] = rgb;
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; }
private void repeatGradient(int[] pixels, int w, int h, float rowrel, float dx, float dy) { int off = 0; for (int y = 0; y < h; y++) { float colrel = rowrel; int j = w; int rgb; while (--j >= 0) { if (type == BILINEAR) rgb = colormap.getColor(map(ImageMath.triangle(colrel))); else rgb = colormap.getColor(map(ImageMath.mod(colrel, 1.0f))); pixels[off] = PixelUtils.combinePixels(rgb, pixels[off], paintMode); off++; colrel += dx; } rowrel += dy; } }
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; }