dither[idx] appears to match y exactly .. can you consolidate this so it's like value = dither[y] and avoid all the else if checks?