Add java dithering code