The following code uses the RGBImageFilter class to create the “night” effect on an image:
import java.awt.image.*;public class NightFilter extends RGBImageFilter { double frac; //0.0<=g>>=16; int green=rgb & 0x0000FF00;green>>>=8; int blue=rgb & 0x0000FF; int r=(int) (red*frac); int g=(int) (green*frac); int b=(int) (blue*frac); return (0x000000FF