private int paethPredictor(byte[] line, byte[] previousLine, int x, int xp) {
		int a = 0xFF & ((xp < 0) ? 0 : line[xp]);
		int b = 0xFF & previousLine[x];
		int c = 0xFF & ((xp < 0) ? 0 : previousLine[xp]);
		int p = a + b - c;

		int pa = (p >= a) ? (p - a) : -(p - a);
		int pb = (p >= b) ? (p - b) : -(p - b);
		int pc = (p >= c) ? (p - c) : -(p - c);

		if (pa <= pb && pa <= pc) {
			return a;
		}

		return (pb <= pc) ? b : c;
	}