private void process(Kernel kernel, int[] in, int[] out, int width, int height, boolean alpha, boolean wrap) {
		float[] matrix = kernel.getKernelData( null );
		int cols = kernel.getWidth();
		int cols2 = cols/2;

		for (int y = 0; y < height; y++) {
			int index = y;
			int ioffset = y*width;
			for (int x = 0; x < width; x++) {
				float r = 0, g = 0, b = 0, a = 0;
				int moffset = cols2;
				for (int col = -cols2; col <= cols2; col++) {
					float f = matrix[moffset+col];

					if (f != 0) {
						int ix = x+col;
						if (ix < 0) {
							if (!wrap) ix = 0; else ix = (x+width) % width;
						} else if (ix >= width) {
							if (!wrap) ix = width-1; else ix = (x+width) % width;
						}
						int rgb = in[ioffset+ix];
						a += f * ((rgb >> 24) & 0xff);
						r += f * ((rgb >> 16) & 0xff);
						g += f * ((rgb >> 8) & 0xff);
						b += f * (rgb & 0xff);
					}
				}
				int ia = alpha ? clamp((int)(a+0.5)) : 0xff;
				int ir = clamp((int)(r+0.5));
				int ig = clamp((int)(g+0.5));
				int ib = clamp((int)(b+0.5));
				out[index] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
                index += height;
			}
		}
    }