Fast Real-Time blur for applet

The speed of the algo is independant from the blur radius (Summed area tables)

This is 8 years old code, so please don’t shoot me.
I know there is a better way to do this (without using a buffer image of the same size), but this works.
At least for blurring integer data, easily extendable to ARGB.

the Screen class is basically

class Screen{
int[] m; //holds the pixel raster
int w,h; //width and height
}

public static void doPreComputation(Screen src, Screen dst) {
		int[] s = src.m;
		int[] d = dst.m;
		int i = 0;
		int w = src.w;
		int h = src.h;
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				int tot = s[i];
				if (x > 0)
					tot += d[i - 1];
				if (y > 0)
					tot += d[i - w];
				if (x > 0 && y > 0)
					tot -= d[i - w - 1];
				d[i] = tot;
				i++;	
			}
		}
	}
	

	public static void doBoxBlur(Screen src, Screen dst, int w, int h, float fak) {
		int ww = src.w;
		int hh = src.h;
		int maxw = ww - 1;
		int muli = (int) ((2 << 15) * 1.f / (w * h * 4) * fak);
		int[] m = src.m;
		int[] dstmem = dst.m;
		int offset = 0;
		for (int y = 0; y < hh; y++) {
			int topy = y - h;
			if (topy < 0)
				topy = 0;
			else if (topy >= hh - 1)
				topy = hh - 1;
			topy *= ww;
			int bottomy = y + h;
			if (bottomy < 0)
				bottomy = 0;
			else if (bottomy >= hh - 1)
				bottomy = hh - 1;
			bottomy *= ww;
			for (int x = 0; x < ww; x++) {
				int leftx = x - w;
				if (leftx < 0)
					leftx = 0;
				else if (leftx >= maxw)
					leftx = maxw;
				int rightx = x + w;
				if (rightx < 0)
					rightx = 0;
				else if (rightx >= maxw)
					rightx = maxw;
				int tot = m[rightx + bottomy] + m[leftx + topy] - m[leftx + bottomy] - m[rightx + topy];
				tot *= muli;
				tot >>= 16;
				if (tot > 255)
					tot = 255;
				dstmem[offset++] = tot;
			}
		}
	}