/* JRG, the Resource Geology Seismic Processing System for Java, and Viewmat for Java are Copyright 1998-2003 by John N. Louie The software and methods here are the subject of academic research, not commercial products. I would like to know what use you make of my methods, and have your feedback on their success or failure. Also, by letting me know who you are, I can inform you if bugs or errors are discovered. Please send me an email message with: your name and email address; whether you are a student or faculty member, consultant or employee; the name of your university or company, and department; and a sentence or two describing what use you intend to make of these methods. Send your message to louie@seismo.unr.edu */ class RgRGB { int i; int R; int G; int B; void clipRgRGB() { if (this.i > 255) this.i = 255; else if (this.i < 0) this.i = 0; if (this.R > 255) this.R = 255; else if (this.R < 0) this.R = 0; if (this.G > 255) this.G = 255; else if (this.G < 0) this.G = 0; if (this.B > 255) this.B = 255; else if (this.B < 0) this.B = 0; } RgRGB(int index, int iR, int iG, int iB) { this.i = index; this.R = iR; this.G = iG; this.B = iB; } RgRGB(int index, float fR, float fG, float fB) { this.i = index; this.R = (int)(fR*255); this.G = (int)(fG*255); this.B = (int)(fB*255); } RgRGB(int index, float fR, float fG, float fB, int bright) { if (bright < 0) bright = 0; else if (bright > 255) bright = 255; bright = (int)(bright*3F/(fR + fG + fB)); this.i = index; this.R = (int)(fR*bright); if (this.R > 255) this.R = 255; this.G = (int)(fG*bright); if (this.G > 255) this.G = 255; this.B = (int)(fB*bright); if (this.B > 255) this.B = 255; } RgRGB(RgRGB rgb) { this.i = rgb.i; this.R = rgb.R; this.G = rgb.G; this.B = rgb.B; } }