samer@0: /* samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.tools; samer@0: import java.awt.Color; samer@0: import java.awt.image.ColorModel; samer@0: import java.awt.image.IndexColorModel; samer@0: samer@0: /** samer@0: Objects of these class could be used directly, samer@0: but main purpose is to help construct an IndexColorModel samer@0: for an image samer@0: */ samer@0: samer@0: public class ColorRamp implements java.io.Serializable samer@0: { samer@0: private byte r[], g[], b[], a[]; samer@0: private int size; samer@0: private int lasti; samer@0: private Color lastc; samer@0: samer@0: samer@0: public ColorRamp(int sz) samer@0: { samer@0: size=sz; samer@0: r=new byte[size]; samer@0: g=new byte[size]; samer@0: b=new byte[size]; samer@0: a=new byte[size]; samer@0: } samer@0: samer@0: public Color getColor(int i) { samer@0: int ir = ((int)r[i] & 0xff); samer@0: int ig = ((int)g[i] & 0xff); samer@0: int ib = ((int)b[i] & 0xff); samer@0: return new Color(ir,ig,ib); samer@0: } samer@0: samer@0: public Color[] getColorArray() { samer@0: Color[] clut=new Color[size]; samer@0: for (int i=0; i=256.0) return (byte)255; samer@0: else return (byte)t; samer@0: } samer@0: } samer@0: