Here you can find the source of generateColorModel()
public static ColorModel generateColorModel()
//package com.java2s; //License from project: Open Source License import java.awt.image.ColorModel; import java.awt.image.IndexColorModel; public class Main { public static ColorModel generateColorModel() { byte[] r = new byte[255]; byte[] g = new byte[255]; byte[] b = new byte[255]; for (int i = 0; i < 255; i++) { r[i] = (byte) ((i * 26) % 250); g[i] = (byte) ((i * 2) % 250); b[i] = (byte) ((i * 35) % 250); }//from w w w . j a v a2s . com return new IndexColorModel(8, 255, r, g, b); } }